language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> #define M 1000 int a[M][M]; int main(void){ int n,i,j,max,x, y; scanf("%d",&n); for(i = 0; i <n; i++){ for(j = 0; j< n; j++) scanf("%d",&a[i][j]); } max = a[0][0]; x = 1; y = 1; for(i = 0; i < n; i++){ for(j = 0; j < n; j++){ ...
C
#include "pop_ext.h" int32_t StripCR(line) char *line; { char *ptr; if(ptr = strchr(line,'\n')){ *ptr = '\0'; return(1); } else { return(0); } } /* ** read spikes into individual spike arrays rather than ** binning them */ int32_t LoadSpikes(fp,result,clusterid) FILE *fp; Result *result; int32_t clust...
C
#ifndef _STRMCH_ #define _STRMCH_ #include <string.h> int strmch_rk(char first[], char last[]) { int first_len = strlen(first), last_len = strlen(last), t = 1, l1 = 0, l2 = 0; for(int i = 0; i < last_len - 1; i++) t = (t * 0xff) % 123; for(int i = 0; i < last_len; i++) l1 = (l1 * 0xff + first[i]) % 123, l2 = ...
C
/* Chris Zehr COP 3223C- 15Fal 0R04 Program 6 12/12/2015 */ /* Headers, Definitions, and Structs */ #include <stdio.h> #include <time.h> #include <stdlib.h> #include <string.h> //Number of items in game #define NUM_ITEMS 6 //Item enumeration enum Item { BLANKET, SADDLE, JACKET, HARNESS, GOGGLES, ...
C
#include <sys/syscall.h> #include <sys/wait.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> struct ancestry { pid_t ancestors[10]; pid_t siblings[100]; pid_t children[100]; }; #define __NR_cs3013_syscall2 378 int main(int argc, char *argv[]) { int a = 0; int s = 0; int c = 0; if (argc != 2) {...
C
#ifndef __INC_CONFERENCE_H__ #define __INC_CONFERENCE_H__ #include <sqlite3.h> #include "data_list.h" #include "bowls.h" #include "team.h" #define CONFERENCE_TEAM_SENTINEL { -1, -1 } #define CONFERENCE_STATS_SENTINEL { -1, -1, bg_None, -1, -1, -1, -1, -1, -1, -1, -1 } #define CONFERENCE_ACCOLADE_SENTINEL { -1,...
C
#include <stdio.h> #include <fcntl.h> #include <sys/file.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #include <errno.h> #include <stdlib.h> #include <string.h> int main() { int rdfd, n; char buff[256]; while(1) { while((rdfd = open("NP1", O_RDONLY)) == -1) { printf("Cannot read...
C
#include <stdio.h> #include <stdint.h> #include <inttypes.h> inline uint64_t rdmsr(uint32_t msr_id) { uint64_t msr_value; asm volatile ( "rdmsr" : "=A" (msr_value) : "c" (msr_id) ); return msr_value; } void show_smram() { uint64_t rdmsr1 = rdmsr(0xc0000010); uint64_t rdmsr2 = rdmsr(0xc0010111); ...
C
#include <stdio.h> int main(void) { int w; int h; printf("ڡڡڡڻ簢 ϱڡڡڡ\n\n"); printf("ʺ Է:"); scanf_s("%d", &w); printf(" Է:"); scanf_s("%d", &h); printf(" = %d\n", w*h); system("pause"); return 0; }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* option.c :+: :+: :+: ...
C
#include "libft.h" /** * compares n bytes of memory chunks. returns 0 if the parcels are identical. * returns 1 if differing bytes and * s1 > * s2 are encountered. otherwise -1 **/ int ft_memcmp(const void *s1, const void *s2, size_t n) { size_t i; unsigned char *ss1; unsigned char *ss2; i = 0; ss1 = (unsigned ...
C
#include "lecture.h" /*BUT : -Lire le document de donnée afin d'extraire et reconnaitre ACr, DCr, ACir et DCir -Recadrer les composantes alternatives ACr et ACir autour de 0 -retourne struct type absorp(.acr, .acir, .dcr et .dcir) -ignore les lignes corrompues ->à la fin de la lecture du fichier la variable d'état pa...
C
#include<stdio.h> #include<stdlib.h> typedef struct nodo{ int n; struct nodo *next; }nodo; void imprime_lista(nodo *head); nodo* final (nodo *head); void adiciona(nodo *head,int valor); void elimina(nodo *head, int v); int main(int argc, char const *argv[]) { int x; nodo *head = (nodo*) malloc(sizeof(nodo)); ...
C
// // Created by lukas on 10.01.2019. // #ifndef STACK_H #define STACK_H typedef struct StackNodeStruct { void * value; struct StackNodeStruct* node; } StackNode; typedef struct { StackNode* node; unsigned int size; } Stack; // Prototypes StackNode* stack_node_create(void*, StackNode*); void stack_n...
C
#include "xlq_common.h" #include <stdio.h> #include "redismodule.h" int no = 0; int addNum = 0; int delNum = 0; void* xlq_malloc(size_t _size) { no++; addNum++; return RedisModule_Alloc(_size); } void* xlq_calloc(size_t __nmemb, size_t __size) { no++; addNum++; return RedisModule_Calloc(__nmemb, __size); } v...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_next_line.c :+: :+: :+: ...
C
#include <sys/types.h> #include <sys/socket.h> #include <iostream> #include <string> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <netdb.h> #include <time.h> #include <stdint.h> using namespace std; int64_t nano_count() { struct timespec t; int ret; ret = clock_gettime(CLOCK_MONOTONI...
C
#include <stdio.h> #include <unistd.h> #include <signal.h> #include <stdlib.h> void handler(int sig); int main(int argc, char* argv[]) { signal(SIGINT,handler); printf("SLeep begins!!\n"); sleep(1000); printf("Wake up!"); return 0; } void handler(int sig) { if(sig == SIGINT) printf("Handler is called.\n"); ...
C
/*-------------------------------------------------------------------------* *--- ---* *--- prof.c ---* *--- ---* *--- ---- ---- ---- ---- ---- ---- ---- ---- ---* *--- ---* *--- Version 1a 2020 February 2 Joseph Phillips ---* *--- ---* *---------------------------------...
C
#include <stdio.h> int soma(); int main(int argc, char const *argv[]) { int N = 6, somatorio = 0; somatorio = soma(N); printf("%d\n",somatorio ); return 0; } int soma(int n){ int s; if (n==0) return 0; else s = n + soma(n-1); return s; }
C
#include <stdio.h> #include <string.h> int majorityElement(int* nums, int numsSize){ int max = 0; int index = -1; for(int i = 0; i < numsSize-1; i++){ int count = 0; for(int j = i+1; j < numsSize; j++){ if(nums[i] == nums[j]){ count++; } } ...
C
#include <stdio.h> int main(){ int n; while(scanf("%d",&n)!=EOF){ int max = 0, len = 0, last = -1; while(n != 0){ if(n & 1 == 1){ if(last == 1) len++; else len = 1; max = max > len ? max : len; } last = n & 1; n >>= 1; } printf("%d\n", max); } retu...
C
#include <types.h> #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <vfs/fs.h> #include <kserv.h> #include <syscall.h> static int start_vfsd() { printf("start vfs service ... "); int pid = fork(); if(pid == 0) { exec("/sbin/vfsd"); } kserv_wait("kserv.vfsd"); printf("ok.\n"); return 0; } ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> #include "zmalloc.h" #define PREFIX_SIZE sizeof(size_t) // 已锁形式增加统计 #define update_zmalloc_stat_add(_n) do{ \ pthread_mutex_lock(&used_memory_mutex); \ used_memory += _n; \ pthread_mutex_unlock(&used_memory_mutex); \ }while(0)...
C
/* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. */ #include "tomcrypt_private.h" /** @file hma...
C
#include <stdio.h> #include <stdlib.h> #include "Stack.c" int main(){ Pila *p = crearPila(); printf("\nSe van a apilar 3 elementos al stack\n"); for(int k=0;k<3;k++){ push(p, crearDatos(2*k)); printf("Valor tope: %i\n", p->tope->datos->d); } printf("\nDesapilamos los elementos\n"); while(p->tope != NUL...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* stack_making.c :+: :+: :+: ...
C
#include<stdio.h> #include<math.h> #include<string.h> long long f[1301]; void fibo(){ f[0] = 0; f[1] = 1; int i; for(i = 2; i <= 1300; i++){ f[i] = f[i - 1] + f[i - 2]; } } void bai_lam(){ int n,i; scanf("%d", &n); int kq = 0; for(i = 0; i < n; i++){ printf("%lld ", f[i]); } } int main(){ fibo(); //i...
C
#include <ApplicationServices/ApplicationServices.h> #include <stdio.h> #include<stdio.h> //printf #include<string.h> //memset #include<stdlib.h> //exit(0); #include<arpa/inet.h> #include<sys/socket.h> #define SERVER "127.0.0.1" #define BUFLEN 512 //Max length of buffer #define PORT 33334 //The port on which to se...
C
#include<stdio.h> int main() { int x,y; printf("enter x and y to calculate the sum and product : "); scanf("%d %d",&x,&y); printf("%d %d",x+y,x*y); return 0; }
C
#include <stdio.h> void prStack2(l,y,z) { printf("%2d [y:%d, z:%d]\n", l, y, z); } void prStack(l,x,y,z) { printf("%2d [x:%d, f{}, y:%d, z:%d]\n", l, x, y, z); } main() { int z; int y; prStack2(2,y,z); y = 5; prStack2(3,y,z); { int f(int *x){ prStack(4,*x,y,z); *x = *x+1; ...
C
#include "search_algos.h" /** * linear_search - search the first ocurrency of a value in the array * @array: set of numbers * @size: size of the array * @value: value to search * Return: return the first index located */ int linear_search(int *array, size_t size, int value) { size_t i = 0; if (array == NULL) ...
C
#include <stdio.h> #include <cs50.h> int main(void) { // Determine variables int height, line, space, hash; // Set height limit to 23 do { printf("Height: "); height = get_int(); } while (height < 0 || height > 23); // Print lines based on height for (line = 1; line <=...
C
#include<stdio.h> #include<locale.h> void main() { char *locale = setlocale(LC_ALL, ""); int a=77; printf(" : %d\n", a); if (a/10==4 || a%10==4) { printf (" 4 \n"); } else { printf (" 4 \n"); } if (a/10==7 || a%10==7) { printf (" 7 \n"); } else { printf (" 7 \n"); } getch(...
C
#include <cstdlib> #include <cstdio> #include <ctype.h> void *emalloc(size_t size) { void *ptr= malloc(size); if (ptr == NULL) { fprintf(stderr, "Memory allocation failed!\n"); exit(EXIT_FAILURE); } return ptr; } void *erealloc(void *ptr, size_t size) { ptr = realloc(ptr, size); ...
C
#include <stdio.h> #include <stdlib.h> int A[25][25]; void Warshall(int n) { int i,j,k; for(k=1;k<=n;k++) for(i=1;i<=n;i++) for(j=1;j<=n;j++) A[i][j]=A[i][j] || (A[i][k]&&A[k][j]); } int main() { int v,e,i,j,v1,v2; printf("Enter the number of Vertices and edges: \n"...
C
/* * NOTWORKIN.c * * Created on: Mar 28, 2016 * Author: Yongsuk */ /* * Yes.c * * Created on: 2016. 3. 24. * Author: Administrator */ #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> void swap() // ٲ㼭 { int x, y, temp; printf(" ԷϽÿ: "); fflush(stdout); scanf("%d %d", &x, &y); prin...
C
#include "../utility.h" int r_mdet0() { double a[4][4] = {{2.0,1.0,3.0,5.0}, /* 矩阵A,B,C分别赋初值*/ {2.0,2.0,-3.0,-1.0}, {2.0,1.0,7.0,2.}, {4.0,2.0,10.0,7.0} }; double b[4][4] = {{2.0,2.0,-3.0,-1.0}, {2.0,1.0,3.0,5.0}, {2.0,1.0,7.0,2.}, {1.,4.0,9.0,-2.0} }...
C
#include <sys/times.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { struct tms start = { 0 }; struct tms end = { 0 }; clock_t clc_start = 0; clock_t clc_end = 0; clock_t clc_tck = 0; if (argc != 2) { return 0; } if ((clc_start = times(&start)) < 0) {...
C
#include <stdio.h> void main() { int a=5,b=5,c=10; printf("%d==%d is %d\n",a,c,a==c); printf("%d>%d is %d\n",a,b,a>b); printf("%d>%d is %d\n",a,c,a>c); printf("%d<%d is %d\n",a,b,a<b); printf("%d<%d is %d\n",a,c,a<c); printf("%d!=%d is %d\n",a,b,a!=b); printf("%d!=%d is %d\n",a,c,a!=c); printf("%d>=%d is %d\n",a,b,...
C
#include "grafo.h" p_grafo criar_grafo(int tam){ p_grafo g; int i; g = malloc(sizeof(Grafo)); if(g == NULL) exit(1); g->adjacencia = malloc(tam * sizeof(No)); if(g->adjacencia == NULL) exit(1); g->n = tam; for(i=0; i<tam; i++){ g->adjacencia[i] = NULL;/*Seta todas as posições, da lista lig...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* rendering2.c :+: :+: :+: ...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <unistd.h> #define MAX_LEN 2000 //attention il faudra mettre une limite du nombre de caracteres utilisables #define TEXTE "France Jean-Michel DUPOND JeanDUPOND@gmail.com ID.png 02/02/2016 je n'aime pas cette photo, oui c'est une virgule! exclamation ...
C
#include "libft.h" char **realloc_tab(char **tab, char *str, int cpt) { char **dest; int i; dest = (char **)malloc(sizeof(char *) * (cpt + 1) + 1); i = 0; while (i < cpt) { dest[i] = ft_strdup(tab[i]); i++; } dest[i] = ft_strdup(str); dest[i + 1] = NULL; return (dest); }
C
#include<stdio.h> void main(){ int num; printf("Enter number: "); scanf("%d",&num); char ch; printf("Enter character: "); scanf(" %c",&ch); float num1; printf("Enter float number: "); scanf("%f",&num1); double d; printf("Enter double number: "); scanf("%lf",&d); int *nptr = &num; char *cptr = &ch; flo...
C
#include<stdio.h> struct node{ int data; struct node* next; }; struct node* head = NULL; void insert(int data,int pos){ struct node * A=head; struct node* temp = (struct node *) malloc(sizeof(struct node)); if(pos==1){ temp->data = data; temp->next = head; head = temp; return; } else{ ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strsplit.c :+: :+: :+: ...
C
#include <stdio.h> #include <string.h> #include <ctype.h> #include <math.h> #define MAX 5 int solve(int op1, char operator, int op2) { switch(operator) { case '+': return op1 + op2; case '-': return op1 - op2; case '*': return op1*op2; case '/': return op1/op2; case '^': return pow(op1, op2); case '%': ...
C
/** * The MIT License (MIT) * Copyright (c) 2016-2017 Wanding.Zhou@vai.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights...
C
/******************************************************************************* * @file Thread_LED.c * @author Auguste Lalande, Felix Dube, Juan Morency Trudel * @version 1.0.0 * @date 8-April-2016 * @brief LED thread ****************************************************************************** ...
C
#include "backtrack.h" #include "board.h" #include "bool.h" #include "checked_alloc.h" #include "list.h" #include <stdlib.h> #include <string.h> typedef struct { int idx; int value; } backtrack_state_t; static void backtrack_state_push(list_t* stack, int idx) { backtrack_state_t* state = checked_malloc(s...
C
#include <stdlib.h> #include <pthread.h> #include <unistd.h> #include <stdio.h> #include <string.h> #include <sys/time.h> #define CMPL_OPT #ifndef CMPL_OPT static volatile int glob = 0; #else static int glob = 0; #endif //#define USE_LOCK #ifdef USE_LOCK pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; #endif v...
C
#include <stdio.h> //복습할 필요가 있다고 생각함 int dp[101][100001]={0}; typedef struct{ int w; int v; } bag; int maximum(int a, int b){ if(a>b){ return a; } else{ return b; } } int main(){ int n, k, max=0; scanf("%d %d", &n, &k); bag a[n]; for(int i=0;i<n;i++){ s...
C
#include <struct.h> #include<HEADER.h> ///iJCϥ *load OebD}ɮ RorC OܿWɮ AccountNum OӪa void loadgame( FILE *load,int RorC,int accountNum) { time1=0; SCORE=0; int t,q; Sleep(1000); system("CLS"); printf("Rules :\n\n" "\t1 There will be a 5 by 5 map\n\n" "\t2 You can ...
C
/* This program change current directory in process. So, when this program terminated, return to previous location. */ #include <stdlib.h> #include <stdio.h> #include <unistd.h> void main(int argc, char *argv[]) { //check arg count. if (argc != 2) { printf("Usage: %s destination",argv[0]); exit(1); } //chan...
C
/// Gerencia a criação e manipulação da tela. /// Este módulo implementa a tela do jogo, bem /// como gerencia as operações relacioanas à ela. /// /// \file main.c /// \author Anderson, André, Cristóvão, Pedro Vítor. /// \since 11/04/16 /// \version 2.0 #include <stdio.h> #include <stdlib.h> #include <string.h> #incl...
C
#include <stdio.h> #include <Windows.h> void swap(int* x, int* y) { int temp; temp = *x; *x = *y; *y = temp; } void Sort(int a[], int n) { int i, j, temp; for (i = 0; i < n; i++) { for (j = i + 1; j < n; j++) { if (a[i] > a[j]) { temp = a[i]; a[i] = a[j]; a[j] = temp; } } } } int main() ...
C
#include <assert.h> #include <inttypes.h> #include <stdint.h> #include <stdio.h> #include <string.h> #include "../aes.h" #include "../cmac.h" uint8_t zeros[16] = {0}; uint8_t ones[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; void test_xor(void) { uin...
C
/* From wikipedia https://en.wikipedia.org/wiki/Partition_(number_theory) In number theory and combinatorics, a partition of a positive integer n, also called an integer partition, is a way of writing n as a sum of positive integers. Two sums that differ only in the order of their summands are considered the same part...
C
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> int main(void) { int age; char name[20]; printf(" Է : "); scanf("%d", &age); fgetc(stdin); // ذ => Ͱ //getchar(); printf("̸ Է : "); gets(name); printf(" : %d, ̸ : %s\n", age, name); return 0; }
C
#include <stdio.h> #include <stdlib.h> int main() { int bytes_read; size_t nbytes = 100; char *my_string; puts ("Please enter a line of text."); /* These 2 lines are the heart of the program. */ my_string = (char *) malloc (nbytes + 1); bytes_read = getline (&my_string, &nbytes, stdin); if (bytes_re...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include "../headerfile.h" double vfunc(double x_1,double x_2,double xi,double zeta) { double ans; if (fabs(zeta)< SMALL) { double x_2t2 = x_2*x_2; double x_2t3 = x_2*x_2*x_2; double x_2t4 = x_2*x_2*x_2*x_2; double x_2t5 = x_2*x_2*x_...
C
/* ============================================================================= A finite volume code to solve the Saint-Venant system in an open channel. ============================================================================= Copyright (C) 2013 Mathieu Besson This program is free software: you ...
C
#include "PowerSetString.h" void printPsetAndHashTest(Node *stack, HashMap* m) { int found,chain_position, count=0; Node *hash_entry, *item=stack; printf("\tP(S)={\n"); while(item != NULL) { printf("%d)\t\t{%s} ", count++,item->S); //Lists the number of the subset within the power set found=0; chain_...
C
#include "pthread.h" #include <stdio.h> #include <stdlib.h> #include <string.h> void *thread_function(void *arg); int flag = 1; int main(void) { int res; int count = 1; pthread_t a_thread; void *thread_result; /* ߳ */ res = pthread_create(&a_thread, NULL, thread_function, NULL); if (0 !...
C
#ifndef __RUTILS_H #define __RUTILS_H #include <math.h> #include <windows.h> #include <crtdbg.h> const float pi=3.141592654f; typedef enum {NEGATIVE= -1, ZERO= 0, POSITIVE= 1} SIGN; #define TOLER 0.0000076 #define IS_EQ(a,b) ((fabs((double)(a)-(b)) >= (double) TOLER) ? 0 : 1) #define IS_EQ3(a,b) (IS_EQ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* libft.h :+: :+: :+: ...
C
// // Created by PCHEN on 2020-03-17. // #include <pr_pool_blocklist.h> #include <pr_mem.h> #include <assert.h> //////////////////////////////////////////////////////////////////////////////// struct pr_pool_blocklink_s{ void* d_block_p; struct pr_pool_blocklink_s * d_next_p; }; typedef struct pr_pool_blocklin...
C
#include <stdio.h> int ggT(int a, int b); void test(int a, int b); int main(int argc, char* argv[]) { int a = 0, b = 0; // setze den testmodus auf 1, wenn du es nicht einlesen möchtest int testmodus = 0; if(testmodus) { printf("### TEST ###\n"); test(1, 3); test(5, 10); test(6, 9); test(1337, 1338);...
C
/* Aluminum foil has a thickness of 0.025mm. A roll is formed by tightly winding it around a tube with an outside diameter of 4cm. Given the length of the foil in cm, write a function that returns the diameter of the roll in cm measured at its thickest point. Round the result to four places. Examples foil(0) ➞ 4.0 ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> //se digitar 4, vai de 0 a 4, 4 é a 5º linha int fatorial(int n) { int fat; for (fat = 1; n > 1; n--) fat = fat * n; return fat; } int CoefBinomial(int n, int k) { int resposta; int k_fatorial, n_fatorial; n_...
C
#include "sandpiles.h" /** * print_grid - prints a matrix * @grid: 3x3 matrix */ static void print_grid(int grid[3][3]) { int x, y; for (x = 0; x < 3; x++) { for (y = 0; y < 3; y++) { if (y) printf(" "); printf("%d", grid[x][y]); } printf("\n"); } } /** * add_matrix - adds 2 matrixes togeth...
C
#include <stdio.h> #include <stdlib.h> int main(void) { int a = 2; int b; /* * Define a constant integer, so the data can never change. * Define a constant pointer, so the pointer can only point to one memory address. * Trying to change either is a compile time error. */ const int *const intPointer = &a; ...
C
/* 23 Una papelera vende libros a $100, cuadernos a $15.50 y plumas a $2.35. E.P. que determine e imprima el monto total de una venta, segn el nmero de artculos vendidos. Elaborado por: Ricardo Nicols Canul Ibarra Senaida Norely Chan Chan Javier Alejandro Chim Cem Fecha: 31/ene/2019 Version: 1.0rev Revisado por: E...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ls_maker.c :+: :+: :+: ...
C
#include <stdio.h> #include <time.h> #include <stdlib.h> void genArr(int arr[], int n){ int i; for (i = 0;i < n; i++){ arr[i] = rand()%1000+1; } } void printArr(int arr[], int n){ int i; for (i = 0; i < n; i++){ printf("%d ",arr[i]); } printf("\n"); } void shellSort(int arr[], int n){ int k = n / 2; i...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_ELEMENT_NB 10 struct element{ unsigned int id; unsigned int cnt; }; struct table{ struct element ele[MAX_ELEMENT_NB]; unsigned int nb; }; void table_init(void) { return; } unsigned int find_element(unsigned int id) { unsigned int i; for(i=...
C
#include<stdio.h> struct data { int val; short int num; float f; char name[10]; }size; int main() { struct data *ptr=NULL; ptr++; printf("%d\n",ptr); }
C
#include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <sys/types.h> #include <sys/uio.h> #define BUFFSIZE 8192 int main(){ int fdi,fdo; char buf[BUFFSIZE]; fdi = open("input.txt",O_RDONLY); fdo = open("lseekout.txt",O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH...
C
/****************************************************************************** Linked List Implementation. *******************************************************************************/ #include <stdio.h> #include <stdlib.h> /***Node structure***/ struct Node { int data; struct Node* next; }; struct ...
C
# include <stdio.h> # pragma warning (disable:4996) int getMin(int arr[], int size) { int arrmin = 999; for (int i = 0; i < size; i++) { if (arr[i] < arrmin) arrmin = arr[i]; } return arrmin; } int main(void){ int scores[5]; int size = sizeof(scores) / sizeof(scores[0]); // ߰, scores ͸ Է¹޾ƾ մϴ. int...
C
//ENGR 102 Sherry Abbasi LED on Program #include <stdio.h> #include <wiringPi.h> int main() { wiringPiSetup(); //sets up the GPIO pins based on wiringPi chart pinMode(0, OUTPUT); //defines GPIO 0 (pin11) as an output digitalWrite(0, HIGH); //sets the value of GPIO 0 (pin11) at logic 1 (3.3 V) delay(5000); //creates a d...
C
/* ** my_putstr.c for my putstr in /home/ ** ** Made by Pigot Aurélien ** Login <pigot_a@etna-alternance.net> ** ** Started on Tue Oct 21 10:38:15 2014 Pigot Aurélien ** Last update Sat Feb 14 20:12:05 2015 Pigot Aurélien */ #include <unistd.h> void my_putstr(char *str) { while (*str != '\0') { write(...
C
// #include <stdio.h> // #include <stdlib.h> // // int main() // // #define SIZE 81 // // { // // char *ui, *p; // int count, amount=80; // // ui = malloc(SIZE * sizeof(char)); // // if (str == NULL) // { // puts("Memory is full."); // exit(1); // } // // p = ui; // // fo...
C
#include <stdio.h> #include <stdlib.h> char *monthName (int month) { char *result; switch (month) { case 1: result = "Jan\n"; break; case 2: result = "Feb\n"; break; case 3: result = "Mar\n"; break; case 4: result = "Apr\n"; break; case 5: result = "May\n"; break; ...
C
/* ppmtopcx.c - read a portable pixmap and produce a PCX file ** ** Copyright (C) 1990 by Michael Davidson. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <math.h> #include "figure.h" #include "geometry.h" #include "nest_structs.h" #include "cmnfuncs.h" #include "cmnnest.h" #include "nestdefs.h" int (*checkpos)(struct Figure *currfig, struct Position *postis, int npos, double xpos, do...
C
#include "ext2_helper.c" int main(int argc, char **argv) { if(argc != 3) { fprintf(stderr, "Usage: ext2_rm <image file name> <absolute path>\n"); exit(1); } return 0; }
C
#include <stdio.h> #include <stdlib.h> struct TreeNode{ int value; struct TreeNode *left; struct TreeNode *right; }; int main(int argc, char const *argv[]) { /* code */ return 0; } //Binary Tree Operations struct TreeNode *insert(struct TreeNode *root, int value){ if(!root){ return create_TreeNode(value); ...
C
#include <string.h> #include <stdbool.h> #include <errno.h> #include "roman_error_codes.h" #include "roman_arabic_map.h" #include "roman_validator.h" int get_map_index(struct RomanArabicMap map) { for(int i = 0; i < get_maps_size(); ++i) { if (are_equal(roman_arabic_maps[i], map)) { return i; } } return -1;...
C
/* Programa: Laboratorio 04 Exercicio 4 Aluno: Marcelo Mendonca Borges Data: 12/05/2016 Descricao: Le uma matriz e verifica se ela eh simetrica */ /*Inclusao de Bibliotecas*/ #include <stdio.h> #include <stdlib.h> #include <math.h> int main () { /*Declaracao de Variaveis*/ int i, j, n, a[100][100], transp = 1...
C
// Created on Mon March 17 2014 // Natalie Reed, Gal Bejerano, Kasandra Yee, Christine Hsieh, James D // Movement for getting botguy and exercise bench SEPARATELY (bench first) #define LEFTWHEEL 2 #define RIGHTWHEEL 0 #define LIGHT 1 #define ARM 1 int start=1000; void turn90Left(); void turn90Right(); void moveForward...
C
#include "base64.h" #include "minunit.h" const char *test_b64decode(void) { const char *monkey_biz = "TW9ua2V5IEJ1c2luZXNz"; size_t outlen; char *output = b64decode(monkey_biz, strlen(monkey_biz), B64_STANDARD, &outlen); mu_assert(!strcmp(output, "Monkey Business"), "Decoded output didn't...
C
#include "auxstruct.h" Pagina inicializaPagina() { Pagina res = NULL; res = (Pagina)malloc(sizeof(NPagina)); res->titulo = NULL; res->data = NULL; res->autor = NULL; res->seccoes = createLinkedList(NULL,NULL); res->linkint = createLinkedList(NULL,NULL); res->linkext = createLinkedList(NULL,NULL); return res...
C
/* * hal_timebase.c * * Created on: Jul 9, 2016 * Author: jmiller */ #include "stm32.h" TIM_HandleTypeDef htim1; uint32_t uwIncrementState = 0; /** * @brief This function configures the TIM1 as a time base source. * The time source is configured to have 1ms time base with a dedicated * ...
C
#include "search_algos.h" /** * binary_searching - binary searching yayyy * @array: array * @left: left * @right: right * @value: value * * Return: index */ int binary_searching(int *array, size_t left, size_t right, int value) { size_t l; if (array == NULL) return (-1); while (right >= left) { printf("Searc...
C
/** Put this in the src folder **/ #include "keyboard.h" //--------Select input group-------- //#define MatrixKeyInput GPIOA //#define MatrixKeyInput GPIOB //#define MatrixKeyInput GPIOC #define MatrixKeyInput GPIOD //#define MatrixKeyInput GPIOE //--------Select output group-------- #define MatrixKeyOutpu...
C
/** ****************************************************************************** * @file bsp_beep.c * @author fire * @version V1.0 * @date 2015-xx-xx * @brief ʪȴӦúӿ ****************************************************************************** * @attention * * ʵƽ̨: STM32 F429 * ̳ ...
C
#include "buttons.h" const GPIO_TypeDef *button_gpio_ports[] = {BTN_0_GPIO_Port, BTN_1_GPIO_Port, BTN_2_GPIO_Port, BTN_3_GPIO_Port, BTN_4_GPIO_Port, BTN_5_GPIO_Port, BTN_6_GPIO_Port, BTN_7_GPIO_Port, BTN_8_GPIO_Port, BTN_9_GPIO_Port, BTN_CANCEL_GPIO_Port, BTN_DP_GPIO_Port, BTN_VOLTS_GPIO_Port, BTN_AMPS_GPIO_Port, BTN_...
C
#include "Sorter.h" #include "MergeSort.c" char* trimSpace(char* str){ int end = strlen(str) - 1; while(str[end] == ' ' || str[end] == '\n' || str[end] == '\r') { str[end] = '\0'; end--; } while(*str == ' ') { str++; } return str; } char getDataType(char* data){ if(strcmp(data, "color") == 0) re...