language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include "libmx.h" char *mx_itoa(int number) { int lenght = 0; unsigned int num = number; while (num != 0) { num = num / 10; lenght++; } char *arr = NULL; arr = mx_strnew(lenght); bool min = false; num = number; int i = 0; if (number == 0) return mx_strcp...
C
int trailingZeroes(int n) { int counter = 0; while (n > 0) { n /= 5; counter += n; } return counter; }
C
#include <stdio.h> int main(void) { int n1, n2 = 0; char cOperation; printf("Saisir un nombre suivi de l'opération puis d'un autre nombre : "); scanf("%d %c %d", &n1, &cOperation, &n2); switch(cOperation) { case '+': printf("%d + %d = %d\n", n1, n2, n1 + n2); break; case '-': printf("%d - %d = %d\n"...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(){ char *str; int temp; int result, len; int i, j; result = 0; str = (char*)malloc(sizeof(char)*16); gets(str); len = strlen(str); result += len; for (i = 0; i < len; ++i){ temp = str[i] - 'A'; switch(temp){ case 0: case 1: case ...
C
#include "stdafx.h" DWORD CRC32(BYTE* ptr,DWORD Size) { DWORD crcTable[256],crcTmp1; //̬CRC-32 for (int i=0; i<256; i++) { crcTmp1 = i; for (int j=8; j>0; j--) { if (crcTmp1&1) crcTmp1 = (crcTmp1 >> 1) ^ 0xEDB88320L; else crcTmp1 >>= 1; } crcTable[i] = crcTmp1; } //CRC32ֵ DWORD crcTmp2= 0xF...
C
#include<stdio.h> int main() { int a[]={1,2,3,4,5,6,7,8,9,10}; int even=0,odd=0; for (int i=0;i<10;i++){ if(a[i]%2==0){ even=even+a[i];} if(a[i]%2==1){ odd=odd+a[i]; } } printf("even: %d\n odd sum: %d",even,odd); return 0; }
C
#include <stdio.h> //#include <arpa/inet.h> #include <stdint.h> #define IS_BIG htons(1) == 1 #if __BYTE_ORDER == __LITTLE_ENDIAN #pragma message("__LITTLE_ENDIAN") #elif __BYTE_ORDER == __BIG_ENDIAN #pragma message("__BIG_ENDIANtemp") #endif typedef union { char a; int b; } A; #define btol16(i) ( (((uint16_t)...
C
#pragma once #include"Basics.h" void bubbleSort(int *a, int n, bool comp(int a, int b)) { for (int i = 0; i < n; ++i) { for (int j = 0; j < n - i - 1; ++j) { if (!comp(*(a + j), *(a + j + 1))) { swap(*(a + j), *(a + j + 1)); } } } return; }
C
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> int main(int argc, char const *argv[]) { int banks, debts, i, banksCpy; while(scanf("%d %d", &banks, &debts) && (banks + debts != 0)) { int* reserves = malloc(sizeof(int) * banks); banksCpy = banks; i = 0; while(banksCpy--) { scanf("%d", (rese...
C
/// solution URI problem : #1051 #include<stdio.h> int main() { float salary, tax = 0, rate, f_extra, s_extra, l_extra; scanf("%f", &salary); if(salary>=0 && salary<=2000) printf("Isento\n"); else if(salary>2000 && salary <=3000){ rate = 0.08; f_extra = salary - 2000; ...
C
//Random Number Generation //to calculate value of constant of a given pmf //problem no.-(8) #include<stdio.h> #include<math.h> int main() { FILE*fp; fp=fopen("Random number generation (8).dat","w"); int i; float p=0,c; float tot_pmf(int); for(i=5;i<=15;i++) { p=p+tot_pmf(i); } c=((float)(1))...
C
/***************************************************************************************************************** * AUTHOR: Tomer Dery * DATE: 12.02.14 ...
C
/* lowelabPfamHit.h was originally generated by the autoSql program, which also * generated lowelabPfamHit.c and lowelabPfamHit.sql. This header links the database and * the RAM representation of objects. */ /* Copyright (C) 2007 The Regents of the University of California * See README in this or parent director...
C
#include <stdio.h> #include <stdlib.h> int main() { //Comparison / Relational Operators int a, b; printf("Enter any value for a and b:"); scanf("%d %d", &a, &b); //a = 5, b = 10 printf("Equal to: %d\n", (a == b)); // 0 printf("Not Equal to: %d\n", (a != b)); // 1 print...
C
#include <stdio.h> main() { char mark='A'; switch(mark) { case 'A': case 'B': case 'C': printf(">=60\n");break; case 'D': printf("<60\n");break; default: printf("Error\n"); } }
C
#include <linux/kernel.h> #include <linux/list.h> #include <linux/module.h> #include <linux/sched.h> asmlinkage long sys_hello(void) { printk("Hello, World!\n"); return 0; } ////////////////////////////////// 7.1 /////////////////////////////// asmlinkage long sys_set_weight(int weight){ if(weig...
C
#include <stdio.h> #include <stdint.h> #include <signal.h> #include <sys/time.h> #include <math.h> #include <inttypes.h> #include <string.h> #include "timer.h" volatile uint32_t timerTicks=0; void timerHandler(void) { printf("timerticks=%d\n", timerTicks++); } int main() { if(timerInit(100, timerHandler)) { pri...
C
#ifndef __LIST_H__ #define __LIST_H__ typedef struct list{ struct list* next; void* data; } list; typedef list* list_p; typedef unsigned int bool; /* Helper routines */ list_p create_new_node(void* data); list_p list_get_tail(list_p head); void list_print(list_p head, void (*print_node_func)(list_p node));...
C
#include <stdio.h> int main () { int a=2,b=2,x,y; x=4*(++a*2+3); y =4*(b++*2+3) ; printf("a=%d,b=%d,x=%d,y=%d\n",a,b,x,y); return 0; }
C
#include <time/cc_timer.h> #include <cc_debug.h> #include <stdlib.h> #include <mach/mach_time.h> /* Note: mach_absolute_time() is essentially unit-less and should always be * used with mach_timebase_info_data_t * * For more information, see the following link: * https://developer.apple.com/library/mac/qa/qa1398/...
C
/* * tty.c * * Created on: Jun 4, 2015 * Author: lidq */ #include <kernel/tty.h> extern s_sys_var *sys_var; s_tty *tty_cur = NULL; void install_tty() { for (int i = 0; i < TTY_COUNT; i++) { sys_var->ttys[i].tty_id = i; sys_var->ttys[i].cursor_pos = 0; sys_var->ttys[i].mm_addr = alloc_mm(TTY_MEM_SI...
C
/*program name :array operations program author: rlf date:29jul2019*/ #include<stdio.h> #include<stdlib.h> int a[20],i,n,pos; void create(); void display(); void insert(); void delete(); void main() { int choice; while(1) { printf("MENU\n 1.create \n 2.display \n 3.insert \n 4.delete \n 5.exit \n"); print...
C
//Program to obtain the result of a taylor series expression: e^x = 1 + x/1! + x^2 / 2! + x^3 / 3!..... #include<stdio.h> /* double series(int x,int n) { static int p=1,f=1; int res; if(n==0) return 1; else { res = series(x,n-1); p = p*x; f = f*n; return res+...
C
#include "libft.h" void *ft_memset(void *destination, int c, size_t n) { char ch; char *str; ch = (char)c; str = (char *)destination; while (n--) *str++ = ch; return (destination); }
C
// funzione che rappresenta la mossa del primo giocatore int p1(int numero) { return numero-1; } // funzione che rappresenta la mossa del secondo giocatore int p2(int numero) { return numero-1; } // funzione che rappresenta una generica mossa di una partita di un gioco multigiocatore int mossa(int stato, int ...
C
/* ** EPITECH PROJECT, 2018 ** nf.sh ** File description: ** nf */ #include <stdlib.h> int my_strcmp(char const *s1, char const *s2) { if (!s1 || !s2) return (-1); if (s2[0] == '\0') return (-1); for (int i = 0; s1[i] && s2[i]; i++) { if (s1[i] != s2[i]) return (s2[i] -...
C
#include <stdio.h> #include <stdlib.h> int main() { int input,days,weeks,year; printf("enter input: "); scanf("%d",&days); year=days/365; weeks=(days-(year*365))/7; days=days-((year*365)+(weeks*7)); printf("YEAR: %d\nWEEKS: %d\nDAYS: %d\n",year,weeks,days); return 0; }
C
#include <stdio.h> void filecopy(FILE *ifp, FILE *of); int main(int argc, char *argv[]) { FILE *fp; if (argc == 1) filecopy (stdin, stdout); else while ( --argc > 0) if ((fp = fopen(*++argv, "r")) == NULL) { printf("cat: can't open %s\n", *argv); return 1; }else { filecopy (fp, stdout); fc...
C
#include <linux/init.h> #include <linux/module.h> #include <linux/device.h> #include <linux/kernel.h> #include <linux/fs.h> #include <linux/uaccess.h> #include <linux/random.h> ///< Can cho ham get_random_bytes #define DEVICE_NAME "RandomMachine" #define CLASS_NAME "Random" MODULE_LICENSE("GPL"); MODULE_AU...
C
// Author: Heecheon Park // Description: 1000x1000 matrix multiplication benchmark program in C with MPI. // Date: 8/30/19 #include <stdio.h> #include <stdlib.h> #include <time.h> #include <mpi.h> #include <assert.h> void mat_mult(double mat1[1000][1000], double mat2[1000][1000], double output_mat[1000][1000]); void ...
C
#include "ResponseCommon.h" #include "../ServerCommon/ServerCommon.h" int serverSocketId = 0; int webAddressDecodeTable[2][DECODETABLE] = { { 0x20, 0x22, 0x23, 0x25, 0x26, 0x28, 0x29, 0x2B, 0x2c, 0x2F, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x5C, 0x7C }, { ' ', '"', '#', '%', '&', '(', ')', '+', ',', '/', ':', ';...
C
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "aes.h" #include "ccm.h" #include "gcm.h" #include "utils.h" void test_aes_cbc() { char* text = "Hola"; // char* text = (char*) hex_to_bytes("3243f6a8885a308d313198a2e0370734"); char* key = "1234567890123456"; // char* key =...
C
/*LIBS*/ #include <stdio.h> #include <stdlib.h> #include <locale.h> /*Variveis globais*/ /*Corpo do prgrama*/ int main(){ setlocale(LC_ALL, "portuguese"); int i, num, temp, resposta; printf("\nInsira um nmero: "); scanf("%d", &num); for(i = num; i > 1; i--){ resposta = resposta + i; } printf("\nO resultado...
C
//--------------------------------------------------------------- // man.c // nchess // // Created by Mark Cornwell on 7/15/14. // Copyright (c) 2014 Mark R Cornwell. All rights reserved. //--------------------------------------------------------------- #include <stdio.h> #include "man.h" // Test routine static ...
C
// // main.c // c shiyan 3.4 // // Created by 林斌 on 2017/4/13. // Copyright © 2017年 林斌. All rights reserved. // #include <stdio.h> #include "stdlib.h" long fabonacci(int n); int main(void) { int i,k; long sum=0,*p=&sum; scanf("%d",&k); for(i=1;i<=k;i++){ sum+=fabonacci(i);//fab循环之后的语句位置 ...
C
/*c program for fibonacci series by recursion && finding a number entered by a user is in fibonacci series or not*/ #include<stdio.h> void main() { int i, n,s,flag=0; int fib(int); puts("How many terms of fibbonacci series you want to print\n"); scanf("%i", &n); printf("The %i terms of F...
C
/** * K&R Exercise 5-1 * Page 97 * As written, getint treats a + or - not followed by a digit as a valid representation of zero. Fix it to push such a character back on the input. * Completed **/ int main(void) { return 0; }
C
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <windows.h> #include <math.h> #include <string.h> //int check() //{ // int a = 1; // return (char *)&a; //} // //int main() //{ // int ret = check(); // if (ret == 1) // printf("С˴洢\n"); // else // printf("˴洢\n"); // return 0; //} //in...
C
#include<stdio.h> void set_idx(int *v,int n){ int i; for(i=0;i<n;i++){ v[i]=i; } } int main(){ int n; int i; scanf("%d",&n); int v[n]; set_idx(v,n); for(i=0;i<n;i++){ printf("%d",v[i]); } }
C
#include <stdio.h> #include <string.h> /*strerror*/ #include <errno.h> //#define OSD_DBG_MSG #include "nc-err.h" #include "dbmalloc.h" #ifdef DEBUG_MALLOC_MEM typedef struct memMallocNode { void *pAddr; size_t size; }MALLOC; #define LIST_LEN 500 static MALLOC list[LIST_LEN]; static int g_MallocMemNum = 0; ...
C
#include <stdio.h> #include <string.h> typedef struct { char nombre[20]; int socket; } Conectado; typedef struct{ Conectado conectados[100]; int num; } ListaConectados; //La lista se pasa por referencia int Pon (ListaConectados *lista, char nombre[20], int socket){ //aade nuevo conectado y retorna 0 si okey o 0...
C
#include "./sudoku_solver.h" #include <assert.h> #include <limits.h> #include <stdbool.h> #include "./sudoku_grid.h" unsigned int tile_count(unsigned short tile) { unsigned short count; asm( "popcnt %1, %0" : "=r" (count) : "g" (tile) : "cc" ); return count; } /* returns 0 for 1 1 for 2, ...
C
#include<stdio.h> int main(){ int i,sum,a,final; for(i=1;;i++){ if(i%8==1){ sum=i; sum/=8; if(sum%8==1){ sum/=8; if(sum%8==7){ a=sum/8; if((a%17==4)&&(a/8%17==15)){ final=i; printf("%d",final); return 0; } } } } } }
C
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<sys/socket.h> #include<netinet/in.h> main() { int sock_desc; struct sockaddr_in server; int k; socklen_t len; char msg[100]; sock_desc=socket(AF_INET,SOCK_STREAM,0); if(sock_desc==-1) { printf("Error in socket creation\n"); exit(1); } memset(&serv...
C
#include <avr/io.h> #include <stdio.h> #include "SPI.h" void initMaster( void ) { // MOSI, SCK and SS Output and MISO as Input DDRB |= (1 << MOSI) | (1 << SCK) | (1 << SS); // SPI Control Register: activate SPE (SPI enable) and set MSTR -> Master Mode (Master/Slave select) and set clock rate fosc/64 SPCR = (1 << ...
C
/* This demos return status */ #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { int rval = 0; if (argc != 2) { printf("usage: %s return_status_number(0~255)\n", argv[0]); printf("Then observe return status in $?\n"); printf("ex: $ %s 121; echo $?\n", argv[0]); ...
C
#include <stdio.h> main() { char data[]={0,0,2,0,1,1,0,0,2,1,0,2,}; int i, row, col; for(i=0;i<12;i++) { row=i/4 + 1; //get row col=i%4 + 1; //get col printf("%d행 %d열에 ", row, col); if(data[i]==1) printf("검은 돌이 놓여 있습니다 \n"); else if(data[i]==2) printf("흰 돌이 놓여 있습니다...
C
/************************************************************************* > File Name: 2select.c > Author: YeZe > Mail:a@b.com > Created Time: Thu 29 Jan 2015 08:51:09 UTC ************************************************************************/ #include "sel0.h" int main(int argc,char *argv[]) { int fd21,f...
C
//menu.c #include "include.h" void menu(void) { // Definiton char cMenu; int iSchleife = 1; char sUser[26]; char sPasswort[20]; char sNachname[20]; char sVorname[20]; char cFile[100] = "sudoku-anleitung.pdf"; int iAnzahlhilfe = 0; int iError2 = 0; char cMenu2 = 0; int iSchleife2 = 1; do { iLoesung = ...
C
#include <stdio.h> int main() { int *arr,str,stl,i,j; char f,k; FILE *fl; fl=fopen("tet.gv","w"); fputs("digraph test {\n",fl); printf("Enter \n"); scanf("%d",&str); stl=str; arr=(int*)malloc(str*stl*sizeof(int)); for(i=0; i<str; i++) { f='A'; k='A'; f+=i; for(j=0; j<stl; j++) { printf("Ent...
C
#include "Queue.h" int main(int argc, char const *argv[]) { int i; initQueue(0); for (i = 1; i < 5; ++i) { addElement((float)i); } // print(front); // terminate(front); // print(front); // not = addNode(front,1515151); // deleteNode(front,getLast(front)); // printf("%0.1f\n\n",getValue(getLast(front))); ...
C
#include "main.h" #include "function.c" int main() { do { // get the chosen difficulty's highest number int difficultMax = difficultySelection(); srand(time(NULL)); // get seed int randNumber = (rand() % difficultMax) + 1; // from 1 to the highest num...
C
#include<stdio.h> int main(){ int a, b; while(scanf("%d%d",&a,&b)!=EOF){ int c=0,ans=0,i; for(i=9;i>=0;i--){ c=(a%10+b%10+c)>9?1:0; ans+=c; a/=10;b/=10; } printf("%d\n",ans); } return 0; } /******************************...
C
#include <stdio.h> int main() { char NOME[70]; double FIXO,VENDAS,FC; gets (NOME); scanf ("%lf",&FIXO); scanf ("%lf",&VENDAS); FC=FIXO+(VENDAS*0.15); printf ("TOTAL = R$ %.2lf\n",FC); system ("pause");}
C
#include <stdio.h> typedef struct { unsigned short bit0 : 1 ; unsigned short bit1 : 1 ; unsigned short bit2 : 1 ; unsigned short rsv : 13 ; }tsParse; typedef union { unsigned short alls; tsParse sParse; }teAll; teAll eAll; int main() { eAll.alls = 0xb872; printf("VAL A : %x \n",eAll.sParse.bit0); ...
C
/* Insertion sort Worst case performance: О(n^2) Best case performance: Ω(n) Average performance: Θ(^2) Worst case space complexity: O(n) */ void insertion_sort(int arr[], int n) { for (int i = 0; i < n; i++) { int j = i; while (j > 0 && arr[j - 1] > arr[j]) { int temp = arr[j]; arr[...
C
#ifndef SKARO_SCHEDULER #define SKARO_SCHEDULER /* * Event_bits is a struct of bit fields. Each bit field represents an event. * Add new events by adding a new bit field. */ #define MAX_EVENTS 8 typedef struct { int velocity_loop; int hello; int steering_loop; int vision; int process_wirel...
C
#include <stdio.h> #include <stdlib.h> #include <Windows.h> #include <time.h> int main() { PROCESS_INFORMATION pi[10]; char names[10][10]; char status[10][10]; double start[10]; double end[10]; int index = 0; //removing garbage values from end time array for(index = 0; ind...
C
#include "student.h" int main(int argc, char **argv) { struct student s; s.matric = 40323; s.name = "David Ciocoiu"; s.address = "Edinburgh Napier University"; print_student(s); return 0; }
C
#include <sys/types.h> #include <sys/stat.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <fcntl.h> #define maxline 100 #define ERROR(text){printf(text);exit(EXIT_FAILURE);} int main(int argc, char** argv){ printf("slave\n"); if (argc != 3) ERROR("Wrong amount of args :...
C
#include <stdio.h> #include <string.h> int bubbleSort(int array[], int count) { int tmp; for (int i = 0; i < count - 1; ++i) { int flag = 0; for (int j = 0; j < count - i - 1; ++j) { if (array[j] > array[j + 1]) { tmp = array[j]; array[j] = array[j+1]; array[j+1] = tmp; flag = 1; } ...
C
#include <stdio.h> void main(int argc, char **argv){ char buf[1]; strcpy(buf,argv[1]); printf("%s\n", buf); printf(buf); printf("\n"); }
C
//jcmg@usal.es #include <stdio.h> #include <stdlib.h> int main (void){ char barras []="========================================", name [40], calcu []="CALCULO DE FACTURA HOSPITALARIA", fact []="FACTURA HOSPITALARIA"; int dia, mes, ano, diasIngresado, diasFacturados, temp; double totalAPagar, costeDiarioTotal, cost...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_print_base.c :+: :+: :+: ...
C
#include <stdio.h> static int global_variable = 42; static void hello_world() { printf("Hello, world! %i\n", global_variable); } int main() { __initialize__(); hello_world(); }
C
#include<stdio.h> int main(void){ double A,B; scanf("%lf %lf",&A,&B); if(A > B) printf("GREATER\n"); else if(A < B) printf("LESS\n"); else printf("EQUAL\n"); return 0; }
C
#include <stdio.h> int main(int argc, char **argv, char **env) { printf("Command line arguments:\n"); for (int i = 0; i < argc; i++) { printf("argv[%d]: %s\n", i, argv[i]); } printf("\n"); printf("Environment variables:\n"); for (int i = 0; env[i] != NU...
C
#include <stdio.h> #include "holberton.h" /** *flip_bits - show: number of bits that need to get from one number to another * *@n: number to compare *@m: number to compare * *Return: the number of diferents bits */ unsigned int flip_bits(unsigned long int n, unsigned long int m) { unsigned long int cont, res, n...
C
#include "hash_tables.h" /** * hash_table_get - gets a value from a key in the hash table * @ht: hash table * @key: key * Return: the actual value */ char *hash_table_get(const hash_table_t *ht, const char *key) { hash_node_t *iternode = malloc(sizeof(hash_node_t)); unsigned long int index; if (!ht || ht->arra...
C
// Author Alex Martin #include<stdio.h> #include<readline/readline.h> int main(void) { float fahrenheit; float celsius; printf("Enter temperature in celsius: "); scanf("%f",&celsius); fahrenheit=(1.8*celsius)+32; printf("%f° in Celsius is equivalent to %f° Fahrenheit." , celsius, fahrenheit); return 0; ...
C
/* This file performs the following test: start, stop and timer functionality for 2 slave pthreads */ #include <pthread.h> #include "papi_test.h" void *Thread(void *arg) { int retval; void *arg2; printf("Thread 0x%x started, specific data is at %p\n", (int) pthread_self(),arg); retval = PAPI_set_thr_s...
C
#include<stdio.h> int is_prime[1000001]={0}; unsigned long long sm[1000001]={0}; int main() { int i,t,m,n,j; for(i=1;i<1000000;i=i+1) is_prime[i]=1; is_prime[0]=0; is_prime[1]=0; //1 is neither a prime nor composite. for(i=2;i<1000;i++) { if(is_prime[i])//if...
C
#include <sys/types.h> #include <sys/param.h> #include <sys/kernel.h> #include <vm/vm.h> #include <sys/malloc.h> extern struct kmembuckets kmembuckets[]; /* in kern/kern_malloc.c */ extern char **kmemnames; /* in kern/kern_malloc.c */ extern vm_offset_t kmemlimit; /* end of " */ extern int *kmemtypetable...
C
#include <cs50.h> #include <stdio.h> #include <math.h> float get_user_input(string prompt); int main(void) { // Gets User Input float i = get_user_input("hOw MuCh cHaNgE iS OwEd? "); // Converts and Rounds to Cents int cents = round(i * 100); // Counter starts at 0 int a = 0; // Handels...
C
#include <SDL2/SDL.h> #include "../graphic.h" #include "helpers.h" SDL_Texture *create_glow_ball(struct graphic_t *graphic, int radius, SDL_Color color, int dim) { SDL_Renderer *renderer = graphic_get_renderer(graphic); float relative_dist = 0; float distance = 0; int alpha = 0...
C
// gcc -dynamiclib -I/usr/include/python2.3/ -lpython2.3 -o _geometry.dylib _geometry.c // Rename .dylib to .so #include <Python.h> #include <math.h> #include "types.h" // FAST INVERSE SQRT // Chris Lomont, http://www.math.purdue.edu/~clomont/Math/Papers/2003/InvSqrt.pdf float _fast_inverse_sqrt(float x) { floa...
C
#include "basic_operator.h" #include <stdio.h> #include "my_sub.h" extern void my_sum_(double *ret, double *a, double *b); double add(double a, double b) { double ret; my_sum_(&ret, &a, &b); return ret; } double sub(double a, double b) { return my_sub(a, b); } double mul(double a, double b) { printf(" Cal...
C
/* Note:Your choice is C IDE */ #include "stdio.h" #include "windows.h" void main() { char c[10]="color 0A"; int i,j; c[6]-=1;c[7]-=1; system("pause"); for(i=0;i<6;i++) { c[6]+=1; c[7]='A'-1; for(j=0;j<3;j++) { c[7]+=1; printf(" \n"); print...
C
#include<stdio.h> #include<string.h> #include<ctype.h> void correct(char* prenom); int main() { FILE* file1,* file2; char* prenom[35] ; file1=fopen("filemal.txt","r"); if(file1==NULL) { printf("can t open file!\n"); return 1; } file2=fopen("filebien.txt","w"); if(file2...
C
#include "holberton.h" /** *print_to_98 - Write until 98. *Return: Always 0. *@n: Variable u */ void print_to_98(int n) { int d, u; d = 0; u = 0; for (n = 0; n <= 98; n++) { d = n / 10; u = n % 10; if (n < 10) { _putchar(' '); _putchar('0' + u); _putchar(','); } else if (n == 0) { _...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<unistd.h> #include<sys/socket.h> #include<sys/types.h> #include<netinet/in.h> #define MAXSIZE 90 void bsort(int a[],int n) { int i,j; for(i=0;i<n-1;i++) for(j=0;j<n-i-1;j++) { if(a[j]>a[j+1]) { int temp=a[j]; a[j]=a[j+1]; ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> /* * Given a compressed string in which a number followed by [] indicate how many times those characters occur, decompress the string * Eg. : a3[b2[c1[d]]]e will be decompressed as abcdcdbcdcdbcdcde. * Assume the string is well formed an...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_data.c :+: :+: :+: ...
C
#include <stdio.h> #include <letmecreate/click/adc.h> #include <letmecreate/core/spi.h> #define START_BIT (0x04) #define SINGLED_ENDED (0x02) int adc_click_get_raw_value(uint8_t channel, uint16_t *value) { uint8_t tx_buffer[3], rx_buffer[3]; if (channel >= ADC_CLICK_CHANNEL_COUNT) { fprintf(...
C
/* Barrelfish communication mechanism - test */ /* * 07/25/11. The test is working, but you have to take care of the channel size (considering the size of a struct ump_message) * when you will want to use it. The kernel module must be loaded with the proper size. Cf. the microbench scripts */ #include <s...
C
/* * master_control.c * * Created on: Mar 27, 2017 * Author: Fabio Pungg */ #ifdef OLD_MASTER_CONTROL #include <DAVE.h> #include "master_control.h" #include "ball_intake.h" #include "sled_positioning.h" static master_states_t cur_master_state = MASTER_INIT_ONE; static uint32_t interrupt_count = 0; master_...
C
/* getch and ungetch to handle EOF Character In all the ungetch and getch * functions written so far, the buf is declared as char buf[BUFSIZ]. * Changing this to int buf[BUFSIZ] enable it to handle EOF. As EOF is an * integer declared in stdio.h having the value -1 */ #include<stdio.h> #define BUFSIZE 100 int ge...
C
#include <stdio.h> #include <unistd.h> #include <pthread.h> void *thread(void *arg) { int i = 0; while(1) { printf("I am runing\n"); sleep(1); i++; if(i==3) { pthread_exit((void *)1); } } return NULL; } int main(int ar...
C
#include <math.h> #include <stdio.h> #include "heatconduct.h" #include "linear.h" #include "array.h" #define pi 3.14159265358 #define max(x,y) x>y?x:y // global variables static int NX; static double *u, *u1, dx,dt, totaltime,romda; void HeatConduct_Init( int tNX,double ttotaltime, double tromda ) { int ...
C
#include <stdio.h> #include <stdlib.h> #include "holberton.h" /** * argstostr - concatenates all of the arguments of the program * @ac: count of arguments given to program * @av: values fed into program * * Return: concatenated string */ char *argstostr(int ac, char **av) { int i, j; int k = 0, n = 0; char *s ...
C
#include<stdio.h> #include<stdlib.h> #include<time.h> #include<Windows.h> int elimineDoublon(int tab[], int taille); void afficheTab(int tab[], int taille); void main() { // int tab[100] = { 1,2,2,3,5,8,9,9,10,14,14,14,15,16,16 }; // int taille = 15, tailleFin = 15; // int tab2[100] = { 1,2,2,3,5,8,9,9,10,14,14,14,...
C
#include <kernel/atag.h> uint32_t get_mem_size(atag_t *tag) { // If MODEL_1 is defined it means I'm using hardware, otherwise qemu, which doesn't support atags. #ifdef MODEL_1 while (tag->tag != NONE) { if (tag->tag == MEM) { return tag->mem.size; } tag = (atag_t *)(...
C
#include <sys/types.h> #include <sys/stat.h> #include <stdio.h> char* Convet_octal_toBinary(int octal); int main(int argc, char *argv[]) { int i; struct stat buf; char *ptr; for (i=1; i<argc; i++) { if (lstat(argv[i], &buf)<0) { printf("lstat() error\n"); co...
C
#include <stdio.h> #include <assert.h> // 将四个有符号字节封装成一个32位unsinged,一个字中的字节从0编号到3,为一个使用补码运算的机器编写函数 typedef unsigned packet_t; // Extract byte form word,Return as signed integer // 提取其中的一个byte位,用有符号的int表示 // 错误的实现 int xbyte_old(packet_t word,int bytenum){ return (word >> (bytenum << 3)) & 0xFF; } int xbyte_new(p...
C
#include <stdio.h> #include "5mok.h" #define STACK_SIZE ROW*COL static int top = 0; static COORD stack[STACK_SIZE]; void show_stack(){ int i; for( i = 0 ; i < top ; i++ ){ if( (i % 2) == 0 ) fprintf( stderr, "black: " ); else fprintf( stderr, "white: " ); fprintf( stderr, "(%d,%d...
C
#ifndef JSON_INTERNAL_GETTERS_INDEX_ARRAY_H_ #define JSON_INTERNAL_GETTERS_INDEX_ARRAY_H_ #include <json/internal/error.h> #include <json/internal/typedef/array.h> // Gets the element from the array and sets *element with it. // If the index in out of the bound or the type doesn't match, the function // fails and set...
C
/**** PROGRAM FOR GCD (GREATEST COMMON DIVISOR) ****/ #include<stdio.h> #include<conio.h> int GCD(int,int); void main() { int a,b; clrscr(); printf("Enter two number for GSD:"); scanf("%d%d",&a,&b); printf("GSD of %d and %d is %d:",a,b,GCD(a,b)); getch(); } int GCD(int a,int b) { if(a<b) retu...
C
#include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <sys/wait.h> int main(void) { pid_t pid, wpid; int status; pid = fork(); if(pid == -1){ perror("fork error"); exit(1); } else if(pid == 0){ //son printf("I'm process child, pid = %d\n", getpid()); #if 1 execl("./abnor", "abnor", NULL);...
C
// Copyright 2015 gocp authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include <stdio.h> #include <unistd.h> #include "gocp.h" typedef struct { int id; GoChan c; } data_t; void f(void *args) { int i; data_t *d = (data_t*)(arg...
C
#include <stdio.h> #include <assert.h> #include "common.h" void* png_to_rgba(FILE* png_file, void* dest, size_t* dest_size){ //PNG format: https://en.wikipedia.org/wiki/Portable_Network_Graphics#File_format //Verify file header uint64_t header; assert( fread(&header, 8, 1, png_file) == 8 ); if ( header != 0x89504...