language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> int a=10;/*global variable*/ int b=10; int main(void) { int c=20;/*local variable*/ int d=20; int g=a+b; int e=c+d; { int h=30;/*block scope*/ int s=50; int j=h+s; printf("the value of j is=%d\n",j); } printf("the value of g is=%d\n",g); printf("the value of e...
C
/* * * 4094 shift register functions * */ #include <avr/io.h> #include "hc4094.h" void HC4094Init(void) { //Set pins as output HC4094_DDR|=((1<<HC4094_CLOCK_PIN)|(1<<HC4094_LATCH_PIN)|(1<<HC4094_DATA_PIN)); } //Sends a clock pulse void HC4094Pulse(void) { HC4094_PORT|=(1<<HC4094_CLOCK_PIN); HC4094_PORT&=(~(1<<HC...
C
#include <stdlib.h> #include <ax/alloc.h> #include <stdio.h> #include <stdarg.h> // ========================================= #define TEST(n,e,f) printf("%-20s [%s]\n", (n), (e) == (f) ? "\e[32mOk\e[0m" : "\e[31mErr\e[0m" ) void test_stack () { void* stack[2048]; int sp = 0; xHeapArea_t heap; meminit...
C
// Copyright [2019] <mituh> // SetFind.c // 集合的存储: 孩子双亲表示法, 并查集, 按秩合并 typedef struct { ElementType Data; int Parent; /* 根结点为-n, n代表集合元素个数 */ } SetType; #define MaxSize 20 int Find(SetType S[ ], ElementType X) { /* 在集合S中查找元素X的根(所属的集合) */ /* MaxSize全局, 是数组S的最大长度 */ int i; for (i = 0; i < MaxSize && S[i].D...
C
#include "josephus.h" #include <stdio.h> #include "circular_array.h" #include "circular_list.h" void JP_execute(int N, int M){ ca* a = CA_init(N); //cl* a = CA_init(); for(int i = 0; i < N; i++){ CA_insert(a, i+1); } int last_idx = 0; while(CA_getSize(a) > 1){ i...
C
#include "hanzi.h" #include "util.h" #include <sys/mman.h> #include <stdio.h> #include <stdbool.h> /* I use a 2-byte integer to store the index in the pinyin_tbl for each Hanzi. * This representation is compact and is easy to search (since the pinyin table * is just a array). * If need to support polyphone, I can u...
C
/* * Test cases from Googles Double Conversion Library * * https://github.com/google/double-conversion/blob/master/test/cctest/test-strtod.cc * * Added extra tests for grisu parse print roundtrip and negative sign. */ #include <string.h> #include <stdio.h> #include <math.h> #include "grisu3_print.h" #include "g...
C
#include <stdio.h> #include<stdlib.h> main () { float p,h, imc; printf("\n Digite seu peso: "); scanf("%f", &p); printf("\n Digite sua altura: "); scanf("%f", &h); imc=p/(h*h); printf("\n %f",imc); if (imc<=17){ printf("\n %.2f peso Muito Abaixo para sua altura %.1f",imc,h); } if (imc<=18.4...
C
#include<stdio.h> #include<malloc.h> struct list { int data ; struct list *prev , *next ; } ; void insert(struct list **head , int data) { struct list *newNode = malloc(sizeof(struct list)) ; newNode -> data = data ; newNode -> prev = NULL ; newNode -> next = NULL ; if(*head == NULL) { *head = newNode ; ...
C
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <math.h> int fxy(int k,int limit) // use this function to determin the location of the nearby pixels of image. //(else if used to find the border pixels) { if (k>=0 && k<=limit-1) { ...
C
#include <stdlib.h> #include <stdint.h> #include <stdio.h> #include "assert.h" #include "seq.h" #include "bitpack.h" #include "mem-infra.h" #include "instrs.h" #include "in_out.h" #include "parse_instr.h" int main(int argc, char *argv[]) { //Check number of arguments if (argc > 2) { fprintf(stder...
C
#include <stdio.h> #include <errno.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> #include <signal.h> #include <string.h> #include <arpa/inet.h> #include <inttypes.h> #include <pthread.h> #include <dirent.h> #inc...
C
#include "../include/simulator.h" /* ****************************************************************** ALTERNATING BIT AND GO-BACK-N NETWORK EMULATOR: VERSION 1.1 J.F.Kurose This code should be used for PA2, unidirectional data transfer protocols (from A to B). Network properties: - one way network delay...
C
#ifndef _MONHOC_H #define _MONHOC_H #include<iostream> #include<fstream> #include<string.h> #include"struct.h" //#include"CauHoiThi.h" #define MAXMH 100 //SO SANH MA MH int SoSanhMaMH(string mA, string mB) { int x = mA.length(); int y = mB.length(); int z; if(x < y) { z = x; } else z = y; for(int i = 0; i <...
C
#include <stdio.h> #include <limits.h> //ͷļڶһЩڱֵ int main() { int a = 4; printf("The size of a: %d\n\n", sizeof a); printf("The range of short: [%hd, %hd]\n",SHRT_MIN,SHRT_MAX); printf("The range of unsigned short: [0, %hu]\n",USHRT_MAX); printf("The size of short: %d Bytes = %d bits \n\n", sizeof (short), 8 *...
C
/* Author: 17051713 gcc studentManage.c -o test */ #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> typedef struct student { int sno; char *sname; int sage; int sclass; struct student* next; } stuInfo, *pStuInfo; #define ADD 1 #define DEL 2 #define SEEA 3 #define SE...
C
#include<stdio.h> #include<stdlib.h> int *buildtree(int *A,int n) { int *st = (int*)malloc((2*n-1)*sizeof(int)); int i,j; for(i=0;i<n;i++) { st[i+n-1] = i; } for(i=n-2;i>-1;i--) { j = 2*i; st[i] = (st[j+1])^(st[j+2]); } return st; } void update(int st[],int A[],int i,int n,int x) { A[i] =...
C
#include "list.h" #include "interrupt.h" /*初始化双向链表list*/ void list_init(struct list* list) { list->head.prev = NULL; list->head.next = &list->tail; list->tail.prev = &list->head; list->tail.next = NULL; } /*将链表元素elem插入在元素before之前*/ void list_insert_before(struct list_elem* before, struct list_elem* elem) { enum...
C
#include <stdlib.h> #include <string.h> #include <stdio.h> #include <sys/time.h> #include <time.h> #include <math.h> #include <stdbool.h> static void timestamp(FILE *f); // https://stackoverflow.com/questions/3673226/how-to-print-time-in-format-2009-08-10-181754-811 static void timestamp(FILE *f) { char buffer[2...
C
// //Basic tool for editing the comment field within a song. // #include <stdio.h> #include <stdlib.h> #include "id3v2lib/include/id3v2lib.h" int main( int argc, char ** argv ) { if( argc != 3 ) { fprintf( stderr, "Error: Use: writeid3soruce [mp3 file] [op] < comment (current argc = %d)\n", argc ); fprintf( st...
C
#include <stdio.h> #include <stdlib.h> int main(){ float x, y; printf("Введите первое число: "); scanf("%f", &x); printf("Введите второе число: "); scanf("%f", &y); if (x >= y) printf("Большим было число %.3f\n", x); else printf("Большим было число %.3f\n", y); getch(); }...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "person_data.h" void getPersonData(long, __p_data *p_data); void updatePersonData(long, __p_data *p_data); void getPersonData(long st_num, __p_data *p_data) { FILE *file; char loc[100] = "data/\0"; char stnum_buf[20]; char str[20]; int element, ...
C
/* ----------------------------------------------------------------------------- FILE: yosh.c NAME: Nathaniel Koehler DESCRIPTION: A shell that essentially contains many of the basic necessary elements. This includes the jobs, exit, history, kill, cd, and help commands. This shell also supports --------------------...
C
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include "queue.h" #include "linked_list.h" typedef struct queue{ node h; node t; } queue; Queue queue_new(void) { Queue new = malloc(sizeof(*new)); assert(new != NULL); new->h = NULL; new->t = NULL; return new; } void queue_destroy(Queue q) { as...
C
// function to print current mode void printMode(char printArray[], int numElements) { int j; UARTCharPut(UART2_BASE, 254); UARTCharPut(UART2_BASE, 134); for (j = 0; j < numElements; j++) { UARTCharPut(UART2_BASE, printArray[j]); } } // function to print current song void printSong(char printArray[], i...
C
#include "pipe_networking.h" #include <ctype.h> // converts given string to upper case string void to_upper(char *str) { int i = 0; while (str[i]) { str[i] = toupper(str[i]); i++; } } int main() { int to_client; //file descriptor of downstream pipe. Write to this one int from_client; //WKP. Read fr...
C
#include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <sys/socket.h> #include <string.h> #include <netinet/in.h> #include <sys/un.h> #include <signal.h> #include "structures2.h" #include <arpa/inet.h> char *name; int S; void close_sockets(); void handle_sigint(int nr); void open_sockets(char*, char*);...
C
#define F_CPU 8000000UL #include <avr/io.h> #include <util/delay.h> #define LED_DDR DDRB ///< DDR of LED. #define LED_PORT PORTB ///< Port of LED. #define BLUE_PIN 0 ///< Pin number of blue colour LED terminal. #define GREEN_PIN 1 ///< Pin number of green colour LED terminal. #define RED_PIN 2 ///< Pin nu...
C
// // ex2_12.c // CICCOPN C // #include <stdio.h> int main() { /* declaração de variáveis */ int numero=0, factorial = 1, i=0; /* Leitura de variáveis */ printf("Indique um valor: "); scanf("%d", &numero); if (numero < 0 || numero > 15) { printf("Erro"); return...
C
#include <stdio.h> #include <string.h> void main(int argc, char *argv[]){ int shift = atoi(argv[1]); FILE *fn; fn = fopen(argv[2],"r"); if(fn == NULL){ printf("ERROR"); return; } int c; char word[1000]; int i = 0; c = fgetc(fn); while(c != EOF){ if (c == '\n'){ i++; break; } word[i] = c + shi...
C
/* * Copyright (c) 2016 Lammert Bies * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publi...
C
#include <stdio.h> #include <stdlib.h> #include <windows.h> int main(){ char buf[1000]; HWND hWnd; hWnd = GetForegroundWindow(); WINDOWINFO windowInfo; windowInfo.cbSize = sizeof(WINDOWINFO); GetWindowInfo(hWnd, &windowInfo); printf("bottom=%d, left=%d, right=%d, top=%d\n", ...
C
#include <system.h> #include <string.h> extern queue_t xAlarmClockQueue; void vAlarmClock_Init(alarmClock_t *pxAlarmClock, const char* name, void (*timeoutFunc)(void* parameter), void* parameter, U32 initTime, ALARM_CLOCK_CMD_TYPE flag) { switch (flag) { case SET_ONESHOT: pxAlarmClock...
C
#include<stdio.h> #include<string.h> #include<sys/types.h> #include<fcntl.h> #include<sys/stat.h> int main (int argc , char *argv[]) { if (argc != 2 ) { printf ("./out fifoname\n"); return -1; } int fd =open(argv[1],O_RDONLY); char buf[1000]; int ret = read(fd,buf,sizeof(buf)); if (ret > 0) { printf ("%s"...
C
#include<stdio.h> #include<stdlib.h> /* Given an sorted array of size n. Find number of elements which are less than or equal to given element n -> 7 say arr -> 1 2 2 2 5 7 9 ele -> 2 initially : lr=0 and up=6 m=3 arr[3]<=2 is true : lr becomes 4 and m becomes 5 now arr[5] > 2 : thus up becomes 4 and m becomes 4 no...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "ArrayList.h" #include "Employee.h" int parserEmployee(FILE* pFile , ArrayList* pArrayListEmployee) { Employee* aux; char id[500],name[500],lastName[500],isEmpty[500]; fscanf(pFile, "%[^,],%[^,],%[^,],%[^\n]\n", id,name,lastName,isEmpty);...
C
#include<stdio.h> #include<unistd.h> #include "tests-my_put_nbr.h" int main(void) { my_put_nbr(42); my_put_nbr(0); my_put_nbr(-2147483648); return 0; }
C
/** * helpers.c * * Computer Science 50 * Problem Set 3 * * Helper functions for Problem Set 3. */ #include <cs50.h> #include "helpers.h" /** * Returns true if value is in array of n values, else false. */ bool search(int value, int values[], int n) { // array limits int beginPosition = 0; ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_putnbr_base.c :+: :+: :+: ...
C
/* * @Description: Knuth–Morris–Pratt algorithm * @version: 1.0 * @Author: Chandler Lu * @Date: 2019-10-06 22:59:43 * @LastEditTime: 2019-10-07 00:49:16 */ #include <stdio.h> #include <string.h> #define SIZE 20 int kmp(char *, char *); int main(int argc, char *argv[]) { char S[SIZE] = "ABABBAAABABABBA"; // ...
C
#include "dog.h" #include <stdlib.h> /** * free_dog - Entry point * @d: Struct dog * * Description: Free all componets of dog * Return: Nothing */ void free_dog(dog_t *d) { if (d) { if (d->name) free(d->name); if (d->owner) free(d->owner); } free(d); }
C
int main(){ int k,m,n,i,l,j,x,z,o,p,q,r,s; int a[20][20]; scanf("%d %d",&m,&n); for(i=0;i<m;i++) { for(j=0;j<n;j++) { scanf("%d",&(a[i][j])); } } if((a[0][0]>=a[0][1])&&(a[0][0]>=a[1][0])) printf("0 0\n"); for(i=1;i<n-1;i++) { if((a[0][i]>=a[0][i-1])&&(a[0][i]>=a[0][i+1])&&(a[0][i]>...
C
/*** BeginHeader */ #use LAB5_SYSTEM.LIB #use LAB5_UCOS.LIB #use LAB5_GPS_Custom.LIB /*** EndHeader */ /*** BeginHeader getRtcTime */ unsigned long getRtcTime(); /*** EndHeader */ unsigned long getRtcTime() { // read rtc in seconds from 1 Jan 1980 // The date and time can be accessed more quickly by reading...
C
#include "ir.h" IRPkg* IRPkgNew(Memory mem, const char* name) { size_t namelen = name == NULL ? 0 : (strlen(name) + 1); auto pkg = (IRPkg*)memalloc(mem, sizeof(IRPkg) + namelen); pkg->mem = mem; ArrayInitWithStorage(&pkg->funs, pkg->funsStorage, sizeof(pkg->funsStorage)/sizeof(void*)); if (name == NULL) ...
C
#include <stdio.h> double A,B,C,MEDIA; void main(void){ scanf("%lf", &A); scanf("%lf", &B); scanf("%lf", &C); while (A<0 || A>10.0 || B <0 || B>10.0 || C<0 || C>10.0){ system("cls"); scanf("%lf", &A); scanf("%lf", &B); scanf("%lf", &C);} MEDIA = (A*2+B*3+C*5) /10...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_memset_g.c :+: :+: :+: ...
C
#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> #include<stdlib.h> //Զstrlen static int mystrlen(char* str) { int count = 0; while (*str != '\0') { str++; count++; } return count; } //ַ static void reverse(char* start, char* end) { while (start < end) { char tmp = *start; *start = *end; *end = tmp...
C
#ifndef _DP_MALLOC_H #define _DP_MALLOC_H /** * dp_malloc.h */ /* support bool type */ #define bool int #define true 1 #define false 0 /** * Max region number, a region is associated with a heap memory chunk list, * at any time, on a cpu, can one region be opened. The kernel only open access * for a certain r...
C
/* Written by Tolga Mizrak 2016 Modification of sse_mathfun_test.c, written by Julien Pommier */ /* Results on a 3.30 GHz AMD FX-6100 Six-Core, compiled with Visual C++ Enterprise 2015 Update 3 (x64) command line: cl.exe /W4 /DUSE_SSE2 /EHsc- /MD /GS- /Gy /fp:fast /Ox /Oy- /GL /Oi /O2 sse_mathfun_test.c checking sine...
C
/* license: MIT * Originally written by https://github.com/h5p9sl * modified by Edward LEI <edward_lei72@hotmail.com> */ #include <stdio.h> #include <string.h> #include "memcpy_sse2.h" #include "sha256.h" #include "hmac_sha256.h" #define SIZEOFARRAY(x) sizeof(x) / sizeof(x[0]) #define SHA256_BLOCK_SIZE 64 static...
C
/***************************************************************************** * * Original Author: * Creation Date: * Description: * ****************************************************************************/ /***************************************************************************** * ...
C
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <sys/wait.h> int main(int argc, char *argv[]) { pid_t pid; int n, j, x; printf ("Kaç kere çalışacak:\n"); scanf ("%d",&j); printf("\n ID: %d\n",getpid()); n = atoi(argv[1]); if (argc == 1) { fprintf (std...
C
char* FindFile(void) { struct _finddata_t file; struct _finddata_t next; // ڵ intptr_t hFile = _findfirst("*.txt", &file); if (hFile == -1L) { return NULL; } else { next = file; //printf("nor rdo hid arc sub sys name time size\n"); do { FileSort(&next); // 111111 // 100000 /*pri...
C
#ifndef __SAMPLE_H #define __SAMPLE_H /** * @file sample.h * * @brief Fichier définissant quelques types, constantes utiles. * */ /* * Type definitions */ #ifdef FIXED_POINT /* to be defined */ #else /** * @brief Type de base du domain temporel */ typedef double sample_t; #endif /* * Includes */ ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* applying.c :+: :+: :+: ...
C
#include<stdio.h> #define N 10 int main(){ char name[N]; printf("What is your name?\n"); scanf("%s", name); printf("Hello, %s!\n", name); return 0; }
C
#include <stdio.h> #include <stdlib.h> #define pi 3.14 float cevreHesapla(float yaricap); float alanHesapla(float yaricap); float yaricap; int main () { printf("Lütfen Yarıcapı Giriniz:"); scanf("%f",&yaricap); printf("Dairenin Cevresi = %f",cevreHesapla(yaricap)); printf("\n"); printf("Daire...
C
#define _CRT_SECURE_NO_WARNINGS 1 #include"game.h" int full(char chessboard[ROW][COL],int row,int col) { int i = 0; int j = 0; for (i = 0; i < row; i++) { for (j = 0; j < col; j++) { if (chessboard[i][j] == ' ') return 0; } } return 1; } void initialize(char chessboard[ROW][COL],int row,int col)//ñ...
C
#include <stdio.h> void writeln(char letters[]) { int i = 0; while (letters[i] != '\0') { putchar(letters[i]); i++; } putchar('\n'); } void test1() { char arr[] = "abcdef"; char *ptr = "ghijklmnop"; writeln(arr); writeln(ptr); writeln("qrstuv"); } void stringCopy(char *fromStr, char *toStr) { f...
C
#ifndef __DATA_STRUCT_TYPEID_H__ #define __DATA_STRUCT_TYPEID_H__ #include <typeinfo> #include <string.h> #if 0 #undef CMP_TYPE #define CMP_TYPE(T,V) if(strcmp(typeid(T).name(), typeid(V).name()) == 0) #define APPEND_FMT \ CMP_TYPE(T,int8_t) \ { \ format.append("%d"); \ } \ else CMP_TYPE(T,u...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #ifndef tree_h #define tree_h struct tree { int item; struct tree *left; struct tree *right; }; typedef struct tree Tree; Tree *createEmptyTree(); Tree *createTree(int item, Tree *left, Tree *right); int isEmpty(Tree *tree); int ...
C
#include <stdio.h> int main() { int a = 100, b = 5, c = 2; float x, y = 1.0; x = y += (a >> 4) + b % c; printf("x=%f\n", x); return 0; }
C
#include <sys/time.h> #include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> double f(int n){ return pow(1.2, n);} int main(int argc, char const *argv[]) { struct timeval start, stop; gettimeofday(&start, 0); int x_i; double a=1; double b=20; long double n=atof(argv[1]); ...
C
/********************************* * * ʽ洢ṹ *********************************/ #include <stdio.h> #define ENDOF NULL typedef struct GNode* GList; struct GNode { int Tage;//־:0ʶڵǵԪ,1ʶڵǹ union { // ӱָSubList͵ԪDataڴ,ô洢ռ int Data; GList SubList; } URegion; GList Next; };
C
/* file: cell.c by: Stephen Cadiz login: scadiz27 date: 9/22/18 team: hammahs members: Sean Flynn, Micah Tumpap */ #include <stdio.h> /* This program calculates the cost of extra minutes for two cell phone plans Data should be redirected from a .dat file. Format: Minutes...
C
#include<stdio.h> int main() { int a[20],*b,i,j,k,m; b=&a[0]; printf("Enter the no."); //for(m=0;m!='\0';m++) scanf("%d",&a[m]); for(i=0;*(b+i)!='\0';i++); printf("%d",i); for(j=0;j<=(i-1);j++) { if(*(b+j)>*(b+j+1)) { k=*(b+j); *(b+j)=*(b+j+1); *(b+j+1)=k; } } //for(m=0;m!='\0';m++) //printf("%d",...
C
/*======================================================================== WSLRUN main.c Copyright (c)2017 Kevin Boone, GPL v3.0 ========================================================================*/ #define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <errno.h...
C
#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> #include<stdlib.h> #include<string.h> //ʹõ int factorial(int num) { int result = 1; while (num > 1) { result *= num;//numʼ num--; } return result; } int main() { int num = 0; printf("һ:>"); scanf("%d",&num); printf("%d\n",factorial(num)); system("pause...
C
/*--------------------------------------------------------------------- C- Function: ReadDataGroupE.c C- C- Purpose/ ReadDataGroupE is called at the start of the simulation C- Methods: to read Data Group E (environmental conditions) from C- the model input file. C- C- C- Inputs: Non...
C
#include<stdio.h> int main() { int t, tcount; long long int a, b; scanf(" %d", &t); for( tcount = 0; tcount < t ; tcount++) { scanf(" %lld %lld", &a, &b); if(a > b) printf(">\n"); else if(a == b) printf("=\n"); else ...
C
#include <stdio.h> #include <stdlib.h> /* Name : secret Description : Practical 9 Question 4 */ void main() { int num[30] = { -3,5,3,8,12,6,22,18,-9,15, -1, 25, 31, 0, 26, -6, 17, 1, 9, 10, 11, 24, -3, 4, -20, 19, 7, -17, 13, 14 }; /* //Question [4(a)] for (int j = 0; j <...
C
//////////////////////////////////////////////////////////////////////// // COMP2521 20T2 ... the Fury of Dracula // dracula.c: your "Fury of Dracula" Dracula AI // // 2014-07-01 v1.0 Team Dracula <cs2521@cse.unsw.edu.au> // 2017-12-01 v1.1 Team Dracula <cs2521@cse.unsw.edu.au> // 2018-12-31 v2.0 Team Dracula <cs2521@c...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> #include "teacher.h" void main() { int ch; printf("Enter the choice\n"); label1: printf("1. Student login \n2. Teacher login\n 3. Exit\n"); scanf("%d",&ch); if(ch==1) { student_main(); ...
C
#include <stdio.h> const int maxLen = 100; typedef float elemType; struct stack_container { elemType data[maxLen]; int top; }; void InitStack(struct stack_container *s); void Push(struct stack_container *s, elemType b); elemType Pop(struct stack_container *s); int main() { elemType b; ...
C
#include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <string.h> #include <unistd.h> #include <arpa/inet.h> int main() { int socket_fd; int length, ret_val; struct sockaddr_in dest_addr; char data[1024]; //建立套接字(容错) if ((socket_fd = socket(AF_INET, ...
C
//depends on time.h #include <time.h> int wait_millis(int min, int max){ struct timespec ts; int milliseconds= rand()%(max-min)+min; ts.tv_sec = milliseconds / 1000; ts.tv_nsec = (milliseconds % 1000) * 1000000; nanosleep(&ts, NULL); return 0; }
C
#include <stdlib.h> #include <string.h> #include <stdio.h> #include "shell.h" list_t *add_node_end(list_t **head, const char *str) { list_t *new_node, *st; st = *head; new_node = malloc(sizeof(list_t)); if (new_node == NULL) return (NULL); new_node->str = strdup(str); if (new_node->str == NULL) { free(ne...
C
/*******************************************************************/ /* To make it easy to add a new instruction, we define andr write */ /* all the codes about instructions in file "riscv_instruction.h" */ /* for definition, andr in file "riscv_instruction.c" for */ /* implementation. If you want to add ...
C
#include "uls.h" static bool errors_filename_comparator(void *data_1, void *data_2) { t_error *error_1 = (t_error *)data_1; t_error *error_2 = (t_error *)data_2; if (mx_strcmp(error_1->filename, error_2->filename) > 0) return true; return false; } void mx_sort_errors(t_list **errors) { t_...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* parser.c :+: :+: :+: ...
C
/* permute edge lists based upon symmetry operations */ #include <stdio.h> #include <ctype.h> #include "permute.h" main (argc, argv) int argc; char **argv; { char line[255]; int i; /* * read cases */ read_cases (argv[1]); /* * for each permutation operator, permute the cases */ while (...
C
#include "holberton.h" /** * *rot13 - check the code for Holberton School students. * @s : pointer * Return: Always 0. */ char *rot13(char *s) { char letras[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; char num[] = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm"; int i = 0; int j; ...
C
/*-------------------------------- ----------Sergeev Sergey---------- --------------------11-6---------- -----------------group B---------- --------------25.10.2016---------- --------------------------------*/ #include<stdio.h> #include<stdlib.h> #include"STR1.h" void main(void) { char *s, fname[1000] ...
C
#include <stdio.h> int asd(int n,int m); int main() { int a,b; char c; scanf("%d %c %d",&a,&c,&b); int i=asd(a,b); printf("%d/%d\n",a/i,b/i); return 0; } int asd(int n,int m) { int r=n%m; while(r) { n=m; m=r; r=n%m; } return m; }
C
#include "bc.h" #include "mt.h" #include <stdio.h> #include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <string.h> int *alph = NULL; void print_mem() { bc_box(1, 1, 61, 12); mt_gotoXY(30, 0); char tmp[] = " Memory "; write(1, tmp, sizeof(tmp)); for (int i = 0; i < 100; i++) { ...
C
#include <stdio.h> #include <inttypes.h> int main() { //position is 24.8 int32_t pos_fx=0; //cm int32_t time_fx = 0; //velocity is 8.8 int16_t vel_fx = 0; //cm/s //accel is 8.8 int16_t accel_fx = 32; //32/256 cm/s/s //dt = 8.8 int16_t dt_fx = 5; //5/256 s float pos=0, vel=0, ...
C
// // main.c // problem4 // // Created by Dcalsky on 15/11/12. // Copyright © 2015年 Dcalsky. All rights reserved. // #include <stdio.h> int main(int argc, const char * argv[]) { char fuckme; int total_num, total_char, nums[101], i, j, tmp1, tmp2; scanf("%d %d", &total_num, &total_char); for(i = 0;...
C
#include <stdio.h> #include <stdlib.h> #include <sys/mman.h> #include <sys/stat.h> #include <fcntl.h> #include <assert.h> #include <unistd.h> #define MAX_NAME_LEN 36 typedef struct __Record { unsigned int id; char name[MAX_NAME_LEN + 1]; }Record; int main() { Record rec; const char *file_path = ...
C
#include "libft.h" static int nb_len(int nb) { long n; int len; n = nb; len = 0; if (nb <= 0) { len++; n *= -1; } while (n >= 1) { len++; n /= 10; } return (len); } char *ft_itoa(int n) { char *str; long nb; int len; int fin; len = nb_len(n); nb = n; if (!(str = (char*)malloc(sizeof(ch...
C
#include <stdlib.h> #include <stdio.h> #include <dirent.h> #include <string.h> #include <math.h> #include <ctype.h> #include "fp_final.h" // user defined header file to calculate the percent void hashmod(long long hash1[],long long hash2[],int l1,int l2,long long max1,long long max2) { // hashmo...
C
/* ** EPITECH PROJECT, 2019 ** test_my_str_isalpha.c ** File description: ** unit test is_alpha */ #include <criterion/criterion.h> int my_str_isalpha(char const *str); Test(my_str_isalpha, case_no_char) { char str[] = ""; cr_assert_eq(my_str_isalpha(str), 1); } Test(my_str_isalpha, case_full_alpha) { ...
C
#include "mcal_adc.h" /******************************************************************************* * Function name : ADC_Init * Description : 1)Initializes the ADC Module in 12bit mode. Channel CH0 is * is used because only it can perform 12bit conversions. * ...
C
#include <stddef.h> // size_t typedef struct { void *value; int priority; } node; typedef struct { node *root; size_t size; /* You may want to allocate more space than strictly needed. */ size_t alloc_size; int heapified; } heap; // Initalize heap void heap_initialize(heap *); // Free memory and ...
C
#define NULL ((void*)0) typedef unsigned long size_t; // Customize by platform. typedef long intptr_t; typedef unsigned long uintptr_t; typedef long scalar_t__; // Either arithmetic or pointer type. /* By default, we understand bool (as a convenience). */ typedef int bool; #define false 0 #define true 1 /* Forward d...
C
#include "Exti.h" #include <stddef.h> #include "Exception.h" #include "STM32Error.h" void extiSetInterruptMaskRegister(ExtiRegs *extiLoc , int pin,RequestMasked mode){ if(extiLoc == NULL){ throwException(EXTI_REG_INPUT_NULL,"Exti register input is NULL"); } else if(pin > 22 || pin < 0 ){ throwException(E...
C
#include<stdio.h> #include<malloc.h> struct EV_myvals { int EV_val; int EV_acc; }; struct EV_myvals * factarth(struct EV_myvals * EV_var) { EV_var->EV_acc = (EV_var->EV_acc*EV_var->EV_val); EV_var->EV_val = (EV_var->EV_val-1); return EV_var; } int fact(int EV_var) { struct EV_myvals * EV_myvar; int EV_acc; EV_myvar = (...
C
/** * @file mnist-stats.c * @brief Utitlies for displaying processing details in the terminal * @author Matt Lind * @date July 2015 */ #include <string.h> #include "screen.h" #include "mnist-utils.h" #include "mnist-stats.h" /** * @details Outputs a 28x28 text frame at a defined screen position */ void display...
C
#include <stdio.h> #include <stdlib.h> #include "queue.h" QueueLink* Queuelink_init() { QueueLink* tmp = (QueueLink*)malloc(sizeof(QueueLink)*1); tmp->front = NULL; tmp->rear = NULL; return tmp; } //tmp마지막에 free void Queue_print(QueueLink* ql) { Queue* tmp = ql->front; while(tmp != NULL) { printf("all: %d\n",...
C
// // Created by 고승빈 on 2017. 10. 1.. // #include <stdio.h> #include <unistd.h> #include <stdlib.h> int main(int argc , char** argv) { char buf[100]; if(argc != 3) { fprintf(stderr , "Usage : ./symlink originfile linkfile\n"); exit(1); } if(symlink(argv[1] , argv[2]) == -1) { ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef unsigned char byte; typedef unsigned short u16; typedef unsigned int u32; typedef unsigned long long u64; typedef struct CipherCtx_s CipherCtx; struct CipherCtx_s { byte order[256]; byte order2[256]; u64 seed; }; void Cipher_UpdateChar(CipherCtx *c...