language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
/* * mixed_intersection.c * */ #include "mixed_intersection.h" #include "bitset_util.h" /* Compute the intersection of src_1 and src_2 and write the result to * dst. */ void array_bitset_container_intersection(const array_container_t *src_1, const bitset_container_t *src_...
C
#include "Task.h" #define SIZEOFTASK sizeof(task_t) #define CHECKPOINTER(PTR) {\ if(PTR == NULL) \ {\ return 0;\ }} struct task { task_id_t uid; task_func_t task_func; void *params; /* input data for task_func */ time_t interval_in_secs; /* time until next run, 0 if not recurring */ ...
C
#include<stdio.h> int main () { int n,a,sum,temp; printf("input a integer : "); scanf("%d",&n); printf("Before swapping : %d.\n",n); temp = n%10; int count = (int)log10(n);//No of digits //remove last digit & add first digit n = (n/10)*10 + n/pow(10,count); //remove first digit...
C
#include "CustomAssertions.h" #include "unity.h" void assertFile(char *Source, char *Target,int lineNumber) { long unsigned int srcFileSize, targetFileSize, position ; unsigned int srcData,targetData ,srcfileStatus = 0,targetFileStatus = 0; char ErrorMsg[1024] ={}; InStream *src = initInStream(); InStream *tar...
C
#include "../includes/ft_printf.h" static void ntoa_format_handle_hash(t_specifier *specifier, char *buf, size_t *buf_index, unsigned int base) { if (specifier->flags & FLAGS_HASH) { if (!(specifier->flags & FLAGS_PRECISION) && *buf_index && ((*buf_index == specifier->precision) || *buf_index == ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_convert_base.c :+: :+: :+: ...
C
// Find the maximum value in an array. // Created by // ... (z0000000) // ... (z0000000) // Created on 2017-08-?? // Tutor's name (dayHH-lab) #include <stdio.h> #include <stdlib.h> #define MAX_LENGTH 1024 int arrayMax (int size, int array[MAX_LENGTH]); // DO NOT CHANGE THIS MAIN FUNCTION int main (int argc, char ...
C
#include "include/header.h" int init(Cube* C) { memcpy(C->faces, "UUUURRRRFFFFDDDDLLLLBBBB", sizeof(char) * 24); C->last_move[0] = 'x'; C->last_move[1] = ' '; return 1; } int print_cube(Cube* C) { printf("\n"); printf(" %s@ %s@\n", color(C->faces[0]), color(C->faces[1])); printf(" %...
C
#include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> //#include <stdbool.h> typedef struct node_type { char *key; struct node_type *left, *right; }NodeT; /// create a node NodeT *createNode(char *givenKey) { NodeT *p = (NodeT*)malloc(sizeof(NodeT)); strrev(givenKey); if (p) ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> char *center(char *s, int n) { char *ret = (char *)malloc(n * sizeof(char)); int i, j; int slen = strlen(s); if (ret == NULL) { printf("Out of memory"); } for (i = 0; i < n; i++) { ret[i] = '-'; } for (j = 0; j <...
C
/* ** EPITECH PROJECT, 2018 ** my_strlen ** File description: ** the lenght of the string */ #include "my.h" int my_strlen(char *str) { int nb; nb = 0; while (str[nb] != '\0') nb++; return (nb); }
C
#include "holberton.h" /** * powX- powers a number b to the p's power * @b: base * @p: power * Return: return b to the power of a */ unsigned long int powX(int b, int p) { unsigned long int ans = 1; while (p) { ans *= b; p--; } return (ans); } /** * set_bit - prints the binary representation of a numb...
C
#include <stdlib.h> #include <stdio.h> #include <stdbool.h> #include <string.h> #include "computer.h" #define GENERAL_ERROR -1 /*void tnt_explode(?????) { }*/ /** * Checks if the current player taking turn is a automatic player. * @param game The game struct * @return either the current player if a automatic...
C
#include<stdio.h> #include<malloc.h> #include<stdlib.h> int findmedian(int *,int *,int); int median(int *,int); int max(int,int); int min(int,int); int * malloc_int(int *,int); int a_cmp(int,int); void testcases(); struct test { int input1[20]; int n1; int input2[20]; int n2; int output; }testDB[10]={{{1,2...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* builtin_exit.c :+: :+: :+: ...
C
int i, j; void main() { i = 8; j = 0; do { j++; i--; if (i % 2 == 0) continue; j++; if (i == 1) break; } while (i!=10); assert(i == 1, "i must be 1"); assert(j == 11, "j must be 11"); }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char *argv[]) { /*init strings for input and output names*/ char* inputName; char* outputName; /*init of other variables*/ int numStates; if (argc==3) /*both input name and output name provided*/ { inpu...
C
#include <string.h> #include <ctype.h> #include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> /* User created libraries */ #include "accounts.h" #include "server.h" #define WITHDRAW "withdraw\0" #define DEPOSIT "deposit\...
C
#include "helpers.h" #include <stdio.h> #include <math.h> // Convert image to grayscale int sepiablue(int blue, int green, int red); int sepiagreen(int blue, int green, int red); int sepiared(int blue, int green, int red); int avg(int blue, int green, int red); //void swap (void *f, void *l); void grayscale(int height...
C
#include <stdio.h> #include <string.h> #include <errno.h> #include <stdlib.h> #include <sys/socket.h> #include <arpa/inet.h> #include <unistd.h> #include <netdb.h> #include "common.h" #include "client.h" void error( char *s ) { fprintf( stderr, "%s : %s", s, strerror( errno ) ); exit(1); } int open_socket( c...
C
/** @file stk_sequence.h * This header provides the typedefs and definitions required to interface * to the Sequence module APIs */ #ifndef STK_SEQUENCE_H #define STK_SEQUENCE_H #include "stk_common.h" /** * \typedef stk_sequence_id * A Sequence ID is a 64 bit unsigned number. * \see stk_acquire_sequence_id() a...
C
#include <stdlib.h> #include <stdio.h> #include <time.h> #include "random.h" #include <time.h> //1.2.a double random_double(double a, double b){ return (double) ((b - a) * (rand() / (RAND_MAX + 1.0)) + a); } //1.2.b float random_float(float a, float b){ return (float) ((b - a) * (rand() / (RAND_M...
C
#include <SimpleModbusMaster_DUE.h> //////////////////// Port information /////////////////// // interval at which to blink (milliseconds) ////////////////////modbus//////////// #define baud 115200 #define timout 50 #define polling 200 // скорость опроса по модбус #define retry_count 10 #define TxEn...
C
#include "common_local.h" void arr_transposition(int *arr, int row, int col) { int i, j; int *trans_arr; trans_arr = (int *)malloc(col * row * sizeof(int)); for(i = 0; i < row; ++i) { for(j = 0; j < col; ++j) { trans_arr[j * col + i] = arr[i * row + j]; } } for(i = 0; i < col; ++i) { for(j = 0; j < ro...
C
/* * ex_4-12_recursive_itoa.c -- Ex KnR book * * Adapt the ideas of printd to write a recursive version of itoa; * that is, convert an integer into a string by calling a recursive routine. * * Written by Harold André * E-mail <harold.andre@gmx.fr> * * Started on Sat Oct 26 12:47:50 2013 Harold André * ...
C
#include <stdio.h> #include "main.h" #include "string.h" /** * _memcpy - Copies the first @n bytes of the memory area * pointed to by @src into the memory area pointed to by @dest. * @dest: A pointer to the memory area to be filled. * @src: A pointer to the memory area to be copied. * @n: The number of by...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_printf.c :+: :+: :+: ...
C
#include<stdio.h> #include<stdlib.h> void matrizIdentidade(int M[][5], int l); void imprimeMatriz(int M[][5], int l); main(){ int Matriz[5][5]; matrizIdentidade(Matriz, 5); imprimeMatriz(Matriz,5); system("pause"); } void imprimeMatriz(int M[][5], int l){ int i, j; for(i=0; i<l; i++){ for(j=0; j<5; j++)...
C
#include<stdio.h> #include<unistd.h> #include<stdlib.h> struct process { int pid,bt,wt,tat,pri; }; int main() { int n,i,n1=0,n2=0,n3=0,p=1,q=1,r=1; int total_waiting_time=0,total_tat=0,quant=4,quantRR=10 ; int c1=0,c2=0,c3=0,t=0; // for waiting times. int Rembt[3]; printf("\t\t\t==========...
C
#include<stm32f4xx.h> int inA,inB; int main(void) { RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); //Enable Peripheral clock for GPIOA GPIO_InitTypeDef GPIO_InitStructure; // Structure definition GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; // Enable GPIO Pin 5 (of GPIOA) GPIO_InitStructure.GPIO_Mod...
C
#include "log.h" #include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include <time.h> #include <string.h> void loge(const char *format, ...) { FILE *f; va_list ap; char out[512]; time_t t = time(NULL); struct tm tm = {0}; char *after_date = &out[21]; tm = *localtime(&t); strftime(out, 22, "...
C
#include <stdio.h> #include <stdlib.h> // TODO: define add, sub, mul, divi as functions which take two integer arguments and return the result // we can't use "div" because it is already defined int add(int a, int b) { return a + b; } int sub(int a, int b) { return a - b; } int mul(int a, int b) { retur...
C
/* * led.c * * Created on: 2014年10月18日 * Author: daniel */ #include "led.h" #include <string.h> // 初始化所有LED引脚 BaseType_t InitLED( void ) { BaseType_t ret = pdTRUE; GPIO_InitTypeDef GPIO_InitStructure; // Enable GPIO Peripheral clock RCC_APB2PeriphClockCmd(LED_INTERNAL_GPIO_CLK | ...
C
#include "producent.h" void error(const char *msg) { perror(msg); exit(1); } void cbInit(circ_buffer_t *cb, size_t capacity, size_t sz) { cb->buffer=malloc(capacity*sz); if(cb->buffer==NULL) error("cb_init: malloc error"); cb->buffer_end=(char*)cb->buffer+capacity*sz; cb->capacity=capacity; cb->count=0; cb-...
C
/* ** EPITECH PROJECT, 2018 ** lemin ** File description: ** find shortest path */ #include "lemin.h" static void verify_tunnel(l_list_t **list, room_t *data, l_list_t *next) { void *tmp; tmp = initialize_list(data, next); if (!tmp) return; push(list, tmp); data->marked = true; } static void add_other_tunnel...
C
#include<stdio.h> #include<conio.h> #include<string.h> #include<stdlib.h> union hospital { char names[10][8],choice,pass,hos_type,name[20],sname[20],stype[20],locat[20],dest[20],member[20]; int limit,age; long int contact,contact_num,count; }; int main() { union hospital hos; int i,n,j,max=1; prin...
C
#include<stdio.h> #include<string.h> int main (void) { //Declaração de variaveis char texto1[80], texto2[80]; int r, letraT1, letraT2, a; //Completar as strings printf("Texto1: "); scanf("%s", texto1); printf("Texto2: "); scanf("%s", texto2); //Comparar Textos for( r = 0; a == 0; r++) { letraT1 = te...
C
#include "../debug/debug.h" #include "cmd.h" #include <errno.h> #include <fcntl.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/statvfs.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> bool do_cmd(cmd *c) { if (!c) DEBUG_PRINT("cmd was null\n");...
C
#include<stdio.h> #define pi 3.14 int main() { float r,pi,area; printf("Enter the Radius: "); scanf("%f",&r); area=pi*r*r; printf("Area of the circle is %f",area); return 0; } //now run
C
#include "types.h" #include "stat.h" #include "user.h" int main(int argc, char *argv[]) { printf(1,"Freepages at start: %d\n",freepages()); char* buf = malloc(10000000); memset(buf,0,10000000); printf(1,"Freepages after malloc: %d\n",freepages()); dedup(); printf(1,"Freepages after dedup: %d\n",freepages()...
C
#include "lua.h" #include "lauxlib.h" #include <stdio.h> #include <stdlib.h> typedef struct { int x; int y; } lua_point; lua_point* lua_point_create(int x, int y) { lua_point* output = NULL; output = malloc(sizeof(lua_point)); if (output) { output->x = x; output->y = y; }...
C
#include<stdio.h> #include<conio.h> void main() { int arr1[50],arr2[50],arr3[100],m,n,i,j,k=0; printf("enter the no of elements1:\n"); scanf("%d",&m); printf("enter the elements\n"); for(i=0;i<m;i++) { scanf("%d",&arr1[i]); } printf("enter the no of elements 2:\n"); scanf("%d",&n); printf("enter the eleme...
C
#include <stdio.h> #include <unistd.h> #include <signal.h> #include <stdlib.h> #include <string.h> void handler(int sig); void handler2(int sig); void handler(int sig) { printf("Caught signal %s\n", strsignal(sig)); signal(sig, SIG_DFL); if (sig == SIGTSTP) signal(SIGCONT, handler); else if (sig == SIGCONT) signa...
C
#include "binary_tree.h" int main() { struct node *root_node = NULL; root_node = insert(root_node,5,NULL); root_node = delete_node(root_node,5); root_node = insert(root_node,7,NULL); root_node = insert(root_node,3,NULL); root_node = insert(root_node,6,NULL); root_node = insert(root_node,9,...
C
/* ** EPITECH PROJECT, 2019 ** PSU_navy_2018 ** File description: ** fill an empty map with ships thanks to positions */ #include "./../include/navy.h" char **fill_the_map_with_pos(char **map, char **pos) { int i = 0; char **ship = NULL; while (map != NULL && pos[i] != NULL) { ship = my_str...
C
/* * errors.h * * Created on: 3 févr. 2018 * Author: jerome */ #ifndef ERRORS_H_ #define ERRORS_H_ #include "stdio.h" #include <stdlib.h> #define ERROR(file,line,info) ({char s[100]; sprintf(s,"ERROR %s:%d - %s\n",file, line, info); printf(s);;exit(1);}) #define ASSERT(cond,file,line) ({if ( (cond) == fal...
C
#define PI 3.14159 float area(float); void main(void) { float radius; printf("Enter Radius Of Sphere"); scanf("%f",&radius); printf("Area Of Sphere Is %2f",area(radius)); } float area(float rad) { return(PI*rad*rad); }
C
#ifndef MATH_H_INCLUDED #define MATH_H_INCLUDED const float PI = 3.14159265359f; inline float degToRad(float deg) { return float((deg * PI) / 180); } inline float radToDeg(float rad) { return float((rad * 180 ) / PI); } inline float lerp(float a, float b, float t) { return a + t * (b - a); } #endif ...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <sys/socket.h> #include <arpa/inet.h> #include <sys/ioctl.h> #include <unistd.h> #include <errno.h> #include <netdb.h> int i = 0; int send_image(int socket, char *imagen) { /** * Esta función se encarga de enviar toda la información de la image...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* edit_link_sectors.c :+: :+: :+: ...
C
#include <stdio.h> #define len 1000 int stackA[len],stackB[len],stackC[len]; int topA=0,topB=0,topC=0; void Push(int *stack,int val,int *top) { if(*top>=len) printf("STACK OVERFLOW\n"); else { stack[*top]=val; (*top)++; } } int Pop(int *stack, int *top) { if(*top<0) printf("EMPTY STACK! No...
C
/* Projet : ELE216 - Laboratoire 1 Date : 21 janvier 2021 Par : Gabriel Gandubert et Hugo Cusson-Bouthillier Logiciel : Sublime text & Eclipse Definition : Encapsulation des criteres de recherche pour la base de donnee de films Contient: Structure des criteres qu...
C
#include "holberton.h" #include <stdio.h> /** * puts_half - Entry point * @str: one * Return: Always 0 (Success) */ void puts_half(char *str) { int contador, par, impar; for (contador = 0 ; str[contador] != '\0' ; contador++) { } if (contador % 2 == 0) { for (par = contador / 2 ; par < contador ; par++) ...
C
#include <stdio.h> #include <stdlib.h> int ans[100005]; typedef struct NODE { int v; struct NODE *next; } Node; Node *e[100005]; Node *end[100005]; void dfs(int x) { Node *now = e[x]; ans[x] = 1; while (now != NULL) { const int v = now->v; if (ans[v] == 0) dfs(v); ...
C
#ifndef __TOBIE_IMAGE_H__ #define __TOBIE_IMAGE_H__ /** * timage_comp 与 timage_crop返回的错误号 * 请定义更多错误类型 */ typedef enum { TIAMGE_OK = 0, TIAMGE_UNKNOWN_IMAGE_TYPE } timage_error_code_e; /** * 公用数据结构 * # position * # rectangle * # buffer */ typedef struct { int x; int y; } timage_position_t; typedef struct ...
C
#include <glib.h> #include <stdio.h> #include "handle_device.h" #define NB_OF_DEVICES 2 /* The problem to solve is following: You monitor devices, which are sending data to you. Each device have a unique name. Each device produces measurements. Challange is: ...
C
/* ** EPITECH PROJECT, 2018 ** my_malloc ** File description: ** show_alloc_mem.c */ #include <unistd.h> #include "my_malloc.h" int print_address_in_hexa(unsigned long long int ptr) { my_putnbr(ptr); return 0; unsigned long nbr2; char nbrc; int size = 0; if ((ptr / 16) != 0) size = print_address_in_hexa(ptr ...
C
#include"list.h" #include<stdlib.h> #include<stdio.h> List * newList(){ List * list = malloc(sizeof(List)); list->head = NULL; list->tail = NULL; list->index = 0; list->insert = insertList; list->read = readData; list->remove = removeData; list->delete = delete; return list; } void insertList(List * list, i...
C
#include<stdio.h> main() { int num,z; int res=0; printf("enter number "); scanf("%d",&num); int x=num; while (num>0) { z=num%10; res=res+z; num=num/10; } printf("sum of digits of %d is %d\n",x,res); }
C
#include <stdio.h> int main(void) { int dan = 0, num = 1; printf("몇 단? : "); scanf_s("%d", &dan); while (num < 10) { printf("%d X %d = %d\n", dan, num, dan*num); num++; } return 0; } /* while (1) printf("%d X %d = %d \n", dan, num, dan*num); num++; 숫자 1은 '참'을 의미하는 대표적인 값이다. 따라서 이 값이 반복의 조건을 대신하면, 그 ...
C
数据结构课程设计——哈夫曼加密解密算法2008年10月13日 14:56课程描述:对于存储在磁盘上的ASCII格式文件(汉字不能识别),根据字符出现的频率作为字符权值,利用Huffman算法进行处理,形成Huffman树,得到Huffman码,利用Huffman码对字符进行加密,已二进制的形式存储到磁盘。 再利用Huffman码对加密后的文件解密。 #include<stdio.h> typedef struct LNode{ /*-------------链表-------------------*/ int data; str...
C
#define NATIVE_MODULE "$math" #include <math.h> #include "ext_math.h" #include "list.h" module_t ext_math_module = {false, NULL, false, NULL}; static bool check_one_vector(cList *l1, Int *len_ret) { Int i,len; len=list_length(l1); for (i=0; i<len; i++) { if (list_elem(l1,i)->type != FLOAT) { ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <pthread.h> #include <fcntl.h> #include <sys/stat.h> #define BUF_SIZE 1000 #define MAX_CLT 256 void* ThreadMain(void* args); void* Handl...
C
#include "holberton.h" /** * append_text_to_file - Appends text_content to an existing file. * @filename: Name of the file. * @text_content: The content to be written to the file. * Return: 1 if success. -1 if non-existent file or filename, couldn't open or * write the contents to the file. */ int append_text_to_...
C
#include <stdio.h> int main(void) { int number = 0b110010; printf("Number in decimal: %d\n", number); printf("Number in hex: %x\n", number); printf("Number in octal: %o\n", number); return 0; }
C
//getch et putc pour cacher le mot de passe #include<stdio.h> #include<string.h> #include<time.h> #include<stdlib.h> #define F fflush(stdin); const char nomCat[]= "CATEGORIES"; const char nomProd[] = "PRODUCTS"; const char nomSupp[] = "change"; const char nomUser[] = "USERS"; int id_auto = 0; int id_cat = 0; int id_ven...
C
/* ** t_listString_remove.c for lib in /home/flavian.gontier/projects/libmy/src/list/t_listString ** ** Made by flavian gontier ** Login <flavian.gontier@epitech.net> ** ** Started on Fri Jan 27 01:22:50 2017 flavian gontier ** Last update Sun Apr 09 13:49:01 2017 flavian gontier */ #include "libmy.h" static voi...
C
/* ** EPITECH PROJECT, 2020 ** CPE_dante_2019 ** File description: ** prism_generator */ #include <stdlib.h> #include <stdio.h> #include <stddef.h> #include "dante.h" #include "my.h" int is_cell_visited(list_t *wall, char **maze, int x, int y) { int x_visited = 0; int y_visited = 0; if (x != wall->width_...
C
#include <pthread.h> #include <sys/types.h> #include <stddef.h> #include <syscalls.h> /* For printf. REMOVE WHEN ALL IMPLEMENTED */ #include <stdio.h> #define UNIMPL printf(__func__) int pthread_attr_init(pthread_attr_t* attr) { attr->detachstate=PTHREAD_CREATE_JOINABLE; attr->scope = PTHREAD_SCOPE_SYSTEM; retur...
C
#include <stdio.h> #include <stdlib.h> #include "ArrayList.h" #include "NameCard.h" int main() { List list; NameCard* pcard; // NameCard 구조체 형으로 포인터pcard을 선언한다. ListInit(&list); // list를 초기화 셋팅한다. pcard = MakeNameCard("이진수", "010-1111-2222"); // pcard 구조체에 MakeNameCard함수로 이름과 전화번호를 저장하였다 LInsert(&list, p...
C
#include <stdio.h> #include <stdlib.h> int main(int argc, char const *argv[]){ int data[] = {4,32,53,23,17,53,86,32,12,31}; int N = sizeof(data)/sizeof(data[0]); int i, j, temp; for ( i = 0; i < N - 1; i ++ ){ for ( j = i + 1; j < N; j ++ ){ if( data[ i ] > data[ j ] ) { temp = data[ i ]; data[...
C
// De bai: kiem tra xem trong mang co gia ri chan nho hon 2019 khong #include<stdio.h> #include<conio.h> main() { int n,MAX,i,imax; printf(" Nhap so phan tu cua tap hop = "); scanf("%i",&n); int array[n]; for(i=0;i<n;i++) { printf(" Nhap phan tu thu %i = ",i+1); scanf("%i",&array[i]); if(array[...
C
#include <u.h> #include <mem/mem.h> #include <ds/ds.h> #include "cc.h" static void ungetch(Lexer *l, int c); static int nextc(Lexer *l); char * tokktostr(Tokkind t) { switch(t) { case TOKIDENT: return "ident"; case TOKNUM: return "number"; case TOKIF: return "if"; case TOKELSE: return ...
C
/************************************** * pthread-philo2.c * * Programme d'exemple de pthread avec * philosophes qui dinent et mutex * **************************************/ #include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <unistd.h> #include <errno.h> #include <string.h...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <netinet/in.h> #include <arpa/inet.h> #include <linux/input.h> #include <fcntl.h> #include <string.h> #include <errno.h> #include <limits.h> #define RB_SIZE 1000 int listen_fd; struct client { struct client *next; struct client *prev; int fd; st...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/wait.h> int main(int argc, char **argv) { // Creation du processus fils pid_t pid = fork(); // Verification de la creation du processus fils if (pid < 0) { printf("Erreur : Le fils n'a pas été cree\n"); return...
C
#include <stdio.h> // calcola il numero di bit 1 nella rappresentazione in binario di n // questa funzione deve essese ricorsiva int count1(int n) { // si dia per scontato che n >= 0 // DA COMPLETARE: QUESTA FUNZIONE DEVE ESSERE RICORSIVA } int main(void) { // DA COMPLETARE: // 1) legge da tastiera un intero ...
C
int centreOfMass(double * V, size_t M, size_t N, size_t P, double * com) { /* Centre of Mass of volumetric image V of size MxNxP V should be pre-processed for beads, an erf-threshold between min and max is probably a good option. */ // Reset, just to be sure... com[0] = 0; com[1] = 0; com[2] = 0; for(size_t xx...
C
/* A C program that will find its way through a maze using the depth-first search algorithm. This program takes input from a file where the filename is specified in the command line arguments. The input file will only contain two integer values per line of input: • The first valid line gives the size of the 2-D maze ...
C
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include "matrix.h" //hw: work on inputNumbers and use strtok() /* We will examine the vector, matrix, and table structures using vanilla C doing this will help learning the following concepts: 1) memory management 2) input, output 3) vector, matrix, and t...
C
#include <signal.h> #include <stdlib.h> #include <unistd.h> #include <stdio.h> void catch_sighup(int signal) { printf("signal : %d\n", signal); printf("prosper youpla boum! c'est le roid u pain dépice!\n"); } int main(void) { printf("pid : %d\n", getpid()); while (1) signal(SIGHUP, catch_sighup); return ...
C
#include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <pthread.h> void funct(int n) { printf("%d\n",n); pthread_exit(NULL); } int main() { int n = 100; pthread_t * p = malloc(sizeof(pthread_t) * n); for (int i = 0; i < n; ++i) { pthread_create(&p[i...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_realloc_tab.c :+: :+: :+: ...
C
/* xsh_ls.c - xsh_ls */ #include <xinu.h> #include <stdio.h> /*------------------------------------------------------------------------ * xhs_ls - list the contents of the local file system directory *------------------------------------------------------------------------ */ shellcmd xsh_ls(int nargs, char *args[...
C
#include <stdio.h> #include <stdlib.h> #define MAX 50 typedef struct Node *Node_pt; typedef struct Node{ Node_pt link; int vtx; } Node; char matrix[MAX][MAX]; char new_matrix[MAX][MAX]; Node_pt list[MAX]; Node_pt new_list[MAX]; int order[MAX]; int discovery_t[MAX]; int finish_t[MAX]; int time = 1; void dfs(int...
C
#include <stdio.h> #include <stdbool.h> bool is_valid_triangle(float a, float b, float c) { return (a + b + c == 180.0); } int main() { float a, b, c; printf("Enter the three angles separated by commas and spaces > "); scanf("%f, %f, %f", &a, &b, &c); printf("%s\n", is_valid_triangle(a, b, c) ? "...
C
#include "login.h" bool doLogin(char *senha){ if(memcmp(senha,SENHA,strlen(senha))!=0) return false; return true; }
C
/*--------------------------------------------------------------*/ /* */ /* execute_road_construction_event */ /* */ /* execute_road_construction_event.c - creates a patch object */ /* */ /* NAME */ /* execute_road_construction_event.c - creates ...
C
// // AVLtree.c // AVL_Tree // // Created by Trang Nguyen on 3/12/17. // Copyright © 2017 Trang Nguyen. All rights reserved. // #include "AVLtree.h" int Height (AVLNode *root){ if (!root) return -1; else return root->height; } int Max (int a, int b) { if (a > b) { return a; } else { ...
C
#include<stdio.h> #include<string.h> #include<stdlib.h> int printCaps(char data) { if (data >= 'a' && data <= 'z') { return (int) data - 32; } else { return (int) data; } } int main(int argc, char* argv[]) { char name[20]; printf("Please enter a name\n"); //scanf("%c", &name); gets(name); if ((name[0] >=...
C
#include<stdio.h> #include<ctype.h> #define size 50 int top=-1; int stack[50]; int isempty(){ if(top==-1) return 1; else return 0; } int isfull(){ if(top==size-1) return 1; else return 0; } void push(int x){ if(isfull()) printf("Stack overflow\n"); else{ top++; stack[top]=x; ...
C
#ifndef _rle_ #define _rle_ // natty dread powered * void * RLE(void * bufSrc, uint *bufSize) { char *bufDst, *sBufPtr, *dBufPtr ; char value ; uint dBufASize, dBufSizeRemain ; long totalCount = *bufSize ; // asign control var with src buf size. uchar repeat ; void *rleBf ; dBufASize = dB...
C
#include "uart.h" #include <string.h> bool uartIsInit = _FALSE; void uartInit(void) { if (uartIsInit) { return; } SIM->SCGC |= SIM_SCGC_UART1_MASK; UART_MODULE->C1 = 0x00; UART_MODULE->C2 = UART_C2_TE_MASK | UART_C2_RE_MASK; // Transmit and receive UART_MODULE->BDH = UART_BDH_SBR(0); UART_MODULE->BDL ...
C
#include <stdio.h> char lower(const char c) { return c >= 'A' && c <= 'Z' ? c + 'a' - 'A' : c; } main() { char s[] = "CAPITAL"; for (int i = 0; s[i] != '\0'; ++i) s[i] = lower(s[i]); printf("%s\n", s); }
C
#define _XOPEN_SOURCE 500 // FTW flags #include <stdio.h> #include <stdlib.h> #include <malloc.h> // malloc functions #include <dirent.h> // dirent structure #include <sys/stat.h> // mkdir #include <errno.h> // to know which errors are raised #include <string.h> // string functions #include <ftw.h> //nftw dir ...
C
#include<stdio.h> #include<math.h> int main() { int x,y; int sonuc; printf("X uzeri y icin x ve y degerlerini giriniz:"); scanf("%d%d",&x,&y); sonuc=pow(x,y); printf("%d uzeri %d = %d",x,y,sonuc); g...
C
// // security.c // // // Created by Nguyen Trung Huan on 26/3/18. // #define BUFFER_LENGTH 100 #include <stdio.h> int main() { char guessedDateStr[BUFFER_LENGTH]; // to input string char guessedKeyStr[BUFFER_LENGTH]; // to input key int date; int key; // Preamble printf("I hope you are not ...
C
#include <stdio.h> #include <stdlib.h> #include <errno.h> #include <pthread.h> #include <string.h> #include <videoBuffer.h> pthread_mutex_t videoListLock; void initVideoList(videoList *list) { list->head = NULL; list->tail = NULL; list->length = 0; } void clearVideoList(videoList *list) { videoBuffer *p ...
C
#include <math.h> #include <stdint.h> #include <stdio.h> #include "geometry.h" #include "image.h" #include "luminance_probe.h" #include "multi_probe_least_squares.h" typedef struct { vec2_iterator_t parent; image_t *image; ls_probe_func_t probe; vec2_t *centers; unsigned samples; ...
C
#include<stdio.h> #define person 10 void main() { static int overtime[person]; int i,workinghour; for(i=0;i<person;i++) { printf("Enter the %d Working Hour :: ",(i+1)); scanf("%d",&workinghour); if(workinghour>40) overtime[i]=(workinghour-40)*12; printf("Overtime income for %d is RS. %d\n\n"...