language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> #include <string.h> #include <stdbool.h> int main(){ char str[30]; int i; int length; printf("输入一段字符串\n"); for( i=0 ; i<30 ; i++ ) { str[i]=getchar(); if(str[i]==EOF) { str[i-1]='\0'; break; } if(i==28) { str[29]='\0'; break; } } length = strlen(str); bool a = tru...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include "grafo.h" /* Programa que detecta a similaridade entre dois textos (.txt) utilizando grafos Mateus Ferreira Gomes --------- Universidade de São Paulo Instituto de Ciências Matemáticas e de Computação */ int verifica(FILE* fp){ FILE *save; save = ...
C
#include <stdlib.h> #include <stdio.h> #include <math.h> int power(int number, int nthpower) { int product=number; while(nthpower>1) { product=product*number; nthpower--; } return product; } void checkpre() { } void binarysearch(int min,int max,int number, int nthroot, int precision) { int temp=(min+max...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* test_map_border.c :+: :+: :+: ...
C
/** POSIX DESCRIPTION Name: aio.h - asynchronous input and output. Description: The <aio.h> header shal define the aiocb structure, which shall inclide the following members int aio_fildes File descriptor. off_t aio_offset File offset. volatile void *...
C
#include<stdio.h> #include<conio.h> #include<math.h> void main() { int a,b,c,d,e,f,g; clrscr(); printf("your quadratic equation looks like ax^2 +bx +c =0 \n"); printf("enter value of a"); scanf("%d",&a); printf("enter value of b"); scanf("%d",&b); printf("enter value of c"); scanf("%d",&c); d=pow(b,2)-...
C
/* Copyright (c) 2020 Advanced Micro Devices, Inc.  All rights reserved. Sep 24, 2020 */ #define DRAND() ( ( double ) rand() / ( ( double ) RAND_MAX / 2.0F ) ) - 1.0F; #define SRAND() ( float ) ( ( double ) rand() / ( ( double ) RAND_MAX / 2.0F ) ) - 1.0F; /* Initialize matrix with random values */ void ran...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #include "code.h" double minimum(double * tab, int taille) { int i=1; double min=tab[0]; for (i=1;i<taille;i++){ if (tab[i]<=min){ min=tab[i]; } } return min; } double maximum(double * tab, int taille) { int i=1; double max=tab[0...
C
#include <stdio.h> #include <memory.h> #include <malloc.h> #include <string.h> #define NAME_LENGTH 20 typedef struct _Robot { char name[NAME_LENGTH]; int energy; float data; }Robot; /** methods for Robot Class **/ void RobotCreate(Robot **robot) { *robot = (Robot*)malloc(sizeof(Robot)); // initialize the argume...
C
/* ----------------------------------------------------------------------------- * $Id: Stable.h,v 1.14 2002/12/19 14:25:04 simonmar Exp $ * * (c) The GHC Team, 1998-2000 * * Stable Pointers: A stable pointer is represented as an index into * the stable pointer table in the low BITS_PER_WORD-8 bits with a * weig...
C
#include <stdio.h> int main () { int num,i,sum=0; printf ("Please input a integer number : "); scanf ("%d",&num); for (i=0;num;i++){//find last most digit and these sum sum+= num%10; num/=10; } printf ("Sum of the digit of this number is : %d",sum); return 0; }
C
#include <stdio.h> extern double aTof(const char *s); /* 测试重写的 aTof() 函数 */ int main(void) { char *number[] = {"48829.34", "-3804.53", "123.45e-6", "1.2e2"}; int i; for (i = 0; i < 4; ++i) printf("%g\n", aTof(number[i])); return 0; }
C
// C Primer Plus // Chapter 9 Exercise 11: // Write and test a Fibonacci() function that uses a loop instead of recursion // to calculate Fibonacci numbers. #include <stdio.h> long Fibonacci(long n); int main(void) { long n; printf("Test Fibonacci() function\n"); printf("Enter an integer n: "); while (scanf(...
C
#include <stdint.h> int main() { int a, b, c, d, e, f, g, h; printf("Unesi ip adresu: \n"); scanf("%d.%d.%d.%d", &a, &b, &c, &d); printf("Unesi subnet masku: \n"); scanf("%d.%d.%d.%d", &e, &f, &g, &h); printf("ip adresa je: %d.%d.%d.%d", a & e, b & f, c & g, d & h); return 0; }
C
#include "graph.h" graph_t * graph_new (int count) { /* allocates and initializes memory for a new graph_t structure */ graph_t *g = calloc(1, sizeof(graph_t)); g->nodes = (int **) calloc(count, sizeof(int *)); g->count = count; g->names = (char **) calloc(count + 1, sizeof(char *)); g->edges ...
C
/* * Simulates a physical layer from the TCP/IP model. * Following this tutorial: http://www.linuxhowtos.org/C_C++/socket.htm * possibly, the following too: http://www.dicas-l.com.br/arquivo/programando_socket_em_c++_sem_segredo.php#.V9lODHUrLDc */ /* Camada Física: Recebe arquivo Transforma em binário ...
C
#include <stdio.h> int main(void){ int H,W; scanf("%d%d",&H,&W); char data[H+2][W+2]; char ans[H+2][W+2]; char sample[W]; for(int i = 0;i < H+2;i++){ for(int j = 0;j < W+2;j++){ data[i][j] = '.'; ans[i][j] = '#'; } } for(int i = 1;i < H+1;i++){ scanf("%s",samp...
C
/* Autor: Sabrina Beck Angelini RA: 157240 Disciplina: MC202 Turma: E Tarefa 06 Segundo semestre de 2014 */ /* * analisador.c: Mdulo de transformao de expresses em rvores * binrias e seus percursos. */ #include "analisador.h" #include <stdlib.h> #include <ctype.h> #i...
C
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> void main() { int count = 0; FILE* fp; fp = fopen(".txt", "w"); fputs("\nâ\nâ\nâ\n\nö\nŸ\nŸ\nܴٸũ\nũƮ\n Ÿ\n", fp); char imshee[200] = { NULL }; fclose(fp); fp = fopen(".txt", "r"); while (fgets(imshee, 200, fp)) { printf("%s", imshee); ...
C
#include "math.h" #include "FFT.h" struct compx EE(struct compx a,struct compx b) { struct compx c; c.real=a.real*b.real-a.imag*b.imag; c.imag=a.real*b.imag+a.imag*b.real; return(c); } void FFT(struct compx *xin) { int f,m,nv2,nm1,i,k,l,j=0; struct compx u,w,t; // ַ㣬Ȼ˳ɵλ򣬲׵㷨 nv2=NPT/2; ...
C
#include <stdio.h> #include <cs50.h> #include <math.h> int main(void) { float change; do { change = get_float("How much change is owed? "); } while (change < 0); int cents = round(change * 100); int coins = 0; int quarter, dime, nickel, penny; quarter = 25; dime = 10; ...
C
/** @file Blob verifier library that uses SEV hashes table. The hashes table holds the allowed hashes of the kernel, initrd, and cmdline blobs. Copyright (C) 2021, IBM Corporation SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include <Library/BaseCryptLib.h> #include <Library/BaseLib.h> #in...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/stat.h> #include <fcntl.h> #include <stdio.h> #include <sys/time.h> #include <sys/types.h> #include <sys/wait.h> int main() { int c; FILE *in, *out; struct timeval tempo1, tempo2; struct timezone tzp; double tempo; in = fopen("file1GB.in","r");...
C
//Program to implement : File Object W/R //Refer : FileHandling.png //See : fileObjectIO.png #include<stdio.h> typedef struct { char name[20]; int age; char gender; } Person; int main() { FILE *fio; int ch; Person p = {"Vikas", 25, 'M'}; Person p1; fio = fopen("d:\\objectIO.txt",...
C
#include<stdio.h> /* ӡ */ void printArr(int nums[],int n){ printf("\n"); int i = 0; for(i=0;i<n;i++){ printf("%d\t",nums[i]); } printf("\n"); } /* ʹöֲ˳вԪk */ void insertK(int nums[],int n,int k){ int mid;// ¼м± int low=0,high=n-1; int flag=0;// ־¼Ƿеkֵ int pos;// ıΪλ while(low<=high&&flag==0){// ѭlo...
C
#include<stdio.h> int main() { int a = 0, b = 0, ch = 0, result = 0; scanf_s("%d", &a); scanf_s("%d", &b); printf("enter 1.add 2.sub 3.div 4.mul"); scanf_s("%d", &ch); switch (ch) { case 1: result = add(a, b); break; case 2: result = sub(a, b); break; case 3: result = div(a, b); break; case 4: ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> int statCalc(int dice); int diceRoll(); void operation(int dice); int main() { printf("Welcome to the Stat Roller!\n"); printf("This Stat Roller can use the Standard, Classic, or Heroic rolls to determine stats\n"); int choice; int dice; ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_validation.c :+: :+: :+: ...
C
/** * @file webnav.c * @brief POJ 1057 */ #include <stdio.h> #include <string.h> char sites[101][71]={"http://www.acm.org/"}; char cmd[8]; int main(void) { int i=0; loop: scanf("%s",cmd); switch(*cmd){ case 'Q': return 0; case 'V': scanf("%s",sites[++i]); sites[i+1][0]='\0'; break; case 'B': i--; ...
C
#include "common.h" int rem_dupl(slist **head) { //validation if(*head == NULL) { return LIST_EMPTY; } //initialize slist *temp, *temp1; temp = *head; slist *remp; //run an outer loop to compare each value one by one to other elements while(temp) { //start another pointer to start the run from the valu...
C
#include <stdio.h> #include <string.h> int main(int argc, char** argv) { if(argc < 2) return -1; const char* str = argv[1]; unsigned int l = strlen(str), h = 2 ^ l, i = 0, k; while(l >= 4) { k = str[i] | str[i+1] << 8 | str[i+2] << 16 | str[i+3] << 24; k = (k & 0xffff) * 1540483477 + (((...
C
/* int L_saturate(double dVar1) { if( dVar1 > (double)0x7FFFFFFF ) { return 0x7FFFFFFF; } else if( dVar1 < (double)0x80000000){ return (int)0x80000000; } else { return (int)dVar1; } } int L_deposit_l(short var1) { return (int)var1; } int L_deposit_h(short var1) { int lvar; lvar = (int ) var1 << 16; ...
C
#include <stdio.h> // for stderr #include <stdlib.h> // for exit() #include "types.h" #include "utils.h" #include "riscv.h" void execute_rtype(Instruction, Processor *); void execute_itype_except_load(Instruction, Processor *); void execute_branch(Instruction, Processor *); void execute_jal(Instruction, Processor *); ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_vector.c :+: :+: :+: ...
C
/* Grace */ #include <stdio.h> #define ENDL 10 #define C_ARRAY "/*%c Grace%c*/%c#include <stdio.h>%c%c#define ENDL 10%c#define C_ARRAY %c%s%c%c#define MAIN() int main(){FILE *fd; fd = fopen(%cGrace_kid.c%c, %cw%c); fprintf(fd, C_ARRAY, ENDL, ENDL, ENDL, ENDL, ENDL, ENDL, 34, C_ARRAY, 34, ENDL, 34, 34, 34, 3...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> //MsgIdentifier functions void openFile(); char readNextCharacter(); void messageIdentifier(); void carryMessage(int msg_length); //Pre-processing functions void preProcessing(int msg_length, char message_type); void preProcessingMDFull(); void preProcessin...
C
#include "holberton.h" /** * _abs - computes the absolute value of an integer * @r: this is the integral value * * Return: if r > 0, return r. 0 otherwise */ int _abs(int r) { if (r > 0) { return (r); } else { return (-r); } }
C
/* * @lc app=leetcode.cn id=11 lang=c * * [11] 盛最多水的容器 */ // @lc code=start //双指针 int maxArea(int* height, int heightSize){ if(heightSize == 0) return 0; int maxArea = 0; int left = 0; int right = heightSize - 1; int temp; while(left != right){ //短的一侧移动,找寻更高的 if(height[le...
C
// // basiccube.c, a wireframe, 3D unit cube with one vertex at the origin // // compile: // gcc -L/usr/lib64 -O2 basiccube.c -lX11 -lGL -lGLU -lglut -lm -lXmu // -o basiccube // // #include <stdio.h> #include <GL/gl.h> #include <GL/glut....
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.c :+: :+: :+: ...
C
#include <stdio.h> #include <Windows.h> #pragma warning(disable:4996) char * _strcpy(char * destination, const char * source) { int i = 0; while (source[i] != '\0') { destination[i] = source[i]; i++; } destination[i] = '\0'; return destination; } int main() { char str1[] = "Sample string"; ...
C
#include <check.h> #include "../main/roman-numerals-reducer.h" #include "test-constants.h" static void assertReduceNumerals(char *input, char *reduceBy, char *expected); START_TEST(testReduceSingleValue) { assertReduceNumerals("II","I","I"); assertReduceNumerals("VII","V","II"); } END_TEST START_TEST(testReduceM...
C
/* 本程序将记录棒球运动员的文件内容输入至结构体中,且计算平均成绩,显示到屏幕。 计划:升级为菜单交互式程序。 */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #include <time.h> #include "extra.h" #define LEN 20 struct name { char fname[LEN]; char lname[LEN]; }; struct playerdate { int num[4]; double average; }; typedef s...
C
#include<stdio.h> int main() { int i; for(i=0; i<=5; i++) { if(i==4) break; printf("%d \n",i); } }
C
// // Created by gianluca on 18/12/19. // #include <stdio.h> #include <stdlib.h> typedef struct { int u, v; } arco; arco* leggiFile(int *n, int *e) { FILE *fp = fopen("grafo.txt","r"); arco *ar; fscanf(fp,"%d %d",n, e); ar = malloc(*e* sizeof(arco)); for (int i = 0; i < *e; i++) { fsca...
C
/* Properly formatted Quine. */ #include <stdio.h> const char *s[ ] = { "\n", "int main( )\n", "{\n", " printf( \"/* Properly formatted Quine. */\\n\" );\n", " printf( \"\\n\" );\n", " printf( \"#include <stdio.h>\\n\" );\n", " printf( \"\\n\" );\n", " printf( \"const char *s[ ] =\\n\" );\n", "...
C
#include <stdio.h> void extOdDigits(long n, long *nd); int main(void) { long n, *nd; nd = &n; printf("Please enter a postive int: "); scanf("%ld", &n); extOdDigits(n, nd); printf("Output: %ld\n",n); return 0; } void extOdDigits(long n, long *nd) { long i = 1;long digits = 0;long j = 1; ...
C
#include<stdio.h> int main() { int a,b,c,sum; printf("Enter Your Data:"); scanf("%d %d %d",&a,&b,&c); sum = a+b+c; if(sum == 180 && a != 0 && b != 0 && c != 0) { printf("Triangle is valid\n"); } else { printf("Triangle is not valid\n"); } return 0; }
C
#include <stdio.h> int main() { int a, b; char op; scanf("%d %c %d", &a, &op, &b); switch (op) { case '+' : printf("%d\n", a + b); break; case '-' : printf("%d\n", a - b); break; case '*' : printf("%d\n", a * b); break; case '/' : printf("%d\n", a / b); break; cas...
C
#include <stdio.h> #include <stdlib.h> // please allocate a 10 long array and fill it with even numbers // please allocate a 10 long array and fill it with odd numbers // select an array, and push the elements into the another array // the resulting array should be 20 elements long // print the array in descending ord...
C
#include <stdio.h> #include <math.h> int main(void) { float a,b; scanf("%f %f",&a,&b); printf("%.4f",pow(a,b)); return 0; }
C
#include <Tuareg_platform.h> #include <Tuareg.h> #include "serial_buffer.h" volatile ComRx_Buffer_t ComRx_Buffer= { .write= 0, .read= 0, .unread= 0 }; /** */ void ComRx_Buffer_reset() { ComRx_Buffer.write= 0; ComRx_Buffer.read= 0; ComRx_Buffer.unread= 0; } /** */ VU32 ComRx_Buffer...
C
#include<stdio.h> void main() { int A , B, C , D, DIFERENCA; scanf("%d%d%d%d",&A ,&B ,&C ,&D); DIFERENCA=(A * B - C * D); printf("DIFERENCA = %d\n",DIFERENCA); }
C
/****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. Code, Compile, Run and Debu...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_reco.c :+: :+: :+: ...
C
/* Copyright 2013 Bliksem Labs. See the LICENSE file at the top-level directory of this distribution and at https://github.com/bliksemlabs/rrrr/. */ /* geometry.c */ #include "geometry.h" #include "config.h" #include <math.h> #include <stdio.h> // Mean of Earth's equatorial and meridional circumferences. #define EAR...
C
#include<stdio.h> int main(){ int num1, num2; printf("Enter 2 integers, and I will tell you\n"); printf("the relationships the satisfy: "); scanf("%d%d", &num1, &num2); if (num1 == num2) { printf("%d is equal to %d\n", num1, num2); }; if (num1 != num2) { printf("%d is not equal to %d\n", num1,...
C
#include <limits.h> #include <stdio.h> #include <stdlib.h> #define TRUE 1 #define FALSE 0 #define MAX_VERTICES 100 #define INF 1000000 //Ѵ. ( ) typedef struct GraphType { int n; // int weight[MAX_VERTICES][MAX_VERTICES]; } GraphType; int distance[MAX_VERTICES]; int found[MAX_VERTICES]; int trace[MAX_VERTI...
C
/** * Forking a process * * Let n be the return of the fork * 1. if n < 0, fork failed * 2. if n == 0, child is running currently * 3. if n > 0, parent is running currently * * Note: Sometimes parent might exit before the execution of the child * Resolution: wait() */ #include <unistd.h> #include <string.h>...
C
/* Number of ones in an integer's binary representation. */ int number_ones(unsigned int n) { int ones = 0; while (n) { n = n & (n - 1); ones ++; } return ones; } void test() { cout << number_ones(7) << endl; }
C
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <float.h> #include <constant.h> #include <formulas.h> #include <matrix.h> /**/ static int arg_parse( int, char ** ); int main( int argc, char **argv ) { int i, axis; double Sxx, Sxy, Sxz, Syy, Syz, Szz; double ang; double input_array[3]; doubl...
C
#include <stdio.h> int main(void) { int counter, till; printf("カウントダウン: "); scanf("%d", &till); for(counter=till; counter >= 0; counter--) { printf("%d\n", counter); } printf("\a\n"); return 0; }
C
#ifndef SQLIST_H #define SQLIST_H /* 定义顺序表的头文件 */ //定义一个数据类型的宏,这样能在想修改数据类型时,只修改此处 #define ElementType int #define InitialSize 50 //此处是动态分配顺序表的定义 typedef struct { ElementType *data; int MaxSize, length; } Sqlist; //对顺序表进行初始化 extern void init(Sqlist *L); //动态地对顺序表进行构造 extern void construct(Sqlist *L); //在第...
C
/************************************************************************************************* * Copyright 2019-2021 FieldComm Group, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the Licens...
C
/* ************************************************************************** */ /* */ /* :::::::: */ /* ft_printf_lib.c :+: :+: ...
C
#include <stdio.h> int main() { int num,rev=0,rem,tmp; printf("Enter num:"); scanf("%d",&num); tmp=num; while(tmp!=0) { rem=tmp%10; //rem=4 rev=rev*10+rem; //rev=4 tmp=tmp/10; // tmp= } printf("rev no.: %d \n",rev); }
C
#include <math.h> #if 1 typedef struct { unsigned char rgbtRed; unsigned char rgbtGreen; unsigned char rgbtBlue; } __attribute__((__packed__)) RGBTRIPLE; #endif // Blur image void blur(int height, int width, RGBTRIPLE image[height][width], RGBTRIPLE imgout[height][width]) { int wid = width - 1...
C
#include <stdio.h> int main(void) { int all; scanf("%d", &all); for (int y = 0; y < all; y++) { int store, quest; scanf("%d %d", &store, &quest); int price[store]; int money[quest]; for (int z = 0; z < store; z++) { scanf(" %d", &price[z]); } for (int x = 0; x < quest; x++) { ...
C
int longestPalindrome(char * s){ if(strlen(s)==1) return 1; int tmp[128]={0}; int count=0; int i=0; for(i=0;i<strlen(s);i++) { tmp[s[i]]++; } for(i=0;i<128;i++) { //直接统计奇数的个数 最后结果就是其他的偶数再加一个中间位的奇数 if(tmp[i]%2==1) count++; } return count==0? strlen...
C
#include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <pthread.h> #include <string.h> void *rout(void *arg) { int i; for(;;) { printf("I am thread1\n"); sleep(1); } } int main() { pthread_t tid; int ret=0; if((ret==pthread_create(&tid,NULL,rout,NULL))!=0) ...
C
#include "registracion.h" #include <stdbool.h> #include <sys/ipc.h> #include <sys/sem.h> #include <sys/msg.h> #include <stdio.h> #define SOLO_C #include "../../common/common.h" bool ids_dispositivos_disponibles[MAX_DISPOSITIVOS_EN_SISTEMA]; //ver si ampliamos los ids int siguiente_id_dispositivo; bool ids_tester_dispo...
C
#include <stdio.h> int boo(); int bar(int a,int b); int baz(int *p,int n); int g = 31; int d[] = {1,2,3,4,5}; int main(int argc, char *argv[]) { int x,y,z; x = boo(); y = bar(3,7); z = baz(d,5); printf("%d %d %d\n",x,y,z); return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "solidos.h" int main(int argc, char **argv) { int ncones = atoi(argv[1]); cone *p = (cone*) malloc(ncones * sizeof(cone)); for(int i = 0; i < ncones; i++) { novo_cone((p + i)); } printf("Cones: %d\n", ncones); for...
C
#include "../fibonacci.h" int sum_fibonacci_even(int first, int second, int max_term) /* Prints out sum of even terms of Fibonacci sequence less than max_term */ { int nxt, total=0; if ( first % 2 == 0 ) { total += first; } if ( second % 2 == 0 ) { total += second; } whil...
C
#include <stdio.h> void sortnum(int *arr,int n){ int i=0,j=0; for(j=1;j<n;j++){ int key=arr[j]; i=j-1; while(i>=0&&arr[i]>key){ arr[i+1]=arr[i]; i--; } arr[i+1]=key; } } int main(){ FILE *fp; if((fp=fopen("inpu.txt","rb+"))==NULL){ printf("Cannot read file\n"); exit(1); } int unsorted[4...
C
#include <stdlib.h> #include <stdio.h> #include <assert.h> int nametest(char a, char b, char c); int isvowel(char arg); int isconsonant(char arg); int sumtest(char a, char b, char c); int isprime(int a); //Test function void assertion(void); int main() { printf("print your name:\n"); char a = getchar(); cha...
C
#include <types.h> #include "cpuid.h" #include "cpuid_data.h" /* * Detects the kind of CPU in the system. */ cpu_info_t* cpuid_detect() { uint32_t ebx, unused; cpuid(0, unused, ebx, unused, unused); switch(ebx) { case 0x756e6547: // Intel Magic Code return cpuid_detect_intel(); break; case 0x6874754...
C
//#define _GNU_SOURCE #define _POSIX_C_SOURCE 200112L #include <stdlib.h> #include <stdio.h> #include "common.h" int myrank; void * myalloc(size_t size) { size_t align = 64; #if 0 char *a = malloc(size+32); int o = ((size_t)a) & 31; o = (32 - o) & 31; char *b = a + o; return (void *)b; #else void *b = N...
C
#include<stdio.h> int main(int argc,char* argv[],char* env[]) { //argc : 命令行参数的个数, 本质上就是argv数组的元素个数 //argv :具体的命令行参数 // envp : 环境变量的值 for(int i=0;i<argc;i++) { printf("%s\n",argv[i]); } for(int i=0;env[i]!=NULL;i++) { printf("%s\n",env[i]); } return 0; }
C
/** * @file Option.c */ #include <stdio.h> #include <bolib.h> #if isWindows # include <windows.h> # include <tchar.h> #endif #include <stdlib.h> #include <string.h> #include <ctype.h> #include "common/Observer.h" #include "common/puts.h" #include "common/strres.h" #if !isWindows typedef char TCHAR; #endif #inc...
C
// C program to remove alternate nodes of a linked list #include<stdio.h> #include<stdlib.h> /* A linked list node */ struct Node { int data; struct Node *next; }; /* deletes alternate nodes of a list starting with head */ void deleteAlt(struct Node *head) { if (head == NULL) return; /* Initialize ...
C
//coded by Jason Thong for CoE3DQ5 2017 //convert a *.bmp (bitmap file) to a *.ppm (portable pixel map file) #include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char **argv) { int i, j, k, width, height; char input_filename[200], output_filename[200]; unsigned char *r_image, *g_image, *b_...
C
#include <stdio.h> //Standard input and output #include <math.h> #include "input.h" // declare function void decryption(char *x, int key); void CaesarDecrypt() { // Initialise variables and string char message[100]; int key, i=0; /*Prompts user to enter message and key and stores them ...
C
//This program gets ten real numbers from the user and //then prints them out in the reverse order. #include <stdio.h> int main(int argc, char* argv[]) { double array[10]; printf("Enter ten real numbers: "); int i; for (i = 0; i < 10; i++) { scanf("%lf", &array[i]); } ...
C
/* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by...
C
/** @file Component.h @brief A base class for components that's used so components can be stored in a large blocks of memory, together. */ #pragma once /** \brief A based structure to represent a component. */ struct Component { Component() = default; //!< Default constructor. virtual ~Component() = default; //!< ...
C
#include "../rover.h" char *strdup(const char *str) { char *a; char *str1; int i; str1 = (char *)str; i = 0; a = (char *)malloc(strlen(str1) + 1); if (a == NULL) return (NULL); while (str[i] != '\0') { a[i] = str1[i]; i++; } a[i] = '\0'; return (a); }
C
#include<stdio.h> void main() { int n,i; int sum = 0; printf("Enter the n i.e max values of series:\n"); scanf("%d",&n); sum = (n*(n + 1))/2; printf("Sum of the series :\n"); for(i=1;i<=n;i++) { if(i!=n) printf("%d +",i); else printf("%d = %d",i,sum); } printf("\n"); }
C
#include<stdio.h> void main(){ for (int i = 1; i < 5; i++) { printf(i*5); printf("\n"); /* code */ } }
C
#include <SDL2/SDL.h> #include <stdio.h> #include <math.h> void spherePrimitiveByPoints(SDL_Renderer* gRenderer, SDL_Point center, int radius, int thickness){ //int count_between_Ys = 0; int circleY = center.y; int circleX = center.x; int yPosOfCirclePointDown; int yPosOfCirclePointUp; int xPosOfCirclePoint = ...
C
#include<stdio.h> void main() { int arr[20],*ptr,i,size; printf("Enter size of array :"); scanf("%d",&size); printf("Enter array elements :"); for(i=0;i<size;i++) { scanf("%d",&arr[i]); } ptr=arr; printf("Array elements are :\n"); for(i=0;i<size;i++) { /*printf("%...
C
#include <stdio.h> #include <unistd.h> int my_is_prime(int nb) { int re = nb / 2; if(nb == 2) return 1; while(re > 1) { if(nb % re == 0) return 0; else return 1; re--; } return 0; }
C
// Copyright (C) 76 Enterprises LLC - All Rights Reserved // See the file "license.txt" for the full copyright notice #pragma once #include <library/collections/vector.h> #include <boost/preprocessor/library.hpp> typedef VECTOR(U8) ae_serializer; // To make sizeof work, we say a varint is the largest it can be. ty...
C
#include <stdio.h> #include <string.h> int convert(char* n, int m) { int l = strlen(n), sum = 0, i; for (i = 0; i < l; i++) { sum *= m; if (n[i] >= '0' && n[i] <= '9') sum += n[i] - '0'; else sum += n[i] - 'A' + 10; } return sum; } char* r...
C
#include <stdio.h> #include <stdlib.h> int func(int x) { int a, a0, a1, a2; a0 = x * x * 2 + 1; a1 = x + 2 - a0; a2 = x / 2 + a1; a = a0 + a1 + a2; printf("a: %d\n", a); return a; } int main(void) { int i = 1; while(1) { i = func(i); sleep(3); } return EXIT_...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef char element; typedef struct stackNode { element data; struct stackNode *link; } stackNode; stackNode *top; void push(element item) { stackNode* temp = (stackNode*)malloc(sizeof(stackNode)); temp->data = item; temp->link = top; top = temp; } el...
C
/* This file contains code to calculate Kendall's Tau in O(N log N) time in * a manner similar to the following reference: * * A Computer Method for Calculating Kendall's Tau with Ungrouped Data * William R. Knight Journal of the American Statistical Association, Vol. 61, * No. 314, Part 1 (Jun., 1966), pp. 436-43...
C
#include "../src/sds.h" #include <stdio.h> #include <assert.h> int main(int argc, char *argv[]) { printf("size:%ld\n", sizeof(struct sdshdr)); sds sname = sdsnew("hello sds"); printf("%s\n", sname); assert(sdslen(sname) == 9); assert(sdsavail(sname) == 0); sds sdup = sdsdup(sname); printf("%s\n", sdup...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* show_alloc_mem.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> long filesize(FILE *stream); void main() { long size,pos; char ch; FILE *fp_in,*fp_out; if((fp_in =fopen("data.dat","r"))==NULL) { printf("can't open file stud.dat\n"); exit(1); } if((fp_out =fopen("trans.dat","w"))==NULL) { fclose(fp_in); printf("can't open fi...