language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <stdlib.h> #include <sys/types.h> #include <ctype.h> #include <sys/stat.h> #include <string.h> #include <signal.h> void handshake(){ printf("Waiting for a Client Connection...\n\n"); mkfifo("WKP", 0666); // make Well Known Pipe ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_printf.c :+: :+: :+: ...
C
// contains screen manipulation functions, such as clearScreen(), gotoxy(), // setColor(), etc #include "comm.h" #include "screen.h" #include <stdio.h> /* Function definition of clearScreen() This function will use VT100 escape sequence "\ESC[2J" to erase the total terminal screen input argument: none return argu...
C
/* ** my_testnbr.c for my_testnbr in /home/zeng_d ** ** Made by David Zeng ** Login <zeng_d@epitech.net> ** ** Started on Mon Mar 28 16:04:38 2016 David Zeng ** Last update Mon Mar 28 16:34:26 2016 David Zeng */ #include "my.h" int my_testnbr(char *str, int *nb) { char buffer[my_strlen(str) + 10]; int tmp; ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <netinet/in.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <arpa/inet.h> #include <errno.h> #define WSAGetLastError() (errno) #define WSA(err) (err) #define closesocket(fd) close(fd)...
C
// Time taken: 50 minutes #include <stdio.h> void decrement(char *N, int digits, int pos); int main(void) { int T; scanf("%d", &T); for (int testCase = 1; testCase <= T; testCase++) { char N[20] = {0}; int digits = 0; N[0] = getchar(); while (N[0] < '0' || N[0] > '9') {N[0] = getchar();} ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_next_line.c :+: :+: :+: ...
C
#include <stdio.h> int main() { int n, i, a, b, f = 0, t = 0, w = 0; printf("n: "); scanf("%d", &n); for(i=0;i<n;i++) { printf("process %d\n", i+1); printf("arrival time: "); scanf("%d", &a); printf("burst time: "); scanf("%d", &b); f=b+f; t=f-a; ...
C
#include <stdio.h> #include <stdlib.h> #include <termios.h> #include <unistd.h> #include <string.h> #include "../encoding/utf_8.h" /* Отображает шестнадцатиричные коды вводимых символов */ //#define NEED_BITS #ifdef NEED_BITS static char * get_bits_static(unsigned char ch) { static char bits[10] = "0000 0000"; ...
C
#include <stdio.h> int main() { long long longest = 0, n = 0; long long i; long collatz = 0; for (i = 1; i < 1000000; i++) { n = i; int t = 0; while (n != 1) { if (n%2 == 0) n /= 2; else n = n*3+1; t++; } if (collatz < t) { collatz = t; longest = i; } } printf("%lld\n", longest...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #include "picture.h" #include "numberGame.h" #define ROW 5 #define COL 3 #define SHUFFEL_COUNT 20 #define MAX ROW*COL void fillMat(int* mat, int row, int col) { for (int i = 0; i < row * col; ++i) { *mat = i; ++mat; } } void messTheMat(int* mat, int row, i...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define STR "00004f00" char *str; int main(){ unsigned long long int ulli = 0; unsigned long long int ullj = 0; str = calloc(100,sizeof(char)); sprintf(str,"%s",STR); printf(":%s:@str\n",str); printf("--- using strtoull() ---\n"); ulli = strtoull(str...
C
#include<stdio.h> #include<stdlib.h> int strend(char *s, char *t) /*declaration of a function that returns 1 if the string t occurs at the end of the string s, and zero otherwise */ { int count1 = 0, count2 = 0; /* initializing two count variables ...
C
#include<stdio.h> #include<process.h> #define N 3 void line(){ int i; for(i=0;i<80;i++) printf("_"); printf("\n"); } typedef struct{ int bookno;float price; char title[50],author[50]; }book; main(){ book b[N]; int i;float sumprice=0.0; for(i=0;i<N;i++){ printf(" enter the data #%d\n",i+1); ...
C
#include <stdio.h> /* print combination of 3 */ int main(void) { int first, middle, last; for (first = '0'; first <= '9'; first++) { for (middle = first + 1; middle <= '9'; middle++) { for (last = middle + 1; last <= '9'; last++) { putchar(first); putchar(middle); putchar(last); if (!(fi...
C
/* ============================================================================= Copyright © 2020 Skynet Consulting Ltd. This file is the property of Skynet Consulting Ltd. and shall not be reproduced, copied, or used as the basis for the manufacture or sale of equipment without the express written permiss...
C
#include <stdio.h> #include <stdlib.h> #include <pthread.h> typedef struct write_args{ int numlines; char* filename; } write_args; void test_write(write_args *wargs); int main(int argc, char* argv[]){ if(argc != 4){ printf("Error, received %d arguments.\n",argc); printf("Expected 3\n");...
C
/*********************************************************************************************************************** * * I N C L U D E S * **********************************************************************************************************************/ /* M...
C
#include<stdio.h> #include<conio.h> void main() { char grd; clrscr(); printf("enter grade"); scanf("%c",&grd); switch(grd) { case 'E': printf("excellence\n"); break; case 'V': printf("very good\n"); break; case 'G': printf("good\n"); break; case 'A': printf("averag \n"); break; default: printf("i...
C
#include<stdio.h> #include<stdlib.h> #include<assert.h> int *array_of_product(const int *arr, size_t sz) { int i,j; int *result = malloc(sz * sizeof(int)); assert(result && "Allocation failed!\n"); for(i = 0; i < sz; i++) { int prod = 1; for(j = 0; j < sz; j++) { if(i != j) { prod...
C
/* * c-periphery * https://github.com/vsergeev/c-periphery * License: MIT */ #include "test.h" #include <stdlib.h> #include <errno.h> #include <sys/wait.h> #include <pthread.h> #include <semaphore.h> #include <unistd.h> #include "../src/gpio.h" unsigned int pin_input, pin_output; void test_arguments(void) { ...
C
/********************************************** Nome: Samuel Toyoshi Ishida RA: 160250 Turma: T Laboratorio 10a - LSCrypto ************************************************/ #include <stdio.h> #include <string.h> #include <stdlib.h> struct alfabeto{ char letra; int num; };/*registro para contag...
C
/************************************************************************* > File Name: localtime.c > Author: Pansj > Mail: perry2008084@gmail.com > Created Time: Wed 19 Mar 2014 09:27:38 PM CST ************************************************************************/ #include<stdio.h> /* puts, printf */ #includ...
C
#include <stdio.h> int main(void) { // int celsius; double celsius; double fahr; // celsius = 37; // scanf("%d", &celsius); scanf("%lf", &celsius); fahr = 9.0 / 5.0 * celsius + 32; printf("celsius : %.2f ---> fahr : %.1f\n", celsius, fahr); return 0; }
C
/* * list.h * * List (thread safe) - header file * * Author: Filip Kinovic * Version: 1.6 * Date: 26.06.2017 */ #include <windows.h> #include <stdio.h> #ifndef _LIST_H_ #define _LIST_H_ #ifdef __cplusplus extern "C" { #endif /* type definitions */ typedef HANDLE HLIST; typedef HANDLE HITEM; typedef enum { ...
C
#include <stdio.h> void ft_ultimate_ft(int *********nbr); int main (void) { int *********nbr1; int ********nbr2; int *******nbr3; int ******nbr4; int *****nbr5; int ****nbr6; int ***nbr7; int **nbr8; int *nbr9; int nbr; nbr = 24; nbr9 = &nbr; nbr8 = &nbr9; nbr7 = &nbr8; nbr6 = &nbr7; nbr5 = &nbr6; ...
C
#include<stdio.h> #include<stdlib.h> void EnterGasMiles(void); int main(){ EnterGasMiles(); return 0; } void EnterGasMiles(){ double gallon = 0, mile = 0, milePerGallon = 0; double totalGallons = 0, totalMiles = 0; do{ printf("Enter the gallons used (-1 th end) : "); s...
C
#include "merge_sort_array.h" void ms_array_sort(int* list, int start, int end) { if(end-start < 1) return; // partition int middle = ms_array_partition(start,end); // sort ms_array_sort(list,start,middle-1); ms_array_sort(list,middle,end); // merge ms_array_merge(list,start,end); } void ms_array_merge(in...
C
/* Generated by re2c 2.0.3 on Sun Nov 15 03:22:57 2020 */ // re2c $INPUT -o $OUTPUT #include <assert.h> // expect a null-terminated string static int lex(const char *str, unsigned int len) { const char *YYCURSOR = str, *YYLIMIT = str + len, *YYMARKER; int count = 0; loop: { char yych; yych = *YYCURSOR...
C
// // hello.txrx.45.c // // step response transmit-receive hello-world // 9600 baud FTDI interface // // Neil Gershenfeld // 11/6/11 // // (c) Massachusetts Institute of Technology 2011 // This work may be reproduced, modified, distributed, // performed, and displayed for any purpose. Copyright is // retained and mu...
C
/* * LeetCode Submissions by Xinyu Chen * ZigZag Conversion * https://leetcode.com/problems/zigzag-conversion/ * Runtime: 4 ms */ char* convert(char* s, int numRows) { int len = strlen(s); if (len <= numRows || numRows == 1) return s; int index = 0, n = numRows * 2 - 2; char *ret = (char*)calloc(len + 1, siz...
C
/* bintransformer.c */ #include<stdio.h> int number; int rest[256]; int i=0; void output(); void transformation() { while(number>0) { rest[i++]=number%2; number=number/2; } output(); } void output() { for(--i; i>=0; i) { printf("%d",rest[i--]); } } int main() { printf("dez: "); scanf(...
C
/* * File: stringSearch.c * Author: Brendon Hudnell * Purpose: This program reads a string from input, then reads additional strings. If any of the additional * strings exactly matches or matches the reverse of the first string, or if it exactly matches the previous string, that string will be printed. ...
C
#include <stdlib.h> int ft_ultimate_range(int **range, int min, int max) { int *a; int i; int n; if (min >= max) { *range = NULL; range = NULL; return (0); } a = malloc(sizeof(int) * (max - min)); *range = a; if (!a) return (-1); i = 0; n = min; while (n < max) { a[i] = n; i++; n++; } ret...
C
/*P8.5 Program to reverse the elements of an array*/ #include<stdio.h> int main(void) { int i,j,temp,arr[10] = {1,2,3,4,5,6,7,8,9,10}; for(i=0,j=9; i<j; i++,j--) { temp=arr[i]; arr[i]=arr[j]; arr[j]=temp; } printf("After reversing, the array is : "); for(i=0; i<10; i++) printf("%d ",arr[i]);...
C
#ifndef FUNCTIONSTRINGCOLLECTOR_H #define FUNCTIONSTRINGCOLLECTOR_H #include "FunctionClassBase.h" #include "TFormula.h" using namespace std; class FunctionStringCollector { public: //Data members TString funcstring; TString type; //Constructor and destructor FunctionStringCollector(); ~FunctionStri...
C
#include <stdio.h> #include <stdlib.h> #define MAX_SIZE 4096 #define FILENAME "origin.txt" int main() { FILE *f; char line[MAX_SIZE]; if ((f = fopen(FILENAME, "r")) == NULL) { perror(FILENAME); return EXIT_FAILURE; } printf("Contenido del archivo: \n"); // while(fgets(line, MAX_SIZE, f) != NULL...
C
#ifndef ARRAYSTACK_H #define ARRAYSTACK_H #include <stdlib.h> #include <stdio.h> typedef struct Node{ char data; struct Node* next; } Node; typedef struct { struct Node* top; } Stack; void stackInit (Stack* s); int push (Stack* s, char c); char pop (Stack* s); char top (Stack* s); int isFull (Sta...
C
#include <stdio.h> void delete_func(int *a, int len, int index) { for (int i = index; i < len - 1; i++) a[i] = a[i + 1]; } void func(int a[100][2], int count) { for (int i = 0; i < count; i++) { int n = a[i][0]; int m = a[i][1]; // 建立数组 int tmp[n]; int len =...
C
/* ** EPITECH PROJECT, 2019 ** test map ** File description: ** test map */ #include <stdio.h> #include <stdlib.h> #include "../include/lem_in.h" #include "../include/my.h" int test_one_room(char *str) { char **room = my_pars(str, ' '); int size = 0; if (str[0] == '#') return (-1); while (roo...
C
#include "defines.h" #include "queue_generic.h" #include "mu_test.h" #include <stdlib.h> typedef void(*ElementDestroy_t)(void* _item); typedef struct Rect { size_t m_height; size_t m_length; } Rect_t; void RectDestroy(Rect_t* _rect) { free(_rect); } /*------------------------------------------------------------...
C
// // main.c // Cache measurement // // Created by Alexey Halaidzhy on 03.04.15. // Copyright (c) 2015 Alexey Halaidzhy. All rights reserved. // #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> #define TWICE(x) x x const size_t CYCLES_COUNT = 1000000; const size_t ...
C
/* Libottery by Nick Mathewson. This software has been dedicated to the public domain under the CC0 public domain dedication. To the extent possible under law, the person who associated CC0 with libottery has waived all copyright and related or neighboring rights to libottery. You should have recei...
C
#include<stdio.h> #include<string.h> #define MAXLINE 1024 char *strremove(char *str, const char *sub); int parse_uri(char *uri, char *host, char *query, char *port); int main(int argc,char **argv){ char str[1024]; char host[1024]; char query[1024]; parse_uri(argv[0], host, query,str); printf("%s %s %s", ...
C
#include <stdio.h> #include <stdlib.h> #define M 128 #define N 128 int main( ){ int tab[M][N]; // printf( "hello world\n" ); #pragma clang loop( i ) reverse #pragma clang loop id( i ) for( int i = 0 ; i < M ; i+=1 ){ #pragma clang loop id( j ) for( int j = 0 ; j < N ; j+=1 ){ tab[i][j] = 0; } } re...
C
/* * sch.c * * Created on: Nov 19, 2018 * Author: uia94411 */ /** * Struct TaskType * TaskType structure is used to define the parameters required in order to * configure a task. */ #include <std_types.h> typedef struct { uint16 interval; /**< Defines how often a task will ...
C
#include <stdio.h> //é pra retornar o vetor no return?, por ex: "return vetor"? Não ficou claro. void ler3Numeros(int *vetor){ int count = 3; for (int i = 0; i < count; i++) { printf("Informe o %iº número: \n", i+1); scanf("%i",&vetor[i]); } } int main(int argc, char const *argv[]) { ...
C
#include <stdio.h> #include<math.h> int main() { int i; int n; int maxx, minn; double mid; int a[100010]; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &a[i]); } if (a[n] > a[1]) { maxx = a[n]; minn = a[1]; } else { maxx =...
C
<<<<<<< HEAD #include "Main.h" int EEPROM_Val = 0; // Variable in which the value of the last required temprature writen in the EEPROM is to be saved char OnOffState = OFF_STATE; // Flag variable in which the system state(On/Off) is to be saved char OnMode = ON_MODE_WORKING; // Flag variable in which ...
C
// // Created by 袁俊 on 2020/10/15. // #include <stdio.h> int main(void) { int floor; printf("请输入您要进入的楼层(1-6):\n"); scanf("%d", &floor); switch (floor) { case 1: printf("1层到了!"); break; case 2: printf("2层到了!"); break; case 3: ...
C
#include <stdio.h> #include <signal.h> #include <unistd.h> void mySleep(unsigned int sec); int main(void){ printf("start\n"); mySleep(3); printf("end\n"); return 0; } /********************************************** * 使用alarm函数和pause函数模拟实现sleep * *******************************************/ void f...
C
#include <stdio.h> #include <ctype.h> /* Global declarations */ /* Variables */ int charClass; char lexeme [100]; char nextChar; char retLex[200]; char tokenStr[100]; int errorFound = 0; int lineCount = 1; int lexLen; int token; int nextToken; FILE *in_fp, *fopen(), *fp; /* Function declarations */ void addChar(); vo...
C
#include <stdio.h> #include "rdm.h" void sort(int*ar,int n) { int i,j,d; for(i=0;i<n-1;i++) { for(j=0;j<n-i-1;j++) { if(*(ar+j)>*(ar+j+1)) { d=*(ar+j); *(ar+j)=*(ar+j+1); *(ar+j+1)=d; } } int k; ...
C
////////////////////////////////////////////////////////////////// // // Copyright 2017 Claus Gittinger // // You may use this, but not claim to have written or own it! // Use at your own risk. // ////////////////////////////////////////////////////////////////// #include "scheme.h" #include "builtinSupport.h" // // ...
C
#include <stdio.h> int main(void){ int first, second; printf("Enter a two-digit number: "); scanf("%1d%1d", &first, &second); printf("The reversal is: %d%d\n", second, first); return 0; }
C
#include<stdio.h> #include<gmp.h> int main() { mpz_t a,b,product; /*Initilaize the variables*/ mpz_init(a); mpz_init(b); mpz_init(product); gmp_printf("Enter first number:");gmp_scanf("%Zd", &a); gmp_printf("Enter second number:");gmp_scanf("%Zd", &b); mpz_mul(product,a,b); gmp_printf("Product is:%Zd\n...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* reverse_rotate.c :+: :+: :+: ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* processing_char_str2.c :+: :+: :+: ...
C
#include "adc.h" volatile uint8_t adc_measure = 0; //volatile uint8_t* ext_ram = (uint8_t) 0x800; //volatile uint8_t* ext_adc = (uint8_t) 0x1400; void initInterrupt() { //probably useless GICR=0x80; //Enable External Interrupts INT0 and INT1 //MCUCR |=0x09; //Configure INT0 active low level trigger...
C
#include<stdio.h> #include<string.h> //reverses the strings void reverse(char* s) { char temp; char* end = s; while(*end != '\0') end++; end--; for(; s < end;s++, end-- ) { temp = *end; *end = *s; *s = temp; } } //absolute value of a number int abs( int x) { return (x < 0) ? x : -x; } //int to array void...
C
static char help[] = "Illustration of MatIS using a 1D Laplacian assembly\n\n"; /* MatIS means that the matrix is not assembled. The easiest way to think of this (for me) is that processes do not have to hold full matrix rows. One process can hold part of row i, and another processes can hold another part. However...
C
#include <stdio.h> int getMax(int *p1, int *p2) { return *p1 > *p2 ? p1 : p2; } void maintttt() { #pragma region ָ붨ʼ //1. int a=10, *p; p = &a; int b = 20, *ptr = &b; //p+sizeof(int) //x86ռ2ֽڣx64ռ4ֽ //2.ָ int c = 200, x, *pc = &c; x = *pc; int i = 10, j = 20, *pa = &i, *pb = &j; pa = pb; printf_s("%d"...
C
#include <stdarg.h> /** * sum_them_all - suma un numero de argumentos indefinidos * @n: numero de argumentos * Return: resultado */ int sum_them_all(const unsigned int n, ...) { unsigned int i, result = 0; /* definir variable tipo va_list*/ va_list list; /*inicializar macro con lista de argumentos y argumentos re...
C
/* Zadání: * * Jakub Kadlčík [jakub.kadlcik01@upol.cz] * * Product is under The BSD 3-Clause License * Copyright (c) 2012, Jakub Kadlčík * All rights reserved. */ #include <stdio.h> #include <stdlib.h> int binarySearch(int A[], int x, int j, int k); int binarySearchNonRecursive(int A[], int x, int n); int mai...
C
#include <stdio.h> #include <stdlib.h> //Լ void computeMatrix(int** A, int **B, int** C); // int n, m, l; int** A; int** B; int** C; int main(void) { //Ҽ: ̹ //й: 1871082 //: 庸 printf("n m n\n:"); scanf("%d %d %d", &n, &m, &l); //n,m,l Է¹ //迭 A,B,C Ҵ A = malloc(sizeof(int*)*n); B = malloc(sizeof(int*)*m...
C
#include<stdio.h> int main () { int n , i , maxn , index_max , minn,index_min , tem; maxn = -999999; minn = -maxn; scanf("%d",&n); for (i = 0 ; i < n ; i ++) { scanf("%d",&tem); //printf("%d\n",tem); if(maxn<=tem) { maxn = tem ; ...
C
#include <stdio.h> int main(int argc, char const *argv[]) { int Age[5],Oldest,Youngest,Counter,OverEighteen=0,UnderEighteen=0; float Average,Sum=0; for (Counter =0;Counter<5;Counter++) { printf("Enter the age of student %d : ",Counter+1); scanf("%d",&Age[Counter]); } Oldest = Age[0]; Youngest = Age[...
C
#include <stdlib.h> #include <string.h> #include <stdio.h> #include "heatshrink_decoder.h" #include "heatshrink_common.h" #include "heatshrink_config.h" #include "greatest.h" static heatshrink_decoder hsd; int main(int argc, char *argv[]) { int data_size = atoi(argv[argc - 1]); uint8_t data[data_size]; ...
C
/* ** dgram_client.c -- a datagram socket "client" */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #define SERVER_PORT 3490 // the po...
C
//inclusão de bibliotecas #include <stdio.h> #include <stdlib.h> #include <locale.h> int main(){ setlocale(LC_ALL, "Portuguese"); //declaração de variáveis char periodo; printf("Informe o seu periodo com apenas a primeira letra: "); scanf("%c", &periodo); switch (periodo) { case 'M': case 'm': pri...
C
//Accept a number from user and reverce that number. #include<stdio.h> int Reverse(int iNo) { int iDigit=0,Revs=0; if(iNo<0) { iNo=-iNo; } /*while(iNo>0) { iDigit=iNo%10; Revs=(Revs*10)+iDigit; iNo=iNo/10; }*/ for(;iNo>0;iNo=iNo/10) { iDigit=iNo%10; Revs=(Revs*10)+iDigit; } ...
C
//In progress - SHA-512 updated with bin. Do the same to the others. #include <string.h> #include <stdio.h> #include <stdint.h> #include <openssl/evp.h> #include <openssl/sha.h> #include <getopt.h> #include <ctype.h> // crypto.h used for the version #include <openssl/crypto.h> // bio.h and buffer.h are solely for Ba...
C
#include <stdio.h> int main(int argc, char *argv[]) { int n, count, i; int magnitudes[10005]; while(1) { scanf("%d\n", &n); if(n == 0) break; for(i=0; i<n; i++) { scanf("%d", &magnitudes[i]); } count = 0; for(i=1; i<(n-1); i++) { if((magnitudes[i] < magnitudes[i+1]) && (magnitudes[i] ...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(void) { // 变量定义 /** int a; */ // 显示的做变量 b 的声明 extern int b; // 变量定义 int a = 66; // 变量使用、变量赋值 a = 56; printf("%d\n", a); return 0; }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.c :+: :+: :+: ...
C
#include <stdio.h> #include <string.h> int duplicate_exist(char *array , int start , int end) ; void main(){ char a[] = "ABBBA" ; int len = strlen(a); permute(a , 0 , len); } void swap(char *x, char *y) { char temp; temp = *x; *x = *y; *y = temp; } int duplicate_exist(char array[] ...
C
/** * SO * Lab IPC * * Task #2, Linux * * Hash function implementation */ #include "hash.h" /** * Hash function based on djb2 of Dan Bernstein * http://www.cse.yorku.ca/~oz/hash.html * @return dispersion value (key) */ unsigned int hash(const char *str) { unsigned int hash = 5381; int c; while ((c = *st...
C
#include "holberton.h" /** * cap_string - entry point * @cap: entry pointer array * Return: Cap with change */ char *cap_string(char *cap) { int i, j; char car[] = "}\n,;\t.!?\"(){ "; i = 0; while (cap[i] != '\0') { if (cap[i + 1] >= 97 && cap[i + 1] <= 122) { if (i == 0) { cap[i] -= 32; } ...
C
#include "libft.h" char *ft_strstr(const char *haystack, const char *needle) { size_t i; size_t j; size_t len_needle; if (!(strcmp(haystack, needle)) || ft_strlen(needle) == 0) return ((char *)haystack); else if (!ft_strlen(haystack)) return (NULL); len_needle = ft_strlen(needle); i = 0; while (haystack[i...
C
#include "blockchain.h" /** * genesis_create - creates Genesis Block * * Return: pointer to created Genesis block or NULL on failure */ block_t *genesis_create(void) { block_t *genesis; genesis = calloc(1, sizeof(*genesis)); if (!genesis) return (NULL); memcpy(genesis->data.buffer, GENESIS_DATA, GENESIS_DA...
C
#include <stdio.h> #include <unistd.h> #include <string.h> #include <fcntl.h> int main() { #if 0 int pid = fork(); if(pid < 0) { perror("fork"); return -1; } else if(0 == pid) { //child sleep(20); printf("i am child\n"); } else { //father while(1) { sleep(1); }...
C
#include <stdio.h> #include <string.h> #define max(a, b) a > b ? a : b int main(void) { int i, j; int n, v; int dp[20005], w[35]; scanf("%d%d", &v, &n); memset(dp, 0, sizeof(dp)); for (i = 0; i < n; i++) { scanf("%d", &w[i]); } for (i = 0; i < n; i++) { for (j = ...
C
#include "symboltabelle.h" void fehler(char* msg, YYLTYPE yylloc){ FATAL_COMPILER_ERROR(INVALID_SEMANTICS, 0, "(%d.%d-%d.%d): %s\n", yylloc.first_line, yylloc.first_column, yylloc.last_line, yylloc.last_column, msg); anzFehler++; } void gebeGlobaleVariablenAus() { variablen *elt; DL_FOREACH(global,elt) { if (e...
C
/** @file * Interface of the functions responsible for executing the batch mode. * */ #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> #include <ctype.h> #include <inttypes.h> #include <stdint.h> #include "auxiliary_structs.h" #include "gamma.h" #include "parsing.h" ...
C
#include "elev.h" #include "queue.h" #include "statemachine.h" #include <stdio.h> #include <stdbool.h> /////////////////////////////// /////MAIN (EVENT HANDLER)////// /////////////////////////////// int main() { // Initialize hardware if (!elev_init()) { printf("Unable to initialize elevator hardw...
C
#include <stdio.h> int main() { int n; scanf("%d",&n); while(n--) { int year,month,day; int m=0; scanf("%d%d%d",&year,&month,&day); switch(month-1) { case 11:m=m+30; case 10:m=m+31; case 9:m=m+30; case 8:m=m+31; ...
C
// // Created by nekoimi on 2021/3/24. // #include <stdio.h> #include "ci_queue.h" // Queue struct queue { int data[100]; int first; int last; }; void queue_main() { int i; struct queue q; q.first = 1; q.last = 1; for (int j = 0; j < 9; ++j) { q.data[j] = j; q.last++; ...
C
#include <string.h> #include <stdlib.h> #include "requests/method.h" #include "utilities/errors.h" struct RequestMethodConversion { RequestMethod value; const char* string; }; const static struct RequestMethodConversion requestMethodConversions[] = { { DELETE, "DELETE" }, { GET, "GET" }, { HEAD...
C
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <fcntl.h> typedef struct _node{ int id; /* node id */ int noc; /* number of children */ struct _node * fc; /* first child */ struct _node * lc; /* last child */ struct _node * ns; /* next sibling */ struct _node * p; /* parent */ }node; #de...
C
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <time.h> #include "timer.h" #include "malloc.h" #include "strlib.h" #define TIMER_MIN_INTERVAL 50 #define TIMER_MAX_INTERVAL 1000 #define cap_value(a, min, max) ((a >= max) ? max : (a <= min) ? min : a) // timers (array) static struct TimerData* t...
C
#include <stdio.h> #include <cs50.h> int main(int argc, string argv[]) { if(argc == 2){ printf("hello, %s\n", argv[1]); } else{ printf("hello, world\n"); } } //Code explanation // int argc is an integer that number of values enterd in the commandline when running scripts // string argv...
C
/* * Filename: Experiment-1 * Description: This experiment is part of Task 1. It is aimed to get you familiar with the AVR Studio 4.17 IDE. This experiment will help you get familiar with debugging techniques. You will be able to locate error in code and remove it to generate effective code * Author: e-Yantra Tea...
C
#include<stdio.h> #include<stdlib.h> int main() { int a[100],pos,len,i; printf("enter the length of the array\n"); scanf("%d",&len); printf("enter the elements for the array\n"); for(i=0;i<len;i++) { scanf("%d",&a[i]); } printf("the elements are \n"); for(i=0;i<len;i++) { printf("%d\n",a[i]); } printf("enter the pos...
C
/* Castles C.A.D. Curso 2011-2012 Codigo base para la realización de las practicas de CAD modulo castle.h ======================================================= 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 ...
C
#include <stdio.h> #include <stdlib.h> struct { int key; int data; } table[100]; int n; int search(int key) { int i; i = 0; while (i < n) { if (table[i].key == key) { return (table[i].data); // found } i++; } return -1; // not found } void add(int key, int data) { if (n >= 100) { ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* key_hook_cone.c :+: :+: :+: ...
C
#ifndef BOARD_H #define BOARD_H #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "arena.h" #include "utils.h" #define EMPTY 0 #define BLACK 1 #define WHITE 2 #define SIZE 9 #define KOMI 1 // white wins ties #define IS_HOSHI(i, j) \ ((i == 2 || i == 6) && (j == 2 || j == 6...
C
#ifndef _IO_H_ #define _IO_H_ #include <stdint.h> #include <curses.h> #define XINIT 10 #define YINIT 5 /*===================================================*/ #define HIGH 1 #define LOW 0 #define Read 1 #define Write 0 #define BLUEBLACK 10 /*Text Blue Background Black*/ #define REDBLACK 20 /*Text Red Background...
C
/* * Practica2.c * * Created: 27/02/2015 22:07:38 * Author: Antonio */ #include <avr/io.h> int main(void) { // set all pins on PORTB for output DDRB = 0xFF; DDRD = 0xFF; DDRC = 0xFF; int nums[10] = { 0x7E, 0x30, 0x6D, 0x79, 0x33, 0x5B, 0x5F, 0x70, 0x7F, 0x7B }; int nums2[10] = { 0x3F, 0x06, 0x5...
C
#include<stdio.h> int fact(int n); void main() { int n,k; printf("enter n value:\n"); scanf("%d",&n); fact(n); printf("fact of given number=%d\n",k); } int fact(int *a) { int n; if(a==0) return 1; else n= a * fact((*a)-1); return n; }