language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> int main() { int a = 7; int arr[] = { 1,2,3,4,5,6,7,8,9,10 }; int sz = sizeof(arr)/sizeof(arr[0]); int left = 0; int right = sz - 1; int mid = 0; while(left <= right) { mid = (left + right) / 2; if(arr[mid] < a) { left = mid + 1; } else if(arr[mi...
C
/* * dcMotor.c * * Created: 1/27/2020 4:53:40 PM * Author: Az */ #include "dcMotor.h" #include "dcMotorConfig.h" #include "timers.h" /** * Description: * @param */ void MotorDC_Init(En_motorType_t en_motor_number) { switch (en_motor_number) { case MOT_1: /*set directions of motor 1 enab...
C
/* ************************************************************************** */ /* LE - / */ /* / */ /* zombie.c .:: .:/ . .:: ...
C
// Analog I/O using AVR embedded ADC #include <avr/io.h> #include "analog.h" // ADMUX value for each channel static const uint8_t channel_selectors[8] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }; // Initialization // TODO: Initialize PORT/DDR void analog_init(void) { ADMUX = (1 << REFS1) | (1 << REFS0);...
C
//Autores //Bruno Baptista 2018278008 //Nuno Tiago 2017276208 #include "functionsa.h" #include <stdio.h> #include <stdlib.h> #include <string.h> //tipo é a string que vamos passaar, valor ou vai ser null ou vai ser o valor da pilha No* create_node(char *tipo,char *valor,int linha, int coluna){ No* node = (No*) ...
C
/* * web_thing_action.c * * Created on: Nov 22, 2019 * Last update: Apr 2, 2021 * Author: kz * email: krzzurek@gmail.com */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "common.h" #include "simple_web_thing_server.h" #include "web_thing.h" #include "web_thing_action.h" char TRUE...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* mouse.c :+: :+: :+: ...
C
#include "head.h" #define GOT_SHOT 1 /* Функция check выполняет проверку победил ли игрок * если находит не побитое поле возвращает 1, для * продолжения игры * */ int check(char opponent_field[10][10]) { for(int i = 0; i < 10; i++){ for(int j = 0; j < 10; j++){ if(opponent_field[i][j] == 1) return 1; ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* checker.c :+: :+: :+: ...
C
#include <stdio.h> #include <string.h> #include <stdbool.h> int getpos (int p[4][100005], int i, int l, int val, int k) { if (k == l) return -1; while (p[i][k] < val) { k++; if (k == l) return -1; } return k + 1; } int main (void) { char a[100005]; scanf ("%s", a)...
C
/* * * El programa lee el archivo .txt creado por el programa * de introducción. * */ #include<stdio.h> #include<stdlib.h> int main() { FILE *archivo; int c; char direccion_arch[]="/home/king/PROGRAMACION/C/PROGRAMACIÓN 2/3 - Manejo de archivos/data/intro.txt"; archivo=fopen(direccion_arch,"r"); printf...
C
/* NOTAS DA AULA Um cdigo de IA tem que possuir trs regies bem divididas: - ENTRADA: leitura de dados, no caso do rob, sensores - PROCESSAMENTO: uso dos dados na determinao de uma sada - SAIDA: decises */ #include <stdio.h> #include <stdlib.h> #include <windows.h> #include <time.h> typedef s...
C
/** * @file binson_parser_init.c * * Description * */ /*======= Includes ==========================================================*/ #include <stdarg.h> #include <stddef.h> #include <stdio.h> #include <float.h> #include <string.h> #include "binson_defines.h" #include "binson_parser.h" #include "utest.h" /*===...
C
#include <sys/types.h> #include <sys/wait.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> int main(){ int n; // track of num byttes read int x,y; // Variables int fd[2]; // holds fds of both ends of pipe pid_t pid; // PID of Child Process //Create pipe if (pipe(fd) < 0){ perror("p...
C
#include<stdio.h> main() { int i,n,sum=0; printf("enter the value of n\n"); scanf("%d",&n); while(i<=n) { sum=sum+i*i; i=i+2; } printf("total of series of %d",sum); rturn 0; }
C
/*This program shows reallocation of memory when needed*/ #include<stdio.h> #include<stdlib.h> int main() { int *marks=(int *)malloc(3*sizeof(int));//Initially 3*4bytes allocated... int mark,i,size=3,n=0; printf("Enter the marks(enter -1 to stop):\n"); scanf("%d",&mark); while(mark!=-1) { if(n>=size) { si...
C
#include <stdio.h> int main() { int a[1000],b[1000],c[2000],n,m,i,j; printf("How many elements in the list first and second array:"); scanf("%d %d",&n,&m); for(i=0;i<n;i++) { scanf("%d",&a[i]); } for(i=0;i<m;i++) { scanf("%d",&b[i]); } prin...
C
/*---------------------------------------------------------------------- * * GBA Program * * Author: Himanshu Pandey *--------------------------------------------------------------------*/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "GBA_basics.h" typedef enum { ...
C
#include <stdio.h> int main() { int a[2] = {0,}; int b[2] = {0,}; int c[2] = {0,}; int mid[2] = {0,}; scanf("%d %d", &a[0], &a[1]); scanf("%d %d", &b[0], &b[1]); scanf("%d %d", &c[0], &c[1]); // find correct order of indices float distance1 = (a[0] - b[0])*(a[0]-b[0]) + (a[1] - b[1])*(a[1]-b[1]); float dis...
C
#include <stdio.h> #include <math.h> #include <time.h> #include <stdlib.h> union End{ char string[4]; int n; }; void main(){ union End var; printf("Digite uma frase de 3 letras: "); fgets(var.string,4,stdin); printf("\nO numero inteiro da união e: \n0x%x", var.n); }
C
#ifndef FILTER_RES_H #define FILTER_RES_H /* * Start Header Creation: dsp.h */ /* %dsp.h% */ /** * Notch filter constant. * @a, b, c, d: Filter constants. */ struct dsp_notch_t { double a, b, c, d, g; }; /** * Calculate the filter constant. * @rate: The rate. * @freq: The frequency. * @k: The re...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> void menu(); char intcheck(char a[100]){ if (a[0]=='1' ||a[0]=='2') return a[0]; else return 'f'; } void ara(){ system("cls"); char s[10],a[100],code[10],c=0; printf("Please Enter a Serching tags :"); scanf...
C
#include <stdio.h> #include <math.h> int main(void) { double x = 2.714; double y = 0; // 10を底とする対数の計算 y = log(x); // 計算結果の表示 printf("y=%f", y); return 0; }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_dtoa.c :+: :+: :+: ...
C
#include "interpret.h" int PrettyStandard(Tableau *tab,char *BufferStandard){ strcat(BufferStandard,tab->mot); strcat(BufferStandard," "); tab=tab->suivant; while(tab->Codeword!=7){ strcat(BufferStandard,tab->mot); tab=tab->suivant; } return 0; } int PrettySource(Tableau *tab,char *path){ FILE * out...
C
#include "lib.h" #include <stdio.h> #include <math.h> #define WIDTH 800 #define HEIGHT 600 #include <string.h> char pixels[WIDTH * HEIGHT * 3]; float slope = 0; void set_pixel(char *data, int x, int y, char r, char g, char b) { if(x >= WIDTH || y >= HEIGHT) return; data[(WIDTH * 3) * y + (x * 3)] = r; da...
C
#include <inttypes.h> #include <stdio.h> #include <stdlib.h> #include <string.h> extern void magic_function(); char* p1; int main (void){ char x = 0; p1 = &x; int bytes = (2048*2048); for (int i = 0; i < bytes; ++i){ *(p1-i-1) = 0; } // https://stackoverflow.com/questions/2814188/c-array-of-pointers-del...
C
#include <ti/devices/msp432p4xx/driverlib/driverlib.h> #include "homework4.h" #include "myGPIO.h" #include <stdlib.h> int main(void) { char rChar; const char *response = "\n\n\r2534 is the best course in the curriculum!\r\n\n"; bool finished; //from FSM function // TODO: Declare the variables that ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <dirent.h> void Error() { fprintf(stderr, "Error: ls, file does not exist.\n"); } void SyntaxError(char *in) { fprintf(stderr, "Syntax Error: %s\nUse: ls [options] [directory] \nOptions: -a, -1, -a1 or -1a\n", in); exit(1); } int ma...
C
/* main.c _______ created by hasan, Role, Control the other part of the game, Created on 2020/8/23 Last Edit 2020/8/23 */ // Including #include <stdio.h> #include <stdlib.h> #include <SDL/SDL.h> #include <SDL/SDL_image.h> #include "constants.h" #include "game.h" #include "editor.h" #include "files.h" // main func...
C
#include<stdio.h> #define DEBUG 1 void mergeSort(int *arr1,int *arr2,int *space) //arr1 and arr2 must ended with '\0',the result is also ended with '\0' { while ( ((*arr1) != '\0') && ((*arr2) != '\0')) { if ( (*arr1) < (*arr2) ) { *space=*arr1; arr1++;space++; } else { *space=*arr2; arr2++;space++; ...
C
/* * countLiveNeighbor * Inputs: * board: 1-D array of the current game board. 1 represents a live cell. * 0 represents a dead cell * boardRowSize: the number of rows on the game board. * boardColSize: the number of cols on the game board. * row: the row of the cell that needs to count alive neighbors. * col: t...
C
#include <stdio.h> #include <stdlib.h> int main() { int dec=1, cre=1, min, max, count, n, hi, lo; printf("\nInserisci il numero min di valori: "); scanf("%d", &min); fflush(stdin); printf("\nInserisci il numero max di valori: "); scanf("%d", &max); fflush(stdin); for(count=0; count<max;...
C
#include <stdio.h> #include <string.h> #define MAXN 25 char grid[MAXN][MAXN]; int visited[MAXN][MAXN]; int h, w; int country_table[30]; void dfs(int r, int c, char lang); int main() { int t, i, j, t_idx = 1; scanf("%d", &t); while (t--) { scanf("%d %d", &h, &w); for (i = 0; i < h; i++) sca...
C
#include<stdio.h> #include<string.h> #include<stdlib.h> #include <sys/dir.h> extern int alphasort(); // built in sorting function int main(int argc,char **argv) { int count, // to count num files in pwd i; // to use in for loop struct direct **fileList; if(argc != 1) { // s...
C
#include <stdio.h> #define SGN(X) (((X) < 0) ? -1 : (((X) > 0) ? 1 : 0)) #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) #define MAX(X, Y) (((X) > (Y)) ? (X) : (Y)) #define AVG(X, Y, Z) (((X) + (Y) + (Z)) / 3) #define ABS(X) (((X) < 0) ? (-1)*(X) : (X)) int main(int argc, char **argv) { printf("%i\n", SGN(-10)); printf(...
C
#include <stdio.h> #include <stdlib.h> #include "queue.h" queue_t* create_queue(int cap) { queue_t *q = (queue_t*) malloc(sizeof(queue_t)); q->front = -1; q->rear = -1; q->capacity = cap; q->arr = (int *) malloc(cap*sizeof(int)); return q; } void enqueue(queue_t *q, int val) { if ((q->rear + 1) % q->capacity...
C
/*-----------Implementacion de la funcion parpadio-------------*/ /*envia un char al arbino para prender un lep rojo o verde segun segun*/ /* REUTILIZACION DE CODIGO!!! * ============================================================================ * * NOMBRE : 2_send_char.c * AUTOR ...
C
// least recently used #include "cache_base.h" #include "linked_list.h" // double linked list typedef struct lru_node { bool cached; UINT filesize; UINT hits; // hits since NOT cached ULONG req; // total cached requests ULONG traffic; // total cached traffic struct lru_node* prev; struct lru_node* next; } lru_n...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <windows.h> main() { char teste[20]="Teste"; char *p; printf("Procurando por e \n"); p=strchr(teste,'e'); printf("Enconteri e em %d \n", p -teste +1); /* O Proximo*/ p=strchr(p+1, 'e'); printf("Encontrei o prox e...
C
#include "holberton.h" /** * _isdigit - Checks for digit character * @c: - The character to be checked * Return: 1 for digit, 0 for anything else */ int _isdigit(int c) { if (c >= 48 && c <= 57) return (1); else return (0); }
C
/* Function sum (accidentally) modifying the original array data. Lecture: IE-B1-SO1 (Software construction 1) Author: Marc Hensel */ #include <stdio.h> int sum(int[], int); int main(void) { int a[] = { 20, 1, 6, 4 }; int size = sizeof a / sizeof a[0]; printf("Sum of all elements (1st call): %d\n", sum(a, size))...
C
#include "console.h" void displayCursor(const HANDLE handle, const bool isDisplay) { CONSOLE_CURSOR_INFO info; info.bVisible = isDisplay; info.dwSize = sizeof(info); SetConsoleCursorInfo(handle, &info); } void setConsoleTitle(const char *const title) { SetConsoleTitle(title); } void initConsole()...
C
#include <stdio.h> #include <stdint.h> #include <stddef.h> typedef struct node_s_int node_t_int; typedef struct node_s_double node_t_double; struct node_s_int { int data; node_t_int *next; node_t_int *prev; }; struct node_s_double { double data; node_t_double *next; node_t_double *prev; }; t...
C
//Write a C main() program //int main(int argc, char *argv[]) This program has two optional command //line argument, “-d” (indicating duplicate) and “-u” (indicating uppercase). //As we did in class these may be combined in several ways (search for “pink and //yellow” in the lecture notes). Your program reads character...
C
#include<stdio.h> #include<stdlib.h> #include<stdbool.h> //include this header to use bool datatype in c int temp; swap(int *big,int *small){ //swap ar[j] with ar[j+1] temp=*big; *big=*small; *small=temp; } void bubbleSort(int ar[], int n){ bool swapped; int i,j; for(i=0;i<n-1;i++){ swapped=false; for(j=0;j<n...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <dirent.h> #include<sys/types.h> int infection_check (char filename[]) // cause seg fault { char taint[] = "simple virus"; char inff_strings[200]; char string_command [200]; char grep[]="| grep virus > /tmp...
C
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<string.h> #include<stdlib.h> #include "LinkList.h" typedef struct Persion { int id; char name; }Persion; void myprint(void* p) { Persion* pt = (Persion*)p; printf("name = %c, id = %d\n", pt->name, pt->id); } int mycompare(Persion* p1, Persion* p2) { if ...
C
// // Created by sudar on 2/18/2018. // #include "SmurfBuslib.h" Bus_t * Read_Bus_info (int index ) { /* * создаем возвращаемый указатель * выделяем место под этот элемент */ Bus_t * bus = ( Bus_t * )malloc( sizeof( Bus_t ) ) ; bus->driver = ( char * )malloc( sizeof( char ) * 20 ) ; ...
C
#include <stdlib.h> #include <GL/glut.h> #include <math.h> #define TotalPoints 12 GLfloat win; GLfloat Points[TotalPoints][2] = { {2, 2.5}, {2, 4.5}, {1, 4.5}, {2, 6}, {2.2, 6}, {2.2, 7}, {4, 7}, {4, 6}, {6.5, 6}, {7.5, 4.5}, {6.5, 4.5}, {6.5, 2.5}, {2, 2.5} }; void scale(int key) { float s...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* tokenize.c :+: :+: :+: ...
C
#include "eli.h" #include "line.h" #include "action.h" #include "buffer.h" #include <ncurses.h> #include <stdlib.h> #include <string.h> #define SIZE(x) (sizeof (x) / sizeof *(x)) #define CTRL(chr) (chr & 037) // Modal Actions static struct Action normal_actions[] = { { CTRL('s'), writefile, NORMAL }, { CTR...
C
#include <stdio.h> #define C_PER_I 2.6 #define I_PER_F 11.0 int main(void) { int cm, feet; float inch; printf("Enter a height in centermeters: "); scanf("%d", &cm); while (cm > 0) { inch = (float) cm / C_PER_I; feet = inch / I_PER_F; inch = inch - feet * I_PER_F; printf("%.1f cm = %d feet, %.1f inches\n...
C
/* * SPMD example using PVM 3 * also illustrating group functions */ #define NPROC 8 #include <stdio.h> #include <sys/types.h> #include "pvm3.h" int main() { int mytid; /* my task id */ int tids[NPROC]; /* array of task id */ int me; /* my process num...
C
#include<stdio.h> #include<stdlib.h> struct Date{ int day; int month; int year; }; struct Address{ int flatNo; char city[100]; char state[100]; }; struct Employee{ char name[100]; int empId; struct Date dat; struct Address add; }; int main() { struct Employee e; //Finding size of structure int size; size=sizeof(...
C
#include <stdio.h> #include <string.h> #include <strings.h> #include <stdlib.h> #include <unistd.h> #include <sys/socket.h> #include <sys/types.h> #include <netdb.h> #include <netinet/in.h> #include <arpa/inet.h> #include <errno.h> #define BUFFER_SIZE 256 int main(int argc, char **argv) { int debug; c...
C
#include <pthread.h> #include <stdio.h> #include <stdlib.h> #include "limits.h" unsigned int prime; void *runner(void *param); int main(int argc, char *argv[]) { pthread_t tid; pthread_attr_t attr; puts("Please enter a number."); scanf("%u", &prime); pthread_attr_init(&attr); pthread_create(&tid,&attr,runner,N...
C
#include"file_sys.h" #include<stdio.h> #include"memory.h" #include"stdarg.h" #include"kernel.h" struct buffer_head * hash_table[NR_HASH]; static struct buffer_head * free_list; static struct task_struct * buffer_wait = 0; static struct buffer_head * first_buffer; int NR_BUFFERS = 0; // ٻʼ void buffer_ini...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> int main(int argc, const char *argv[]) { int fd; int data; fd = open("/dev/adc", O_RDWR); if (fd < 0) { perror("open"); exit(1); } while(1) { read(fd, &data, sizeof(data)); printf("Vol: %0.2fV\n", 1.8 * data / 4096); usleep...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct{ char numeros[200]; }telefones; telefones Telefones[100000]; int Comparacao(const void *p1, const void *p2){ telefones *i = (telefones *)p1, *j = (telefones *)p2; return strcmp(i->numeros, j->numeros); } int main(){ int N, i, j, contador;...
C
#include "main.h" /* ===================================================================== ============= || USAGE FUNCTIONS FOR EXTERNAL CALLS || ============== ===================================================================== */ // global variables #define DATA_SIZE 20 int display_N_values_per_line = 5...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* handle_width.c :+: :+: :+: ...
C
/* Projecto feito por: Henrique Alves Pocinho Nº99952 Rodrigo Pereira Nº100080 Wargame */ #include <stdio.h> #include <stdlib.h> #include <getopt.h> #include <math.h> #include <time.h> /* *Nome da funcao: textoAjuda * *Objetivo da funcao: Imprime o texto de ajuda em caso de erro */ void textoAjuda(){ printf("...
C
// Author: Erwin Ouyang // Date : 15 Dec 2018 #include <stdio.h> #include <stdint.h> uint32_t *mult_mm2s_p; uint32_t *mult_s2mm_p; int main() { // *** Pointer to AXI MM2S and S2MM *** mult_mm2s_p = (uint32_t *)0x40000000; mult_s2mm_p = (uint32_t *)0x41000000; // *** Multiply 1 word *** *(mult_mm2s_p+0) = 0x90...
C
/* * ===================================================================================== * * Filename: photons_hw5_task1.c * Usage: ./photons_hw5_task1.c * Description: Sterling photons_hw5_task1.c * * Version: 1.0 * Created: 02/14/2017 04:37:58 PM * Compiler: gcc -W...
C
#include <stdlib.h> #include <math.h> #include "arrays.h" double* arr_cpyArray( const unsigned int len, double* a, const double* b ) { unsigned int i; for( i = 0; i < len; ++i ) { a[i] = b[i]; } return a; } double* arr_addScalar( const unsigned int len, double* a, const double s, const...
C
#include <stdio.h> int main() { int num = 0, remainder = 0; // while -1 not entered... while(num != -1) { // prompt user for input printf("Enter an integer (-1 to stop): "); // read and store input, then modulus by 2 scanf_s("%d", &num, sizeof(int)); // ready to stop if -1 else... if(num != -1) { remainder...
C
#include "../../../libc/include/stdio.h" #include "../../../libc/include/system.h" #include "../../include/kernel/pit.h" #include "../../include/kernel/irq.h" uint32_t tick = 0; void pit_callback() { tick++; } void init_timer(uint32_t frequency) { register_handler(IRQ0, &pit_callback); uint32_t divisor...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #define MAX 4 struct ficha { char nome[40]; char telefone[20]; int valido; //ser usado para excluso }; void compactar(struct ficha vetor[], int *N) { int i = (*N) - 1; int j = 0; while(j < i) { while(vetor[j].valido == 1) ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* joep.c :+: :+: :+: ...
C
#include "queue.h" #include <stdlib.h> #include <string.h> #include <stdio.h> int enqueue(struct studentqueue *q, const char *name) { int nameLength = 0; while(q->next != NULL) q = q->next; const char* nameCopy = name; while(*nameCopy++) nameLength++; struct studentqueue* newNode = ...
C
#include "compute.h" #include <stdio.h> void ReadNumberFile(char *filename, float effort) { FILE *inputfile; /* Read from inputfile */ /* printf ( "Opening file %s \n", filename); */ inputfile = fopen (filename, "r" ); if ( inputfile != NULL) { printf("Reading from %s...\n", filename); ...
C
/* * LED.c * * Created on: Sep 6, 2021 * Author: Omar */ #include "LED.h" void LED_init(uint8_t port_name,uint8_t pin_num) { DIO_init(port_name, pin_num); } void LED_on(uint8_t port_name,uint8_t pin_num) { DIO_set(port_name, pin_num); } void LED_off(uint8_t port_name,uint8_t pin_num) { DIO_reset(port_name...
C
#include <stdio.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include <time.h> int main(int argc, char **argv) { struct timeval *time; struct hostent *host; char buf[256]; time_t when; struct tm *tm; if(!argv[1]) exit(1); host = gethostbyname(argv[1]); if(!hos...
C
#include <stdio.h> int square (int numero){ printf ("O quadrado de %d eh %d\n",numero,(numero*numero)); return 0; } int main (){ int numero; printf ("Entre com um numero: "); scanf ("%d",&numero); printf ("\n"); square(numero); return 0; }
C
// Un archivo binario PRODUCTOS.DAT contiene la información de los productos vendidos en un supermercado, // consistentes en código de artículo(int), proveedor(char de 30) y precio(float). // // En otro archivo binario AUMENTOS.DAT se encuentra un vector de estructuras conformadas por: // nombre de proveedor(char de 30...
C
#include "raycast.h" int rgb_mod(float mod, int rgb) { int color; Uint8 r_s; Uint8 g_s; Uint8 b_s; r_s = (0.f - ((rgb >> 16) & 0xFF)) * mod + ((rgb >> 16) & 0xFF); g_s = (0.f - ((rgb >> 8) & 0xFF)) * mod + ((rgb >> 8) & 0xFF); b_s = (0.f - (rgb & 0xFF)) * mod + (rgb & 0xFF); color = ((((r_s & 0xFF) << 16))...
C
#include <stdlib.h> #include <stdio.h> #define max 20 typedef struct nodo{ int dato; struct nodo *izq,*der; }nodo; typedef nodo *TArbol; typedef struct nodoL{ int etiqueta; //indice en el vector de cabeceras int costo; int arbol; //booleano, inidica si la arista pertenece al arbol generador stru...
C
/* Implementation of a buddy allocator. * * To use, fill out a buddy_allocator struct to the desired granularity and * size. Calling buddy_sizerequired() will return the size of the block of * memory required to initialize the allocator. Then use buddy_init() on the * struct and the address of the block of mem...
C
/* * Demonstrate a simple buffer overflow attack */ #include <stdio.h> #include <stdlib.h> /* * A function that is never called! */ void not_used(void) { printf("I am never here!\n"); exit(1); } /* * Function to read an array and return the product of * all the elements in the array. */ long serial_mu...
C
/* * @Author: Zazu * @Date: 2018-12-22 11:49:44 * @Git: https://github.com/Zazu979 * @Last Modified by: Zazu * @Last Modified time: 2019-03-08 17:14:20 */ #include <stdlib.h> #include <stdio.h> #include <stdint.h> #include <zlib.h> #include <compression.h> uint32_t getFileLength(char* filename){ FILE* ...
C
#include "ring_buffer.h" #include <stdio.h> int main(int argc, char *argv[]) { int first = 1; int second = 2; int third = 3; int fourth = 4; int fifth = 5; ringbuff_t *rb = ring_buffer_create(5); printf("Adding item 1\n"); ring_buffer_add(rb, &first); printf("Adding item 2\n"); ring_buffer_a...
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> int main(int argc , char *argv[]) { //socket的建立 int sockfd = 0; FILE * file_to_send; int count1=1,count2=1, percent; char toSEND[1]; ...
C
#include <stdio.h> #include <stdlib.h> #include "socios.h" #include "autores.h" #include "libros.h" #include "prestamos.h" #include "funcionesGet.h" #define CANTIDAD_PRESTAMOS 10 #define CANTIDAD_LIBROS 7 #define CANTIDAD_SOCIOS 8 #define CANTIDAD_AUTORES 7 int main() { int opcion; eSocio arraySocios[CANTIDAD...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_printf.c :+: :+: :+: ...
C
#include <stdio.h> int main() { printf("Oct\tDec\tHex\tChar\n"); char c = 0; for (int i = 0; i < 128;i++) { printf("%03o\t%-3d\t%02x\t%C\n", c, c, c, c); c++; } return 0; }
C
#include "holberton.h" /** * non_interact - This function get command line a through arguments of main. * @av: Pointer to strings with all arguments of input in each postiion. * Return: void. **/ void non_interact(char **av) { char error_msg[100]; sprintf(error_msg, "%s: 0: Can't open %s\n", av[0], av[1]); wri...
C
#include<stdio.h> #include<stdlib.h> #define max 30 #define maxsize 100 //ˣȸ˵(ĶܲԾνˣǸͺ) typedef struct BTree{ char data; struct BTree *lchild,*rchild; }BTree; typedef struct CTNode{ char data; struct CTNode *next; }CTNode; typedef struct CTBox{ char data; CTNo...
C
#include<stdio.h> int main(){ /*int i=1; printf("%20.d\n",i); printf("%17.d %d\n",i,i+1); printf("%14.d %d %d\n",i,i+1,i+2); printf("%11.d%6.d%7.d%8.d\n",i,i+1,i+2,i+3);*/ int i,n,j; printf("Enter any number : "); scanf("%d",&n); for(i=1;i<=n;i++){ for(j=...
C
// PROBLEM // Given an array of even size, task is to find minimum value that can be added to an element so that array become balanced. An array is balanced if the sum of the left half of the array elements is equal to the sum of right half. // CODE // #include<stdio.h> #include<stdlib.h> int main() { int t,n,i...
C
#include "server.h" #include "../parser/request_parser.h" static int id_counter = 10; client_t *clients[MAX_CLIENT]; void startServer() { int server_fd, new_socket, addrlen; int opt = 1; struct sockaddr_in server, client; pthread_t client_thread; printf("CREATING SERVER SOCKET..."); // creat...
C
#include <omp.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <sys/time.h> double start_time, end_time; #define SIZE 10000 /* maximum matrix size */ #define MAXVALUE 99 int matrix[SIZE][SIZE]; int main(int argc, char *argv[]) { int i, j, maxV = -1, minV = MAXVALUE + 1, maxR, maxC, minR, min...
C
#include "get_next_line.h" char *string2hexString(char* input) { int loop; loop = 0; while(input[loop] != '\0') { printf("%02X", input[loop]); loop++; } return (NULL); } int ft_str_fd(char **str, char **line, int fd, int res) { int i; char *src; i = 0; while (str[fd][i] != '\n' && str[fd][i]...
C
#include <stdio.h> #include <stdlib.h> //指针与一维字符数组 void change(char* p) { *p = 'H'; p[1] = 'E'; *(p + 2) = 'L'; } int main() { char c[10] = "hello"; change(c); puts(c); system("pause"); }
C
#include <avr/io.h> #include <avr/interrupt.h> #include <avr/sleep.h> #include <util/delay.h> #include "bit_tools.h" #include "printf_tools.h" #include "scheduler.h" /* assuming 16 bit ints... */ unsigned char rand() { static unsigned int seed; seed = 181 * seed + 359 ; return (seed >> 8); } ...
C
#include <stdlib.h> typedef struct Node { DATA data; struct Node* next; } ChainListType; ChainListType* ChainListAddEnd(ChainListType* head, DATA data); //ӽ㵽ĩβ ChainListType* ChainListAddFirst(ChainListType* head, DATA data); //ӽ㵽ײ ChainListType* C...
C
/* *FileName: hc89f0541_delay.c *Author: CGN *Version: 1.00 *Date: 2019.10.05 *Description: */ #include "hc89f0541_delay.h" void delay_ms(unsigned int t){ unsigned int temp; for(;t > 0;t --) for(temp = 1596;temp > 0;temp --); } void delay_us(unsigned int t){ t = t >> 1; while(t--); }
C
#include <stdio.h> void main() { puts("-------------Simple Calculator-------------"); int num1,num2,addition,subtraction,multiplication,division,rem; double percentage,partvalue,total; printf("Enter First Number: "); scanf("%d",&num1); printf("Enter Second Number: "); scanf("%d",&num2); printf("Enter P...
C
//https://www.hackerrank.com/challenges/jumping-on-the-clouds-revisited #include <math.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <assert.h> #include <limits.h> #include <stdbool.h> int main(){ int n; int k; scanf("%d %d",&n,&k); int *c = malloc(sizeof(int) * n); for(i...
C
#include <stdio.h> #include <stdlib.h> struct tempo{ int hora; int minutos; int segundos; }; void main(){ struct tempo horas[5]; int i = 0, maiorHora[3]; for (i = 0; i < 5; i++){ printf("Hora: \n"); scanf("%d",&horas[i].hora); printf("Minutos: \n"); scanf("%d",&horas[i].minutos); ...