language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
int *binarysearch(int A[],int target,int n){ int *low=&A[0]; int *high=&A[n]; int *mid; while(low<high){ mid=low+(high-low)/2; if(target==*mid) return mid; else if(target<*mid) high=mid; else if(target>*mid) low=mid+1; } return NULL; }
C
#include<stdio.h> #include<string.h> void main(int a, char** inp){ char * token; token = strtok(inp[0], " "); token = strtok(NULL, " "); if(strcmp(token, "-E")==0){ token = strtok(NULL, " "); while(token != NULL){ char file1[100]; strcpy(file1, token); FILE *fptr1 = fopen(file1, "r"); char line1[2...
C
#include <pthread.h> #include <semaphore.h> #include <stdio.h> #define N 5 //number of philosophers /* use the lpthread flag with gcc to compile this code ~$ gcc q1.c -lpthread */ /* various states of a philosopher */ #define THINKING 2 #define HUNGRY 1 #define EATING 0 /* index of left and ri...
C
#include "crypto_decode.h" #include "crypto_uint8.h" #define uint8 crypto_uint8 #define p 1277 void crypto_decode(void *v,const unsigned char *s) { uint8 *f = v; uint8 x; int i; for (i = 0;i < p/4;++i) { x = *s++; *f++ = ((uint8)(x&3))-1; x >>= 2; *f++ = ((uint8)(x&3))-1; x >>= 2; *f++ = ((ui...
C
/* ** bufferize.c for minishell1 in /home/nicolaspolomack/shell/PSU_2016_minishell1 ** ** Made by Nicolas Polomack ** Login <nicolas.polomack@epitech.eu> ** ** Started on Mon Jan 9 10:55:14 2017 Nicolas Polomack ** Last update Sun May 21 11:49:53 2017 Arthur Knoepflin */ #include <sys/stat.h> #include "my.h" in...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #pragma region data_structure typedef struct _stackNode StackNode; struct _stackNode{ int value; StackNode * nextNode; }; StackNode * _head; #pragma endregion data_structure #pragma region methods_signature /************ * Constructors n ...
C
#include "HoareQuickSort.h" #if DEBUG #include <stdio.h> #endif // DEBUG /* nondecreasing order: type = 1 nonincreasing order: type = 0 */ void HoareQuickSort(int* a, int first, int last, int type) { if (type) { HoareQuickSortNondecreasingOrder(a, first, last); } else { HoareQuickSortNonincreasingOrder(a,...
C
#include<stdio.h> #include<stdlib.h> #include "storage_mgr.h" #include<string.h> FILE *page; extern void initStorageManager (void){ page = NULL; } extern RC createPageFile (char *fileName) { page = fopen(fileName,"w+"); if(fileName == NULL){ return RC_FILE_NOT_FOUND; } if(page==NULL){ fclose(page); pri...
C
/* Sample thread program to add the numbers in an array */ #include <stdio.h> #include <stdlib.h> #include <pthread.h> #define array_size 1000 #define no_processes 10 int a[array_size]; int global_index = 0; int sum = 0; pthread_mutex_t mutex1; pthread_mutex_t mutex2; void *slave(void *ignored) { int local_index, ...
C
#include<stdio.h> #define MAX 100 void crtanje(int n, int raz); int main() { int n; printf("Unesi n:\n"); scanf("%d", &n); crtanje(n, 0); printf("\n"); return 0; } void crtanje(int n, int raz) { int i; if (n == 1) { for (i = 0; i < raz; i++)printf(" "); printf("...
C
#include "b-tree.h" #include <stdlib.h> #include <assert.h> /* ========================================================================== * PROTOTIPOS * ========================================================================== */ static b_node_t * b_node_new (); static b_node_t * b_node_add_nonfull (b...
C
#ifndef DOUBLE_LIST_H #define DOUBLE_LIST_H #include <stdlib.h> #define DOUBLE_LIST_GET_NEXT(double_list_ptr, typename) (typename *)double_list_ptr->next #define DOUBLE_LIST_GET_PREV(double_list_ptr, typename) (typename *)double_list_ptr->prev typedef struct double_list { struct double_list *next; struct double_li...
C
#include <stdio.h> #include <unistd.h> int main(int argc, char *argv[]){ FILE *secret = fopen("/root/root-me-challenges/app-systeme/ch5/.passwd", "rt"); char buffer[32]; fgets(buffer, sizeof(buffer), secret); printf(argv[1]); printf("\n"); printf("%s\n",buffer); printf("%x\n",buffer); printf("%p\n",buffer); ...
C
/* * Implementation of the null device, "null:", which generates an * immediate EOF on read and throws away anything written to it. */ #include <types.h> #include <kern/errno.h> #include <lib.h> #include <vfs.h> #include <dev.h> #include <uio.h> /* For open() */ static int nullopen(struct device *dev,...
C
/* * Extracted from jstest.c developed by Vojtech Pavlik */ /* * This program can be used to test all the features of the Linux * joystick API. It is also intended to serve as an example * implementation for those who wish to learn * how to write their own joystick using applications. */ #include <sys/ioctl....
C
//////////////////////////////////////////////////////////////////////////////// // Display update //////////////////////////////////////////////////////////////////////////////// #include "display.h" #include "map_to_7segment.h" #define DISPLAY_BLINK_HALF_PERIOD 20 #define DISPLAY_SCROLL_RATE 12 static st...
C
/************************************************************************* > File Name: switch.c > Author: wangjx > Mail: wangjianxing5210@163.com > Created Time: 2018年10月09日 星期二 14时50分20秒 ************************************************************************/ #include <stdio.h> #include <stdlib.h> #includ...
C
/** lab32.c * =========================================================== * Name: Jim Wang, 12 November 2019 * Section: T3A/4A * Project: Lab 32 * Documentation: C3C Gills helped me differentiate between tail and head recursion. * =========================================================== */ #include "lab32.h" int ...
C
#include <stdio.h> #include <stdlib.h> int main() { int a = 0, b = 1, c = 0, i = 0, answer = 0; printf("input number : "); scanf_s("%d", &answer); for (i = 1, i <= answer; i++) { printf("%d", a); c = a + b; a = b; b = c; } return 0; }
C
#ifndef OS345ARGPARSE_H_ #define OS345ARGPARSE_H_ #include <stdio.h> #include <stdarg.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include "os345.h" #define MAX_ARG_LEN 256 char* bufferContents; int nextCharPos; typedef struct { int argc; char** argv; bool runInBackground; int errors; } Parse...
C
#include "client.h" /** * Function that makes the ips that will connect to the server */ void makeIp() { char *firstPart = "http://"; char *secondPartImage = "/Api/Analyze"; char* secondPartStop = "/Api/Stop"; serverImageLink = malloc(strlen(firstPart) + strlen(serverIp) + strlen(secondPartImage) +...
C
bool isMatch(char* s, char* p) { int length_s, length_p, i, j; int len_flag = 0; char left, right; length_s = strlen(s); length_p = strlen(p); // unequal lenth if(length_s != length_p) { for(i = 0;i < length_p;i++) if(p[i] == '*') { len_flag ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "abm.h" int getInt(char mensaje[]) { int auxInt; printf(mensaje); scanf("%d",&auxInt); fflush(stdin); return auxInt; } float getFloat(char mensaje[]) { float auxFloat; printf(mensaje); scanf("%f",&auxFloat); fflush(...
C
#include "main.h" void operatorControl() { bool btnPress = 1; int rightPower; int leftPower; while (1) { //Tank Drive rightPower = joystickGetAnalog(1, 2); leftPower = joystickGetAnalog(1, 3); if(abs(rightPower) > 15 || abs(leftPower) > 15) { motorSet(DRIVE_R, -rightPower); m...
C
#include <stdio.h> #include <stdlib.h> #include "funcion.h" int main() { char seguir='s'; int opcion; float x; float y; float resultado; int pusonumeroUno=0; int pusonumeroDos=0; while(seguir=='s') { if(pusonumeroUno==0) { printf("1- Ingr...
C
/* blah_entity.c Defines functions which operate upon entities. See blah_entity.h for reference. */ #include <stdlib.h> #include <stdio.h> #ifdef BLAH_USE_GLUT #include <GL/glut.h> #endif #include <string.h> #include "blah_entity.h" #include "blah_macros.h" #include "blah_matrix.h" #include "blah_list.h" #include...
C
#include<stdlib.h> #include<stdio.h> int main() { printf("Content-Type: text/html\n\n"); printf("<html><head><title>C Script</title></head>"); printf("<body>"); printf("<form action='a.out' method='post'><p>"); printf("<input type='submit' value='Click me!'/>"); printf("</p></form></body></html>"); ...
C
# include <stdio.h> int main (void) { int i; do { printf("Please input a wind speed: \n"); scanf("%d", &i); if (i<1) printf ("If you wish to return to the start press C \n If you wish to quit, input Q \n"); fflush(stdin); scanf("%s", &q); } while(q!='Q'); return 0; }
C
/*// section pour inclure les en-tete #include <stdio.h> #include <stdlib.h> //section pour delarer les fonctions et variables globales int main(); // cette ligne est optionnelle int addition(int i, int j); // cette ligne est essentielle // variable globale int registre; //section pour delarer les fonctions // la fon...
C
#include <stdio.h> #include <stdlib.h> #define nomBin "RegistrosBin.bin" #define nomText "RegistrosText.txt" #define TAM 300 #define CON_MSJ 1 typedef struct { long dni; char apyn[36]; char sex; }t_pers; void crearBinario (char *nombre); void crearText (char *nombre); int abrirArchivo (FILE **fp, char *nombre, cha...
C
#include "nes.h" struct _ppu ppu = { .read = &nes_ppu_read_address, .write = &nes_ppu_write_address }; uint8_t nes_ppu_read_null(uint16_t address) { return 0; } void nes_ppu_write_null(uint16_t address, uint8_t value) { } uint8_t ppu_read_pattern_table(uint16_t address) { printf("READ PATTERN\n"); retu...
C
#include <stdio.h> int main() { int counter = 0; int num = 1; int div = 1; printf(" Prime Number from 1 to 100 are: \n"); printf("1\n"); while(num <= 100) { div = 2; counter = 0; while (div <= num/2) { if (num % div == 0) { counter = 1; break; } div++; } if (counter == 0...
C
int binarySearch (char aray[][Length], int size, char search_item[LENGTH]){ int first = 0, last = size -1; bool found = false; int position = -1, middle; while (!found && first <= last){ middle = (first + last ) / 2; if ((strcmp(array[middle],search_item))==0){ position = mi...
C
/* ** aff_prompt.c for in /home/buffat_b/couver-shell ** ** Made by ** Login <buffat_b@epitech.net> ** ** Started on Wed May 25 14:05:49 2016 ** Last update Sun Jun 5 16:16:46 2016 Bertrand Buffat */ #include "shell.h" void erase_down_lines(t_prompt *prompt, int nb_lines) { write(1, prompt->start_line_str, str...
C
int arr[] = {0,0,0,0,0,0,0,0,0,0}; int *base = arr; void add(int val, int offset){ val = arr[offset] + val; arr[offset] = val; } void main(){ int var1 = 1; int var2 = 2; add(3,4); add(var1,var2); for (int x = 0; x < 10; x++) printf("%d\n", arr[x]); }
C
/** * Tree data structure header file */ #ifndef TREE_H #define TREE_H #include <stdio.h> #include <stdlib.h> typedef struct treeNode TreeNode; // Tree node struct struct treeNode { char *path; char *name; TreeNode *children; TreeNode *siblings; int level; }; typedef struct tree Tree...
C
#include "cmod.h" #include "timer.h" #include "oi.h" #include "sensors.h" //drive straight until you hit something void findWall(void) { drive(100); for (;;) { delayMs(100); getBumps(); if (bumpLeft || bumpRight) { stop(); break; //escape for loop } } } //determines the wall sensor strength // val...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* move_util.c :+: :+: :+...
C
/* ** EPITECH PROJECT, 2019 ** BSQ ** File description: ** */ #include <stdlib.h> #include "my.h" void fs_understand_return_of_read(int fd, char *buffer, int size) { int buff_size = read(fd, buffer, size); if (buff_size == -1) my_putstr("read failed\n"); if (buff_size == 0) my_putstr("rea...
C
#include "bggl3.h" #include <math.h> int bggl3_id_int, bggl3_id_float, bggl3_id_cons, bggl3_id_null; int bggl3_id_symbol, bggl3_id_string, bggl3_id_complex; int bggl3_id_fvector; elem bggl3_print(BGGL3_State *ctx, elem args) { elem a, c; int i; c=args; while(c) { a=BGGL3_CAR(c); i=BGGL3_GetTypeID(a); if(...
C
#include <stdio.h> void main(){ int contador = 1; int numero; do{ printf("digite um numero: "); scanf("%d", &numero); if(numero % 3 == 0){ printf("o numero %d e divisivel por 3 \n", numero); } contador++; } while(contador <= 10); }
C
#include <stdio.h> typedef struct a { int i; int j; }a; *a f(a x) { a *r = x; return r; } int main(void) { a *x = { 56,89 }; a *y = f(x); printf("%d\n", y->j); return 0; }
C
/* * jpg-recover -- Extract JPEG/CR2 files from raw bytes (filesystem images etc.). * Copyright (c) 2011, Matus Tejiscak <functor.sk@ziman>. * Released under the BSD license: http://creativecommons.org/licenses/BSD/ */ #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include "globals...
C
#include <stdio.h> #include <string.h> #include "first.h" int main(int argc, char* argv[]) { unsigned short x; char* command; unsigned short arg1; unsigned short arg2; char* fileName = argv[1]; FILE* fp = fopen(fileName, "r"); fscanf(fp, "%hu", &x); while(fscanf(fp,"%s\t%hu\t%hu", co...
C
#include<stdio.h> int main() {int n,m,i,j, k, c, A=0, B=0; printf("Enter height n and width m\n"); scanf("%d %d",&n,&m); int a[n][m]; for(i=0;i<=n-1;i++){ for(j=0;j<=m-1;j++){ printf("Enter a[%d][%d]\n",i,j); scanf("%d",&a[i][j]); } } for(i=0;i<=n*m-1;i++){if((i-1)/m<i/m){ printf("\...
C
#include "../../common/common.h" #include "../../common/APP.h" /* *Find mac flag in table switch *@author SUN ZHOGNJIAN */ void getIpSwitch(){ int rc; char* sql = malloc(100); memset(sql, 0, 100); strcat(sql, "SELECT * FROM switch;"); char* zErrMsg = 0; rc = sqlite3_exec(db, sql, getSwitch...
C
#include <stdio.h> #include <stdlib.h> #include <pthread.h> int ar[1000]; int chunk_size=100; void * TestThread(void *arg) { int i=0,sum1=0; int start=(int)arg; int end=start+chunk_size; for ( i=start;i<end;i++) sum1=sum1+ar[i]; return ((void*)sum1); } int main () { int i=0; for ( i=0;i<1000...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> #include "shet.h" #include "shet_json.h" #include "jsmn.h" #ifdef SHET_DEBUG #define DPRINTF(...) fprintf(stderr, __VA_ARGS__) #else #define DPRINTF(...) #endif //////////////////////////////////////////////////////////////////////////...
C
#include <stdio.h> #include <string.h> struct person_name{ char first[10]; char middle_initial; char last[10]; }; struct student{ struct person_name name; int id, age; char sex; }; int main(){ struct student student1; strcpy(student1.name.first, "Artem"); printf("%s\n", student1.name.first); return 0; ...
C
#include<stdio.h> int main() { char A[]="How are you"; int i,vcount=0,ccount=0; for(i=0;A[i]!='\0';i++) { if(A[i]=='a' || A[i]=='e' || A[i]=='i' || A[i]=='o' || A[i]=='u' || A[i]=='A' || A[i]=='E' || A[i]=='I' || A[i]=='O' || A[i]=='U') { vcount++; } ...
C
#include <stdio.h> #include <stdlib.h> int main () { int a[6]; int i; int Asc=0; int desc=0; printf ("Ingrese un listado de 5 numeros \n "); for (i=0;i<6;i++) { scanf ("%d",&a[i]); } //1 2 3 4 5 6 for (i=0;i<5;i++) { if (a[i]<=a...
C
#include <stdio.h> int main(void){ int N; char name[256][256]; int i, j; scanf("%d", &N); for (i = 0; i < N; ++i){ scanf("%s", name[i]); } for (i = 0; i < N; ++i){ for (j = 0; name[i][j] != '\0'; ++j){ if (name[i][j] >= 65 && name[i][j] <=90){ ...
C
#include <stdio.h> void trocaVetor(int *v1, int v2[5]){ int i, aux; for(i=0; i < 5; i++){ aux = v1[i]; v1[i] = v2[i]; v2[i] = aux; } } void somaVetor(int v1[], int *v2, int v3[5]){ int i; for(i=0; i < 5; i++){ v3[i] = (v1[i] + v2[i]); } } int main(){ int i; int vetA[5], vetB[5], vetC[5]; for...
C
#ifndef PRIM_C #define PRIM_C struct prim { char nome_arquivo[64]; int vertices; int arestas; int **grafo; // grafo com ate max_vertices quantidades de vertices int max_vertices; int infinito; int custo_minimo; // custo minimo do grafo char arquivo_saida[64]; // armazena arquivo de saida }; typedef struct pri...
C
#define MAXROWS 10 #define MAXCOLS 10 #define TRUE 1 #define FALSE 0 #define TOP_MARGIN "\n" #define LEFT_MARGIN "\t" #define BOTTOM_MARGIN "\n" enum gameResults { IN_PROGRESS, DRAW, WIN1, WIN2, INVALID_MOVE1, INVALID_MOVE2, TIMEOUT1, TIMEOUT2, ERROR }; struct game { int rows; int columns; int piecesToWin; int...
C
#include<stdio.h> #include<stdlib.h> #include<time.h> void randomArray(int arr[], int n) { srand(time(0)); for(int i = 0; i<n; i++) { arr[i] = rand()%99; } } int left(int i) { return (2*i)+1; } int right(int i) { return (2*i)+2; } int parent(int i) { return (i/2)-1; } void swap(int *a,int *b) { int temp; ...
C
#include "holberton.h" /** * reverse_array - This function reverses the content of an array of * integers * @a: The array of integers to reverse * @n: The number of elements in the array */ void reverse_array(int *a, int n) { int i, tmp; /* loop through array reversing elements */ for (i = 0; i < n; i++) { ...
C
#include<stdio.h> int main() { int start,end,i; scanf("%d %d",&start,&end); for(i=start+1;i<end;i++) { if(i%2==0) { printf("\t %d",i); } } return 0; }
C
#include <stdio.h> int rev(int); int fl(int); int main() { int i; int num; int tests; scanf("%d", &tests); for(i = 0; i < tests; i++) { scanf("%d", &num); printf("%d\n", fl(num)); } return 0; } int fl(int num) { int sum = 0; sum += num % 10; sum += rev(...
C
#include<stdio.h> int main(void){ int n; int result=0,tmp; int i,flag=1; scanf("%d",&n); for(i=1;i<n;i++){ result=i; tmp=i; while(tmp){ result+=tmp%10; tmp/=10; } if(result==n){ printf("%d\n",i); flag=0; break; } } if(flag) printf("0\n"); return 0; }
C
//first 5 topics from the PDF #include <stdio.h> #include <math.h> // global variables in C char intro[100] = "Logic matters, language doesn't"; // functions in C int add(int a, int b){ int c; c = a + b; } int max(int a, int b){ if (a > b) return a; else return b; } void name(char n...
C
#include <stdio.h> #include <stdlib.h> #include "calculadora.h" int main(void) { setbuf(stdout,NULL); char opcionLetra; float numUno; float numDos; float resultadoSuma; float resultadoResta; float resultadoDivision; float resultadoMultplicacion; float resultadoFactorialUno; float resultadoF...
C
#include<stdio.h> int main() { int i,res=0; int arr[11]; printf("enter array elements\n"); for(i=0;i<11;i++) scanf("%d",&arr[i]); for(i=0;i<11;i++) printf("array elements are %d\n",arr[i]); for(i=0;i<11;i++) res=res^arr[i]; printf("%d\n",res); return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> char *read_line(); char *remove_equal_consecutive_chars(char *input); int main() { char *string = read_line(&string); string = remove_equal_consecutive_chars(string); printf("%s\n", string); return 0; } //removes equal consecutive chars ex. ...
C
/****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. Code, Compile, Run and Debug online from a...
C
#include "checkup.h" #define error_print(...) fprintf(stderr, __VA_ARGS__) int error(char *error) { error_print("%s\n", error); return UNSUCCESS; } bool check_count_of_parameters(parameters_count_t parameters_count) { if (parameters_count == PARAMS_COUNT) { return true; } return false; } ...
C
/*QUESTO 08: Em uma empresa deseja-se fazer um levantamento sobre algumas informaes dos seus 250 funcionrios. Cada funcionrio dever responder um questionrio ao qual informar os seguintes dados: matrcula, sexo, idade, salrio e tempo (em anos) de trabalho na empresa. A execuo do programa deve exibir os seguintes iten...
C
#define _CRT_SECURE_NO_DEPRECATE 1 #include <stdio.h> int main() { int arr[] = { 1, 2, 3, 4, 5, 1, 2, 3, 4 ,5,8,9}; int i = 0; int ret = 0; //int j = 0; int sz = sizeof(arr) / sizeof(arr[0]); for (i = 0; i < sz; i++) { ret = ret^arr[i]; /*int count = 0; for (j = 0; j < sz; j++) { if (arr[i] == arr[...
C
#include <conf.h> #include <kernel.h> #include <proc.h> #include <lock.h> #include <stdio.h> #define DEFAULT_LOCK_PRIO 20 void sem_fun (char *msg, int sem) { kprintf ("%s:to acquire sem\n", msg); wait(sem); kprintf ("%s:acquired sem\n", msg); sleep (2); kprintf ("%s:to release sem\n", msg);...
C
extern char** environ; main() { char** env=environ; while(*env){ printf("%s\n",*env++); } return; }
C
#include <stdio.h> #include <signal.h> void handler(int signum) { signal(signum, handler); printf("caught: %d\n",signum); } int main(int argc, char* argv[]) { printf("test\n"); for (int i=1; i<=64; i++ ) { // signals 32 and 33 are not in kill -l if(i!=32 && i!=33) { ...
C
/* * This file is subject to the license agreement located in the file LICENSE * and cannot be distributed without it. This notice cannot be * removed or modified. */ #include "ocr.h" #include "extensions/ocr-affinity.h" /** * DESC: This program spawns a "latch" event, N task "A"'s and N "once" events. * Task A...
C
#include<stdio.h> #include<stdlib.h> int stack[10]; int top=0; int push(int x) { stack[top++]=x; } int pop() { int d=stack[--top]; return d; } int expr(char ch) { int a,b; int c; b=pop(); a=pop(); if(ch == '+') { c=a+b; } else if(ch == '-') { c=a-b; } else if (ch == '*') { c=a*b; } push(c); }...
C
// divide_files.c for Yolo // Compile: gcc -o divide_files divide_files.c // Usage: // ./divide_files // ./divide_files [portion] // portion: the portion of test data. The default value is 0.2. #include <stdio.h> #include <stdlib.h> #include <err.h> #include <sys/types.h> #include <diren...
C
/* mtime.c, by Jehsom. * Shows the modification time of a file in epoch time. * This software is property of the public domain. */ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <time.h> #include <strings.h> #define TIMELEN 300 int main( int argc, c...
C
#ifndef _STDIO_H #include <stdio.h> #include "Assignment2.h" #endif char *sappend (char *str1, char *str2) { while (*str1 != '\0') { str1 ++; } while (*str2 != '\0') { *str1 ++ = *str2 ++; } *str1 = '\0'; return str1; }
C
#include "lib.h" #include "types.h" int data = 0; void producer(int pid, sem_t mutex, sem_t empty, sem_t full) { int i = pid - 1; for(int k = 0; k < 8; k++) { sem_wait(&empty); printf("pid %d, producer %d, produce, product %d\n", pid, i, k + 1); sleep(128); printf("pid %d, prod...
C
#include<stdio.h> #include<stdlib.h> int main() { int *ar[5],n[5],i,j,m; for(i=0;i<5;i++) { printf("Enter number of student for class %d\n",i+1); scanf("%d",&m); n[i]=m; ar[i]=(int *)malloc(sizeof(int)*m); if(ar[i]==NULL) { printf("Memory allocation failed\n"); return 1; ...
C
#include "cq-header.h" int sec(pd0) /* 6.2 Float and double */ /* 6.3 Floating and integral */ /* 6.4 Pointers and integers */ /* 6.5 Unsigned */ /* 6.6 ...
C
#include "interface.h" void setEntradaGrafo(Grafo *grafo, char *entrada) { char **Buffer; int size; Buffer = leArquivo(entrada, &size); if(Buffer == NULL) { printf("\nErro ao ler arquivo, o programa sera fechado!!\n"); exit(EXIT_FAILURE); } int i, V1, V2, NVertices, NAresta...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <omp.h> #include <math.h> #define LINE_SIZE 26 //strict file format: assuming fixed length for each line and value #define POINT_SIZE 8 #define MAX_OUTPUT 3464 #define MAX_LINE_COUNT 1000000 //maximum of lines to be allocated at once ...
C
#include <stdio.h> #include <time.h> #include <stdlib.h> struct card{ int data; struct card *next; }; typedef struct card card; int check(int b, int* count){ if(count[b - 1] == 0){ count[b - 1] = 1; return b; }else{ b = rand() % 13 + 1; return check(b, count); } }; ...
C
#include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdio.h> #include <errno.h> #include <string.h> #include <sys/ioctl.h> #include <ctype.h> #include <stdlib.h> #include "CtcDrvr.h" #define _DRVR_NM_ "CTC" #define matchEndian(bytes, size, depth) { } /** * @brief Open devic...
C
#include "binary_trees.h" /** * binary_tree_preorder - a function that pre-order traverses a binary tree * @tree: a pointer to the root node of the tree to traverse * @func: a pointer to a function to call for each node, value passed as param * * Return: No data type returned. If tree or func is NULL do nothing....
C
#include<stdio.h> int cnt=0; void move(int,char,char,char); int main(){ int disk; printf("Input num of disks : "); scanf("%d",&disk); move(disk,'A','B','C'); return 0; } void move(int n, char a, char b, char c) { if (n == 1) { ++cnt; printf("\n%5d: Move disk 1 from %c to %c", cnt, a, c); return; } els...
C
#include<sys/ipc.h> #include<sys/shm.h> #include<stdio.h> #include<stdlib.h> #include<unistd.h> int main (){ // ftok to generate unique key key_t key = ftok("shmfile",65); // shmget returns an identifier in shmid int shmid = shmget(key,5*sizeof(int),0666|IPC_CREAT); // shmat to attach to shared memory ...
C
#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include "utility.h" unsigned char debug; int GetClockSecond(void) {int ret,time; struct timespec res; ret=clock_gettime(CLOCK_MONOTONIC,&res); if(ret==0){ time=res.tv_sec+(res.tv_nsec/1000000000); } else { ...
C
#include "holberton.h" /** * print_rev - function that prints a string * in reverse, followed by a new line. * @s: input is a parameter * Return: void */ void print_rev(char *s) { int i, j; i = 0; while (s[i] != 0) { i++; } for (j = (i - 1); j >= 0; j--) { _putchar(*(s + j)); } _putchar('\n'); }
C
#include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <pthread.h> double factor(double num) { if (num == 0) { return 1; } double answ = 1; for(int i = 1;i<=num;i++) { answ*=i; } return answ; } int* erat(int n) { int* begining = (int*)malloc((n+1)*sizeof(int)); int counter = 0; int* curren...
C
/* $Id: msh.c,v 1.48 2017/06/02 03:38:15 tranb7 Exp $ */ /* CS 352 -- Mini Shell! * * Sept 21, 2000, Phil Nelson * Modified April 8, 2001 * Modified January 6, 2003 * */ /* Brandon Tran * March 29, 2017 * CS 352 * Assignment 2 */ #include <stdio.h> #include <string.h> #include <unistd.h> #inc...
C
/** * Copyright (c) 2017 willydlw * * This library is free software; you can redistribute it and/or modify it * under the terms of the MIT license. See `main.c` for details. */ /** @file communication_state.h * * @brief Finite state machine definitions for communication * with another program. * * * @auth...
C
#include<stdio.h> typedef struct TreeNode { char c; struct TreeNode *leftchild; struct TreeNode *rightchild; }TreeNode; int CompTree(TreeNode* tree1,TreeNode* tree2); struct TreeNode* createTree( TreeNode * ); void showTree( TreeNode * ); int main(void) { TreeNode *tree1, *tree2; tree1 ...
C
/* $Copyright: $ * Copyright (c) 1994 by Steve Baker (ice@mama.indstate.edu) * All Rights reserved * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * ...
C
// If SW1 is pressed, the green LED will be toggled every half second (the red LED will be off). // If SW1 is not pressed, the red LED will be toggled every half second (the green LED will be off). // Whenever SW2 is pressed (no matter SW1 is pressed or not), all LEDs will be off. // Considering the Tiva’s clock frequ...
C
#include<stdio.h> void main() { // sp=selling price,cp=cost price,p=profit,l=loss int sp,cp,p,l; printf("\n enter the selling price and cost price"); scanf("\n %d%d",&sp,&cp); if(sp>cp) printf("\n profit %d",sp-cp); else printf("\n loss %d",cp-sp); }
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include "Node.h" #include <stdbool.h> int countNodes(node *root, int *count) { if(root==NULL) return 0; countNodes(root->left, count); (*count)++; countNodes(root->right, count); return *count; } bool checkBinary(node *root, int i, int count) { if(ro...
C
#include <stdio.h> int main(){ int a,b,c; printf("informe o valor dos tres lados do triangulo:\n"); scanf("%d %d %d", &a, &b, &c); if ((a == b)&&(b==c)){ printf("O triangulo e equilatero."); }else if ((a == b)||(b==c)) { printf("O triangulo e isosceles."); }else{ printf("O triangulo e escaleno.");...
C
#pragma once #include <stdio.h> #include "DetermineBarcodeInfo.h" #include "menu.h" #include "printReceipts.h" //void barcodeDataToProduct(productNow productList[],int i); int isProductInTheList(); void salesProcess(); void printProductInTheList(productNow productList[], int b[7]); void resetList(productNo...
C
/* * mm_alloc.h * * Exports a clone of the interface documented in "man 3 malloc". */ #pragma once #include <stdlib.h> void *mm_malloc(size_t size); void *mm_realloc(void *ptr, size_t size); void mm_free(void *ptr); /*struct of block*/ struct block { struct block *prev; struct block *next; int free...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* kostyliivelosipedy.c :+: :+: :+: ...