language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> #include <stdlib.h> #include "linked_list.h" /* constructs an empty list */ List *list_init() { List *list = (List *)malloc(sizeof(List)); Node *dummy_head = (Node *)malloc(sizeof(Node)); Node *dummy_tail = (Node *)malloc(sizeof(Node)); dummy_head->next = dummy_tail; dummy_tail-...
C
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <pthread.h> #define THREAD_NUMBER 10 pthread_mutex_t mutex; pthread_cond_t cond; int running[THREAD_NUMBER] = {0}; int check_conflict(void); void *thread_proc(void *arg); int main(int argc, char *argv[]) { int ret, i; pthread_t thread[THREAD_NUMB...
C
#include "hash.h" #include <stdio.h> #include <stdlib.h> /* This program reads first argument as file and outputs the sha1 * sum on EOF. It does this twice on the same file to show how to * reuse the hash context. */ #define UPDATE_PAYLOAD_SIZE 8192 int main(int argc, char *argv[]) { if (argc == 1) { abort()...
C
/* Hello World! Hello World! 1 13 */ #include <stdio.h> int main (){ int a, b; a = fputs("Hello World!\n", stdout); b = puts("Hello World!"); printf("%d %d\n", a, b); return 0; }
C
#include<stdio.h> #include<stdlib.h> #include<time.h> #include<conio.h> //Funo TIME char jogador1; char jogador2; char linha1[10]; char linha2[10]; char linha3[10]; char tecla; void dorme(int t){ int inicio=clock(); int agora, dif=0; while(dif<t){ agora=clock(); dif=1000*...
C
#include "product.h" int addProduct(Product *s){ int i =0; float j =0; getchar(); printf("\nEnter product name : "); fgets(s->name,20, stdin); for(int i=0;i<20;i++){ if(s->name[i]=='\n'){ s->name[i]='\0'; break; } } printf("Enter product weight : "); scanf("%d", &s->weight); printf("Enter...
C
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include "AVL.h" int main(){ int escolha, x, y=0; no *T; system("cls"); puts("Arvore AVL"); system("pause"); system("cls"); puts("Inicializar a Arvore?"); puts("1.sim"); scanf("%d", &escolha); if(escolha==1){ ...
C
#include <stdio.h> #include <stdlib.h> int ex4(void) { int x, y, c, d; int a = 45, b = 55; printf("ï]ƶq:"); scanf("%d", &x); printf("Qsƶq:"); scanf("%d", &y); c = x + y; d = (a*x) + (b*y); if (c > 15) { if (d >= 800) printf("ɦ9ufA:%d \n", d * 9 / 10); else printf(":%d \n", d); } else printf(":%d...
C
#include <stdio.h> #include <stdarg.h> static void foo(char *fmt, ...) { va_list ap; int d; char c, *s; va_start(ap, fmt); char buf[128] = {0}; snprintf(buf, sizeof(buf), "The buffer is %s\n", fmt); vprintf(buf, ap); va_end(ap); // while (*fmt) { // switc...
C
/*Programme réaliser par Aladin SALEH & Paul MINGUET **06/02/21 **IUT Sénart Fontainebleau - Année 2 */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/msg.h> #include <sys/shm.h> #include <assert.h> #include <sys/types.h> #include <sys/wait.h> #incl...
C
/* * mymalloc.c * * Created on: Feb 12, 2019 * Author: FahadMirza */ #include <stdio.h> #include <stdint.h> #include <stdbool.h> #define HEAP_SIZE (256U) static uint8_t heap_space[HEAP_SIZE + 1]; static uint8_t *topOfHeap = heap_space; static int availableHeapSize = HEAP_SIZE; typedef struct sBlockMeta {...
C
/* * RepositoryHandler.h * * Created on: Jul 21, 2015 * Author: suryaveer */ /* This function will insert the resource in the repository. Input Parameters: db_key_t* _k: List of Columns. db_val_t* _v: List of Values int _n total: number of values char _rt: Type of resource (Presentity/Subscriber/ etc) c...
C
#include <stdlib.h> #include <stdio.h> #include "mvm.h" #include "unittest.h" static TInst inst; static bool test_mvm_byte_size(TTestContext* ctx) { return assertEqualInt(1, sizeof(mvm_byte), ctx, "mvm_byte size"); } static bool test_mvm_half_size(TTestContext* ctx) { return assertEqualInt(2, sizeof(mvm_ha...
C
#include <stdio.h> void main(){ int data1 = 5, data2 = 3; int result1 = data1 > 7; int result2 = data2 <=data1; int result3 = data2 == 7; int result4 = data2 != data1; printf("result : %d, %d, %d, %d\n", result1, result2, result3, result4); }
C
#include <sys/types.h> #include <unistd.h> #include <stdint.h> #include <stdio.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/mman.h> int main(void) { uint64_t fileSz = 7281; uint64_t i = 0; /* printf("Enter the size of file: "); scanf("%llu", &fileSz); */ int fd = open("arc.txt", O_RD...
C
/* ** NAME ** isnobal -- run snowmelt model over a set of images ** ** SYNOPSIS ** #include "pgm.h" ** ** void ** isnobal( ** int out_step) |* # of data tsteps per output img *| ** ** DESCRIPTION ** isnobal reads all input files, performs calculations and writes output ** images for 2-layer energy-...
C
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include "deviceLibrary.h" #include "ArduinoDriverLibrary.h" #define BUFFER_LENGTH 256 /* processMoveDevice: this method call the device driver, it sends nextMove: 1 if the move is touch, 2 if the move is push, 3 if the move is drag, pos...
C
#include <stdio.h> int eh_primo(int n){ int i; for(i=2;i<n;i++){ if(n%i==0){ return 0; } } return 1; } int main(void){ int n; int bol; printf("digite um numero "); scanf("%d",&n); bol = eh_primo(n); if(bol==0){ printf("nao eh primo\n"); } else{ printf("eh primo\n"); } ret...
C
// // main.c // OSLab1 // // Created by Алексей Агеев on 08.10.2020. // #include <stdio.h> #include <stdlib.h> #include <memory.h> #include <unistd.h> #include <sys/fcntl.h> #include <pthread.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/mman.h> #include <string.h> #include <errno.h> #include <sys/f...
C
#include "bigz.h" /* * Unsigned multiplication. Returns |a * b| */ bigz * bigz_umul(bigz * a, bigz * b) { int i, j; unsigned int sum_carry, carry, mul_carry; unsigned int tmp, c0, c1, c2, c3; /* storage for partial products */ bigz *prod; if (a->size < b->size) { prod = a; a =...
C
#include <stdio.h> #include <math.h> int main() { double x, y, delta, del; double a, b, c; printf("insert ax²+bx+c :"); scanf("%lf %lf %lf", &a, &b, &c); delta = (b)*(b) - (4*((a)*(c))); printf("%lf \n", delta); if (delta > 0 && a!= 0){ del = sqrt (delta); printf("%lf", del); ...
C
#include <stdio.h> int main() { int day,x1,x2; day=0; x1=1020; while (x2>=0) { x2=x1-(0.5*x1+2); x1=x2; day++; } printf("day=%d\n",day-1); return 0;}
C
/* ** main.c for in /home/fourni_s/UNIX/WarpZone/Astar ** ** Made by sonny fournier ** Login <fourni_s@epitech.net> ** ** Started on Sun May 22 10:31:00 2016 sonny fournier ** Last update Sun May 22 21:04:47 2016 sonny fournier */ #include "my.h" int check_map(char *s, t_read *lab) { int i; int test; l...
C
#include <stdlib.h> #include "stack.h" Stack *createNewStack(Tree *tree) { Stack *newStack = (Stack*) malloc(sizeof(Stack)); newStack->tree = tree; newStack->next = NULL; return newStack; } void push(Stack **stack, Tree *tree) { Stack *new = createNewStack(tree); Stack *head = *stack; i...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <conio.h> // Prototipos MayMen // int NumSecreto (int ar[11],int N); void IngresoNum (int ar[11],int N); int Puntaje (int ar[11],int N); int MayMen(); // Definiciones int MayMen() { int ar[11],N; IngresoNum (ar,N); }...
C
/* * File Name: main.c * * Author: Habiba Mahmoud */ #include "MC1.h" uint8 g_tick = 0; uint8 second; /* Description : * For clock = 8Mhz and prescaler F_CPU/1024 every count will take 128 microsecond * so put initial timer counter=0 0 --> 255 (32ms per overflow) * so we need timer to overflow 31 times to g...
C
#include<stdio.h> int main(void){ int x=2; printf("\ \n \t%d",x); }
C
#include <scheduler.h> extern int sum; extern pthread_mutex_t sem; extern fcfs_queue gqueue; /* =============================================================== FCFS QUEUES =============================================================== */ void fcfs_wait(fcfs_queue* queue) { uint32_t turn; /* - - Seccion...
C
#ifndef SNFS_COMMON_UTILS_H #define SNFS_COMMON_UTILS_H /* * The macros below are for debugging and printing out verbose output. They are * similar to the Linux debug macros in that defining DEBUG will enable debug * output. The verbose macro will print if DEBUG was defined or if the `active` * parameter is true. ...
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 <stdio.h> int main() { int albumSize,playSize,cases=0,songLen[100],playOrder[1000],isUnique,uniqueCount,time; int i,j,k; while(scanf("%d %d",&albumSize,&playSize)!=EOF && cases<150) { cases+=1; time=0; uniqueCount=0; for(i=0;i<100;++i) songLen[i] = 0; for(i=0;i<1000;++i) playOrder[i] = ...
C
/* -*- coding: iso-latin-1-unix; -*- */ /* DECLARO QUE SOU O UNICO AUTOR E RESPONSAVEL POR ESTE PROGRAMA. // TODAS AS PARTES DO PROGRAMA, EXCETO AS QUE FORAM FORNECIDAS // PELO PROFESSOR OU COPIADAS DO LIVRO OU DAS BIBLIOTECAS DE // SEDGEWICK OU ROBERTS, FORAM DESENVOLVIDAS POR MIM. DECLARO // TAMBEM QUE SOU RESPONSAV...
C
/* *c程序的内存分配,c的内存分配包括代码区,数据区,代码区,顾名思义存放代码的,数据区可以细分为 *堆区,栈区(或者叫堆栈),全局区(或叫静态数据区),常量区(字符串常量等) * * */ #include<stdio.h> extern int c; int c = 0; int m = 10; const static int k = 10; void func(int arg) { static int a = 10; printf("static a addr %p\n",&a); int b; printf("local b addr %p\n",&b); int *p = malloc(...
C
#include <stdio.h> #include <string.h> #include <net/if.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <netinet/in.h> int main(){ int fd; struct ifreq ifr; struct sockaddr_in *s_in; fd = socket(AF_INET,SOCK_DGRAM,0); /*新しいIPv4アドレスの値や設定を反映...
C
#include <stdio.h> #include <stdlib.h> #include <netinet/in.h> #include <arpa/inet.h> #include <sys/socket.h> #include <sys/types.h> #define port 10200 int sockfd, newsockfd; struct sockaddr_in seraddr, cliaddr; char buf[255]; void CreateServerSocket(){ sockfd = socket(AF_INET, SOCK_STREAM, 0); seraddr.sin_f...
C
#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> int my_strlen(char* str) { int count = 0; while (*str != '\0') { count++; str++; } return count; } int main() { char arr[] = "hello world!"; int ret = 0; ret = my_strlen(arr); printf("%d\n", ret); return 0; }
C
#include <stdio.h> int main() { FILE *file; char buffer[100]; //open a file to write to file = fopen("intro.txt", "w"); //use fgets to get input from user printf("Write a self introduction using less than 100 characters: "); fgets(buffer, 100, stdin); //use fputs to save user input from buffer to file fpu...
C
#include<stdio.h> int main() { long long int x,n,i,v[61]; v[0] = 0; v[1] = 1; for(i=2; i<=60; i++){ v[i] = v[i-2] + v[i-1]; } scanf("%lld", &x); for(i=0; i<x; i++){ scanf("%lld", &n); printf("Fib(%lld) = %lld\n", n,v[n]); } return 0; }
C
/***************************************************************************** * * Rokko: Integrated Interface for libraries of eigenvalue decomposition * * Copyright (C) 2012-2014 by Tatsuya Sakashita <t-sakashita@issp.u-tokyo.ac.jp>, * Synge Todo <wistaria@comp-phys.org>, * ...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include "parser.h" #include "lexer.h" #include "symbol_table.h" #include "calc.grm.h" static symbol_entry_t* symbol_table = NULL; int lr_parser(int filde) { int value_stack[100]; int value_top = 0; int parse_stack[100]; int parse_top = 0; parse_stack[p...
C
#include <stdio.h> #include <control.h> /* * Function: parser * ----------------------------------------------- * Summary: * Takes a message and parses its type, loads * into 'buffer' or Motor Commands, and * passes into appropriate function. * * @return: * void* to be used with pthread_create to * ...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <SDL.h> #include <glew.h> #include "psys.h" void sdl_panic(const char* msg) { fprintf(stderr, "%s: %s\n", msg, SDL_GetError()); SDL_Quit(); exit(EXIT_FAILURE); } void panic(const char* msg) { fprintf(stderr, "%s\n", msg); SDL_Quit(); exit(E...
C
// // main.c // Approximation // // Created by sonnet on 10/6/13. // Copyright (c) 2013 Mad scientist. All rights reserved. // #include <stdio.h> int main(int argc, const char * argv[]) { float x0, dt, until; printf("input x0: "); scanf("%f",&x0); printf("input dt: "); scanf("%f",&dt); pri...
C
#include "libmx.h" char *mx_charjoin(char *str, char ch) { char *dst = NULL; int len = 0; if (str == NULL) { dst = mx_strnew(1); dst[0] = ch; return dst; } len = mx_strlen(str); dst = mx_strnew(len + 1); for (int i = 0; i <= len + 1; i++) { if (i == len + 1)...
C
/*/ 2. Ler uma string e chamar uma funo para realizar a sua inverso dentro da mesma string. Mostrar a string invertida. /*/ #include <stdio.h> #include <stdlib.h> #include <locale.h> #include <string.h> void Inverter(); void Inverter(char palavra[100]) { int i; printf("\n"); for (i = strlen(palavra) - 1; i >=...
C
#ifndef _SORT_H_ #define _SORT_H_ #include <stdio.h> #include <stdlib.h> /** * struct listint_s - Doubly linked list node * * @n: Integer stored in the node * @prev: Pointer to the previous element of the list * @next: Pointer to the next element of the list */ typedef struct listint_s { const int n; struct li...
C
#include<stdio.h> #include<stdlib.h> #include "searchtree.h" SearchTree CreateSearchTree(Element ele) { SearchTree T; T = (SearchTree)malloc(sizeof(struct SearchTreeNode)); if (T == NULL) { fprintf(stderr, "out of memory\n"); exit(EXIT_FAILURE); } T->Element = ele; T->Left = NULL; T->Right = NULL; retu...
C
#include <stdio.h> #include <string.h> int main( ) { char str1[] = "gaeeks" ; char str2[] = "geeks" ; int j = strcmpi ( str1, str2 ) ; printf ( "The function returns = %d",j ) ; getch(); return 0; }
C
#include<stdio.h> #define SIZE 1000000 int sp=-1; int arr[SIZE]; int isempty() { if(sp==-1) { return 1; } else { return 0; } } int isfull() { if(sp==SIZE) { return 1; } else { return 0; } } void push(int x) { ...
C
/***** TCP CONCURRENT SERVER *****/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/wait.h> #include <inttypes.h> #include "../errlib.h" #include "../sockwrap.h" #include <fcntl.h> #include <signal.h> #include <sys/stat.h> #include <errno.h> /* CONSTANTS */ #define BUFLEN 128 ...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> // struct struct info { char name[0x20]; char channel[0x20]; char twitter[0x20]; }; // global variable struct info vTubers[5]; // function void init() { setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0)...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_putnbr.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include "singlelinkedlist.h" #include "hiredis.h" int main(int argc, char **argv) { unsigned int j; unsigned int k; redisContext *c; redisReply *reply; const char *hostname = (argc > 1) ? argv[1] : "127.0.0.1"; ...
C
#include <glib.h> int main(int argc, char** argv) { GList* list = g_list_append(NULL, "Austin "); list = g_list_append(list, "Bowie "); list = g_list_append(list, "Bowie "); list = g_list_append(list, "Cheyenne "); printf("Here's the list: "); g_list_foreach(list, (GFunc)printf, NULL); printf("\nItem 'Bo...
C
#include <WebUSB.h> WebUSB WebUSBSerial(1, "Deno"); #define Serial WebUSBSerial const int ledPin = 13; void setup() { Serial.begin(9600); Serial.write("Sketch begins.\r\n> "); Serial.flush(); pinMode(ledPin, OUTPUT); } void loop() { int byte = Serial.read(); Serial.write(byte); if (byte == 'H')...
C
/* Brake Light Warning System ***Subsystem Test for Speed and Deceleration*** Written by StanLee Maslonka Program Purpose: Program the ATmega32 to receive Speed from a Hall Effect Sensor and Deceleration from an Accelerometer and control a LED Bar's brightness and flashing rate accordingly. Inputs: Speed from th...
C
//command.c #include <string.h> #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "iodev.h" //Signature global variable extern char signature[5][3]; /* Signature will hold the status of the 5 sensor values in the order: 0: photo 1: gas 2: particle 3: temp 4: humid The values w...
C
#include <stdio.h> int main(void) { int arr[15][15] = {0, }; int test, h, w; for(int i = 0; i < 15; i++) arr[0][i] = i; for(int i = 1; i < 15; i++) { for(int j = 1; j < 15; j++) arr[i][j] = arr[i - 1][j] + arr[i][j - 1]; } scanf("%d", &test); for(int i=0;i<test;i++) { scanf("%d %d"...
C
#include "../../include/my.h" int my_revstr(char* s) { int temp; int rep; int i; int j; if (s == NULL) { return -1; } i =0; j = (my_strlen(s) - 1); while(i < j) { temp = s[i]; rep = s[j]; s[i] = rep; s[j] = temp; i++; j--; } return my_strlen(s); }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* prs_recurse_left.c :+: :+: :+: ...
C
// // main.c // Shell sort // // Created by Rex Ma on 15/12/11. // Copyright © 2015年 Rex Ma. All rights reserved. // #include <stdio.h> #include <stdlib.h> int main(int argc, const char * argv[]) { // insert code here... int a[10]; for (int k = 0; k < 10; k++) { a[k] = rand(); } ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* movement.c :+: :+: :+: ...
C
#include<stdio.h> #include<conio.h> void main() { int m,n,c,d,first[10][10],second[10][10],sum[10][10]; printf("Enter no of rows and columns\n"); scanf("%d%d",&m,&n); printf("Enter elements of first matrix\n"); for(c=0;c<m;c++) for(d=0;d<n;d++) scanf("%d",&first[c][d]); printf("enter elements of 2\n"); for...
C
// bit_array.h // Solution IJC-DU1, example a), 25.03.2016 // Author: Roman Kiselevich, FIT // Compiler: gcc 4.8.4 // Module to working with bit-arrays #ifndef _BIT_ARRAY_H #define _BIT_ARRAY_H #include <limits.h> // CHAR_BIT #include "error.h" // fatal_error() typedef unsigned long* bit_array_t; // The number of ...
C
#ifndef __DRAWING_FUNCS_H_ #define __DRAWING_FUNCS_H_ #include "glut.h" #include <cmath> #define PI 3.1415926535898 static void draw_rect2d(float width, float height, GLenum drawStyle = GL_POLYGON) { glBegin(drawStyle); glVertex2f(-1.0f * width, 1.0f * height); glVertex2f(-1.0f * width, -1.0f * ...
C
#include <fcntl.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char buffer[100]; char receive[100]; printf("Enter the Word: "); scanf("%s",buffer); int fd,fdd; char * fifoSimple = "/tmp/fifoSim...
C
#ifndef DLIST_H #define DLIST_H #include "error.h" typedef struct Node { int val; struct Node *prev, *next; } Node; typedef struct DList { int length; struct Node *sentinel; } DList; Handle init_dlist(DList **dlist); Handle insert_dlist(DList *dlist, int data, int index); Handle reverse_dlist(DList *dlist, ...
C
/* ** my_getnbr.c for Jour05 in /home/vitiel_s/PiscineC/Jour05/my_getnbr ** ** Made by VITIELLO Sullivan ** Login <vitiel_s@etna-alternance.net> ** ** Started on Fri Oct 2 14:41:43 2015 VITIELLO Sullivan ** Last update Fri Oct 2 15:23:38 2015 VITIELLO Sullivan */ int my_getnbr(char *str) { int i; int s; i...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* response_other.c :+: :+: :+: ...
C
#include <stdio.h> int main() { char alphabet[51]; scanf ("%s",alphabet); int i; int answer=0; alphabet[50]=alphabet[0]; for(i=0;i<51;i++) { if(alphabet[i]==alphabet[i+1]) { answer=answer+((int)alphabet[i]-48); printf("%d\n",answer); } } return 0; }
C
/* LDR - Sensor Demo -- using ADC */ // ------- Preamble -------- // #define F_CPU 1000000L /* atTiny85 Bautrate */ #include <avr/io.h> /* Defines pins, ports, etc */ #include <util/delay.h> /* Functions to waste time */ #include "pinDefines.h" /*----- Fu...
C
/* ** main.c for in /home/nicolas/horbac_n/my_aff_tab_num ** ** Made by HORBACZ Nicolas ** Login <horbac_n@etna-alternance.net> ** ** Started on Tue Mar 21 09:59:35 2017 HORBACZ Nicolas ** Last update Tue Mar 21 10:00:57 2017 HORBACZ Nicolas */ void my_aff_tab_num(int tab[], int size); int main() { int tab[...
C
/* Main source file. Contains program entry point function. Author: Matthew Boyette Date: 6/24/2013 */ #include "main.h" int main (int argc, char *argv[]) { // If there is a command-line argument... if (argc > 1) { // Read the file, build the adjacency list, and get a pointer to it. ADJLIST* adjList = par...
C
#include <stdio.h> #include <sys/socket.h> #include <sys/types.h> #include <arpa/inet.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include "tftp.h" #include "file_utils.h" #define HELP "!help" #define MODE "!mode" #define GET "!get" #define QUIT "!quit" #define MAX_CMD_LINE_LEN 64 #define PROMPT ">...
C
#include<stdio.h> #include<stdlib.h> #include<limits.h>//INT_MAX int biggest num #include"show.h" //notice when finish the code find // seg default becasue of : in merge_sort the mid = (low+high)/2 // wrong sort becasue of : when merge the two arr the index i or j cross the line final use the biggest num to be the...
C
/* main.c is the front end/test for list.c */ #include <stdio.h> /* printf */ #include <stdlib.h> /* atoi */ #include "list.h" void test_add_front(void) { int i; struct Node *list = NULL; for (i = 1; i <= 10; i++) { printf("add %2i to front: ", i); add_front(&list, i); print_list(list); } ...
C
#include <stdio.h> #include <time.h> #include "db_ctl.h" #include "main.h" /* ** enemies.c : ̺Ʈ ó 1) struct _EnemyInfo *enemy[MAX_ENEMIES]; 2) struct _EnemyInfo *temp[MAX_ENEMIES]; ϴ ü . enemy : ü temp : ӽ ( ҷ ӽ÷ ) === 3) CurrentEnemies *_enemy[3]; (ִ 3) ϴ ü . === 4) static int enemy_st...
C
#include "sudoku_game_operation.h" /** * Creates an empty atomic game operation * @return Pointer to the game operation object */ sudoku_game_operation_t *create_atomic_game_operation() { sudoku_game_operation_t *operation = malloc(sizeof(sudoku_game_operation_t)); /* Check if malloc was successful */ i...
C
#include <msp430f5529.h> //Precision Control /*** initialize prototype functions ***/ void pinOutput(int values); void trianglewave(); void Counter8bit(); int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer /*** Initialize GPIO pins ***/ P2DIR |= BIT0; // P2.0 output ...
C
#ifndef _HASH_H_ #define _HASH_H_ //ϣ() typedef struct hash hash_t; typedef unsigned int (*hashfunc_t)(unsigned int, void*); hash_t* hash_alloc(unsigned int buckets, hashfunc_t hash_func);// void* hash_lookup_entry(hash_t *hash, void* key, unsigned int key_size);//ѯ void hash_add_entry(hash_t *hash, vo...
C
#include "headers/enlace.h" ////Constantes #define SIZE 1024 /* * Cliente UDP */ //nos[0] guarda as informacoes do no 1. //nos[1] guarda as informacoes do no 2. //etc.. int checkSum(void *); int checksum; int no_do_enlace; // Numero do nó iniciado; void iniciaEnlace(){ no_do_enlace = info.no_de_i...
C
// BUBBLE SORT #include<stdio.h> void swap(int* a, int* b) { int temp = *a; *a = *b; *b = temp; } void bubble_sort(int arr[],int n) { for(int i=0;i<n-1;i++) { for(int j=0;j<n-i-1;j++) { if(arr[j]>arr[j+1]) { swap(&arr[j],&arr[j+1]); } } } } void printarray(int arr[],int n) { for(int i...
C
#include <stdio.h> #include <stdlib.h> typedef struct polynode { float coef; int exp; struct poly *next; } poly; void file_print(poly *head) { poly *p = head; FILE *fp; fp = fopen("poly_list.txt","w"); for(; p!=NULL; p = p->next) { fprintf(fp,"%f %d, ",p->coef,...
C
/*2. Дан текст. Слова в тексте разделены пробелами и знаками препинания. Получить n наиболее часто встречающихся слов и число их появлений.*/ #include <stdio.h> #include <stdlib.h> int memoryCounter(char* text) { int counter = 0, wordLength = 0, lastSymbol = 0; for (int i = 0; i < 256; i++) { if ((text[i] == ' '...
C
/* * Fixed size hash table implementation * * Just a quick hash table implementation for use * with the bot.. will probably switch to * something more standard later.. */ #include <math.h> #include <stdlib.h> #include <stdio.h> #include <assert.h> #include <string.h> #include <sys/queue.h> #include "htable.h" ...
C
#include <stdlib.h> #include <stdio.h> #include <stdbool.h> //Binary Search //Class number 4, March 26, 2018 //Recursive Implementation //Check elem in an array bool check_elem(int *v, int min_index, int max_index, int val){ int middle = ((min_index + max_index)/2); if(max_index < min_index) return false; ...
C
/* ** change_lines_ai.c for in /home/sepret_f/sem2/cpe/CPE_2015_Allum1 ** ** Made by fabrice sepret ** Login <sepret_f@epitech.net> ** ** Started on Wed Feb 10 14:39:58 2016 fabrice sepret ** Last update Thu Feb 18 14:33:13 2016 fabrice sepret */ #include <stdlib.h> #include "alum1.h" int change_line1_ai(t_va v...
C
#include "binary_trees.h" /** * binary_tree_nodes - counts the nodes with at least 1 child * @tree: root node of the tree to count the number of nodes * * Return: number of nodes */ size_t binary_tree_nodes(const binary_tree_t *tree) { size_t child = 0; if (!tree) return (0); if (tree->left || tree->right) ch...
C
#ifndef OVERDRIVE_H #define OVERDRIVE_H #define LPF1P 0 #define HPF1P 1 typedef struct iir_1p_t { // Coefficients float a1; float b0; float b1; // State variables float x1; float y1; } iir_1p; typedef struct overdrive_t { float fs; // Sampling frequency float clipper_fs; //...
C
/* ** EPITECH PROJECT, 2020 ** PSU_tetris_2019 ** File description: ** test_tetrimino_create_from_file */ #include <criterion/criterion.h> #include <criterion/redirect.h> #include <ncurses.h> #include "tetrimino.h" Test(tetrimino_create_from_file, snake) { tetrimino_t *tetrimino = NULL; char const tetrimino_p...
C
/* Sample UDP client */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> //Хэш-функция, используемая для проверки данных пользователя и пароля unsigned int HashH37(const char * str) { unsigned int ...
C
#include "print_string.h" void print_it(); int main() { print_it(); } void print_it() { char *str1 = "This is User1"; char *str2 = ".I'm running now."; while(1) { print_string(5, 10, str1); print_string(5, 11, str2); str2[0]++; } }
C
#ifndef __PRIM_AND_KRUSKAL_H__ #define __PRIM_AND_KRUSKAL_H__ #include <stdio.h> #include <stdlib.h> #define MAX_VERTEX 100 //最大结点个数 #define INFINITY 65535 //用来表示无穷大的数据 typedef int ElemType;//自定义用户数据类型 typedef float EdageType;//自定义边的数据类型 //定义图的数据结构 /* typedef struct { int number;//顶点编号 ElemType data;//其他数据信息 }Vert...
C
#include <stdio.h> #include <stdlib.h> #include <locale.h> #include <ctype.h> #include <string.h> typedef struct Pessoa cel; struct Pessoa{ cel *prox; cel *anterior; int idade; char nome[30]; float altura; float peso; }; struct No{ int chave; int tamanho; cel *head; struct No *direita; struct No *esquerda; struct No...
C
/* ---------------------------------------------------------------------------- * args.c --- Argument parsing utilities * nca-073-9 * * Copyright (c) 1996-2000 by Netcetera AG. * Copyright (c) 2001 by Apache Software Foundation. * All rights reserved. * * See the file "license.terms" for information on usage a...
C
#ifndef BRANCH_H #define BRANCH_H #include "sale.h" #include "auxStructs.h" /** * \brief Structure that stores all relations between the clients and products of a branch. * * It uses two hash tables to store information, one matches a product to all the clients who bought it, and the other matches a client to all...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> #define MAX_SIZE 100 #define LEN 10 #define MALLOC(p,s)\ if( !((p) = malloc(s)) ){\ printf("malloc fail");\ exit(1);\ } typedef struct { char item[LEN]; int key; }element; typedef struct node* nodePointer; typedef struct node { ele...
C
/* ** EPITECH PROJECT, 2019 ** get_str.c ** File description: ** read with getline from a fd */ #include "my.h" char *get_str(int fd, int n) { char *buffer = NULL; size_t size = 0; char *res = my_strdup("", KEEP); FILE *pipfd = get_pipe_fd(fd); if (n == -1) return (NULL); while ((n = ...
C
#include <stdio.h> #include <stdlib.h> void sort(int vet[], int m){//Metodo de ordenamento Descrence bouble sort int i = 0, j =0; int max = 0; int flag = 0; for(i=0;i<m;i++){ max = vet[i];//Considera este sendo o possivel maior numero for (j=0;j<m;j++){ if (vet[j]< max){ vet[i] = vet[j]; vet[j] = ma...
C
#include <stdio.h> int main(void) { int score; printf("Enter your score : "); scanf("%d", &score); //int a = 60; //printf("%d\n", score >= a); int isPassed; isPassed = (score >= 60); printf("score %d is passed? %d\n", score, isPassed); return 0; }