language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <time.h> #include "defn.h" #include "AM.h" char empName[40]; char empAge[40]; char empSal[40]; char dnameAge[40]; void insertEntries(int fd, char * name, int recid) { char errStr[140]; strcpy(errStr, "Error in AM_InsertEn...
C
#pragma once BENC_ENTITY_TYPE benc_entity_type(char* buf){ int i; switch(buf[0]){ case 'd': return T_DICT; case 'l': return T_LIST; case 'i': return T_INT; default: for(i=0;isdigit(buf[i]);i++){//there are dependencies on this } //guaranteeing there is no \0 before ':' when returning T...
C
//binary search #include<stdio.h> int bsearch(int arr[],int lower,int higher,int key) { int mid=lower+(higher-lower)/2; if(arr[mid]==key) return mid; if(arr[mid]>key) return bsearch(arr,lower,mid-1,key); else return bsearch(arr,mid+1,higher,key); } int main() { int n,key; printf("Enter element value:-"); scan...
C
#include <stdio.h> #include <stdlib.h> #include<time.h> void cria_triangulacao (float *vetor, int i, int f){ int auxiliar = vetor[i]; // definindo vetor auxiliar como a primeira posição do vetor (posição inicial) int j = i * 2 + 1; // primeiro ramo while(j <= f){ // enquanto o valor final for maior ou iag...
C
#include <stdio.h> #include <string.h> #define BUF_LEN 50 int func() __attribute__ ((noinline)); void parse(int* ) __attribute__ ((noinline)); int compare(int*, int*) __attribute__ ((noinline)); void parse(int* p) { int a = 0x11111; printf("unused a = %d", a); *p = 123456; } int compare(int* p1, int* p2...
C
#include <stdio.h> int main() { int i,N,num, check, count=0; scanf("%d", &N); while (N--) { check = 0; scanf("%d", &num); if (num == 1) { check = 1; } for (i = 2; i*i <= num; i++) { if (num%i == 0) { check = 1; break; } } if (check == 0) count++; } prin...
C
#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> int f(int n) { if (n > 1) { return n * f(n - 1); } return 1; } int fa(int n) { int m = 1; while (n > 1) { m = m * n; n--; } return m; } int main() { int n = 0; int a; printf("Ҫ֣"); scanf("%d", &n); a = f(n); printf("%d\n", a); a = fa(n); printf(...
C
/* K4-7̉𓚗 */ #include <stdio.h> /*--- ‚̕s1s2 ---*/ void swap_str(char s1[], char s2[]) { char *temp; while (*s1 && *s2) { /* Zق̖܂ŕ */ char t = *s1; *s1++ = *s2; *s2++ = t; } if (*s1) { /* s1̂ق */ temp = s1; while (*s1) { *s2++ = *s1++; } /* s1̎cs2ɃRs[ */ *temp = *s2 = '\0'; } else i...
C
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <time.h> #include <math.h> #include <string.h> #include "matrix.h" void benchmark_mul(int n, int repeats) { double *a = random_matrix(n); double *b = random_matrix(n); double *res = alloc_matrix(n); clock_t start, end; int i; double...
C
#ifndef _ALFA_H #define _ALFA_H #define MAX_LONG_ID 100 #define MAX_TAMANIO_VECTOR 64 #define TRUE 1 #define FALSE 0 #define ERROR -1 #define MAX_VAR 200 /* Numero maximo de variables que puede tener un programa */ /* Categorias */ #define VARIABLE 0 #define PARAMETRO 1 #define FUNCION 2 /* Tipos */ #define INT 0 #de...
C
#include <stdlib.h> #include <stdio.h> int main(int argc, char *argv[]) { int conversion = atoi(argv[1]); printf("Number of blocks to be passed to malloc(): %i\n", conversion); printf("Passing blocks to malloc().\n"); int counter = 0; sleep(3); while (counter < conversion) { char* pointer = malloc(1024); pr...
C
#include "construct.h" #include <stdlib.h> int balance(int t[], int l, int r) { long long mtot = 0, rxm = 0; for ( int i = l, j = 0; i <= r; i++, j++) { mtot += t[i]; rxm += t[i] * j; } if ( rxm % mtot == 0 ) return l + rxm / mtot; return -1; } Node *new_node(in...
C
/*ANGELA GABRIELA PESINA DE LOS SANTOS - 1947576 RESTAURANT MENU */ //library #include <stdio.h> #include <stdlib.h> #include "res.h" //principal function int main (){ int op, rep; do { //open do printf("\t\t***WELCOME TO FIME-STAURANT***\n"); printf("----------------------------------------------...
C
#ifndef _UTILITIES_H #define _UTILITIES_H // Needed to sort array of points according to X coordinate. int compare_x(const void *a, const void *b); // Needed to sort array of points according to Y coordinate. int compare_y(const void* a, const void* b); // A utility function to find the distance between two points. ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* rgb.c :+: :+: :+: ...
C
//The code format should be as below. Excessive commenting and documentations is encouraged as this //project is multi-year. In the future a new group of students will need to pick this project up as //quickly as possible. //***PLEASE NOTE*** the Max line width should be 100 characters. In most IDEs you can set up a ...
C
#include<stdio.h> #define max(a,b) (a>b)?a:b void knapsack(int m,int n,int w[],int p[]) { int v[100][200],x[10],i,j,sum=0; for(i=0;i<=n;i++) v[i][0]=0;//first column all elements=0 for(j=0;j<=m;j++) v[0][j]=0;//first row all elements=0 /*Here, we assume all the given item weights are always lesser than the ...
C
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <string.h> void my_fprintf(char *path) { FILE *fp = NULL; //дʽ fp = fopen(path, "w+"); if (fp == NULL) { perror("my_fprintf fopen"); return; } //printf("hello, i am pig, mike = %d\n", 250); //fprintf(stdout, "hello, i am pig,...
C
#include <stdio.h> #include <stdlib.h> int main() { printf("%-10d\n", 10000);//false printf("%c\n", "This is a string");//false printf("%*.*lf\n", 8, 3, 1024.987654);//true printf("% ld\n%+ld\n", 1000000, 1000000);//true printf("%10.2E\n", 444.93738);//true printf("%d\n", 10.987);//false }
C
#include <stdio.h> #include "sorting.h" #include <stdlib.h> int main() { FILE *file = fopen("/Users/alexandrasyabrenko/Documents/Programming/Lab2/Lab2/test.txt", "r"); int arrayLength = getSymbolsAmout(file); char *array = getFromFileToArray(file); printf("Unsorted array: \n"); printArrayToScreen(array...
C
#include "requete.h" #include "envoi.h" /** * Converti un char* en un entier. * Le char* doit représenter un nombre entre -1 et la taille max * d'un int non signé. */ int parseInt(char* entier) { if(strcmp(entier, "-1") == 0) { return -1; } int res = 0; int i; for(i = 0; entier[i] != '\0'; i++) { char c ...
C
#include <stdio.h> #include "arbol.h" #include "pila.h" #define TAM 100 void imprimeAlgo() { } int main(void) { Pila *p; NodoArb *a, *b, *c, *d; char cad[TAM]; int i; p = creaPila(TAM); printf("Introduce una operación\n"); for (i = 0; i < TAM; i++) { scanf("%[^\n]", &cad[i]); } for (i = 0; cad[i]; i++)...
C
// // main.c // 11【了解】条件编译的概念及优点 // // Created by 高明辉 on 16/2/15. // Copyright © 2016年 itcast. All rights reserved. // #include <stdio.h> #define M 0 #if M == 1 void gm_log(){ printf("这是日志输出"); } #else void gm_log(){ printf("不输出日志"); } #endif int main(int argc, const char * argv[]) { /* #i...
C
#include<stdio.h> void swap (int *a, int x, int y) /*swap method it will be used by qSortHelper and takes as parameters an array and two integers that will be used as indexes for the swap*/ { int temp=a[x]; //setting the value of temp to the first number to be swapped, so the value is not lost a[x]...
C
/* * watches.h * * Memory watch definitions */ #ifndef _LIBUM_WATCHES_H #define _LIBUM_WATCHES_H #include <stdint.h> #ifndef LITE #define WATCHES_MAX 10 #else #define WATCHES_MAX 5 #endif struct watch_info { uint8_t type : 4; uint8_t floating : 4; }; enum watch_type { W...
C
/* Lily has a chocolate bar consisting of a row of n squares where each square has an integer written on it. She wants to share it with Ron for his birthday, which falls on month m and day d. Lily wants to give Ron a piece of chocolate only if it contains m consecutive squares whose integers sum to d. Given m, d, and...
C
#include <stdio.h> int main() { int i = 0xDAEDBEAF; int *pi = &i; size_t size = sizeof(pi) * 8; printf("size: %lu bit(s)\n", size); printf("value: %p\n", pi); printf("memory: %X\n", *pi); }
C
#include<stdio.h>/*2009.9.25晚 写于白鹿原*/ #include <malloc.h> typedef int DataType; typedef struct Node { DataType data; struct Node *LChild; struct Node *RChild; }BitNode,*BitTree; void CreatBiTree(BitNode * BT) { char ch; ch = getchar(); if(ch == '#') { BT = NULL; } else { BT = (BitNode *)malloc(sizeo...
C
#include <stdio.h> #include <math.h> int bit_liczby (int numer, int liczba) { if( (liczba & (int)pow(2, numer)) > 0) return 1; else return 0; } int main() { int a, b; printf("Podaj liczbe\n"); scanf("%i", &a); printf("Podaj numer bitu\n"); scanf("%i", &b); printf("rezultat - %i\n", bit_liczby(b,a)); return 0; ...
C
#include "transport.h" #include "skyline.h" #include <stdio.h> #include <stdlib.h> #include <math.h> df_transport null_dft = {0}; //Condition au bord gauche double g(double t) { return exp(-t); } int main(void){ df_transport dft = null_dft; int nx = 1000; double Lx = 1; init_df_transport(&dft, nx, Lx); /...
C
#include <stdio.h> #define NO_OUT 1 #if NO_OUT == 1 #define ERROUT0(fmt) #else #define ERROUT0(fmt) vce_errout((fmt)) #endif void vce_errout( char *hoge ) { fprintf( stderr, "%s aho \n", hoge ); } int main() { ERROUT0( "aho\n"); }
C
#include <stdlib.h> #include <stdio.h> #include <unistd.h> int main(void) { int n; int fd[2]; pid_t pid; char line[100]; if (pipe(fd) < 0) printf("pip error"); if ((pid = fork()) < 0) printf("fork error"); else if (pid > 0){ close(fd[0]); write(fd[1], "hello...
C
#include<stdio.h> int main(void) { int numbers[] = {9,8,7,6,5,4,3,2,1,0}; int sort[10]; int swapc = 1,i = 0; while(swapc != 0) { swapc = 0; if(i > 9) i = 0; if (numbers[i] > numbers[i+1]) { sort[i] = numbers[i+1]; sort[i+1] = numbers[i]; swapc++; ...
C
#include <signal.h> #include <stdio.h> #include <unistd.h> //void (*signal(int signo, void (*func )(int)))(int); //typedef void sigfunc(int); //sigfunc *signal(int, sigfunc *); void my_assert() { kill(getpid(), SIGSEGV); } void signal_handler(int signo) { if (signo == SIGINT) { printf("SIGINT recei...
C
#include <stdio.h> int main() { int num; scanf_s("%d", &num); while (num >= 1200) { num -= 1200; printf("%d\n", num); } }
C
#include <xinu.h> #include <stdio.h> void printPacket(struct netpacket * ); shellcmd xsh_sendpkt(int nargs, char * args[]) { printf("\nSending packet...\n"); if (nargs != 3) { //print usage printf("USAGE: sendpkt <destination> <message>\n"); return 0; } //TODO: sanity chec...
C
/* Find PI using Monte Carlo algoritm. Total CPU processes: 4. References: https://www.geeksforgeeks.org/estimating-value-pi-using-monte-carlo/ https://www.tutorialspoint.com/c-program-to-demonstrate-fork-and-pipe https://tldp.org/LDP/lpg/node11.html */ #include <stdio.h> #include ...
C
#include <stdio.h> #include <climits> int main(){ long long unsigned int shelf = 0; int book; while(scanf("%d", &book) != EOF){ //from shelf int inshelf = 0; int index; long long unsigned int tmp = 255; //on shelf and which position for(int i=0; i<8; i++){ if(((shelf >> 8*i) & tmp) == book){ i...
C
/* driver for enorm example. */ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <assert.h> #include <minpack.h> #define real __minpack_real__ #ifdef __cminpack_double__ #define N1 3 #define N2 367 #define SQRTFAC 1.5 #define FAC 10. #endif #ifdef __cminpack_long_double__ #define N1 3 #define N...
C
#include <stdio.h> #include <stdlib.h> void lireArrangement( FILE * flujo, int tailleArrangement ){ int array [ tailleArrangement ]; fread( array, sizeof( int ), tailleArrangement, flujo ); fclose( flujo ); printf( "Leyendo el archivo\n" ); for (int i =0 ; i < tailleArrangement; i++ ){ printf( "Arreglo en la po...
C
/***************************************************************************//** @file listtest.c @author Stephen Brennan @date Friday, 6 March 2015 @brief Libstephen: Generic list tests. @copyright Copyright (c) 2013-2016, Stephen Brennan. Released under the ...
C
#include <stdio.h> #include <stdlib.h> #include "storage_mgr.h" #include "dberror.h" #include <sys/stat.h> #include <string.h> //File header contains total number of pages #define PAGELEN 4 //We need a global variable to reset values if a file is closed or destroyed SM_FileHandle *sm_fileHandle; void initStorageMana...
C
#include <stdlib.h> #include <stdio.h> typedef struct _nodo { int dato; struct _nodo* sx; struct _nodo* dx; } nodo; typedef struct _cercaprof { int profond; int trovato; } cercaprof; nodo* Inserisci(nodo* radice, int input) { if(radice == NULL) { nodo* nuovo = malloc(sizeof(nodo)); (*nuovo).dato = input; ...
C
#include "flow.h" #include "imu.h" #include "imath.h" #include "math.h" _FLOW flow = {0}; //光流数据包接收 void flow_parse(u8 data_packet) { u8 sum = 0; switch(flow.step) { case 0: //帧头 if(data_packet==0xFE) { flow...
C
void main() { char intonumber(char x); char intochar(int y); char str[N]; gets(str); int i=0,c1=0; while(str[i]!=' ') { c1=c1*10+intonumber(str[i++]); } while(str[i]==' ') i++; unsigned long n1=0; while(str[i]!=' ') { n1=n1*c1+intonumber(str[i++]); } while(str[i]==' ') i++; int l1=0; wh...
C
/* * main.c * * 20493-02 Computer Architecture * Term Project on Implentation of Cache Mechanism * * Skeleton Code Prepared by Prof. HyungJune Lee * Nov 13, 2017 * */ #include <stdio.h> #include <math.h> #include "cache_impl.h" int num_cache_hits = 0; int num_cache_misses = 0; int num_bytes = 0; int num_acc...
C
#include<stdio.h> //not working int main(){ int x , y , i , n ; y = 1; scanf("%d%d",&x,&n); while(1<=n){ y = x*n; printf("%d",y); i++; } printf("%d",y); }
C
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> int main() { int i, index, k, n, temp; int a[10]; scanf("%d", &n); for(i=0; i<n; i++) scanf("%d", &a[i]); for(k=0; k<n-1; k++){ index=k; for(i=k+1; i<n; i++) if(a[i]>a[index]) index=i; temp=a[index]; a[index]=a[k]; a[k]=temp; } printf("%d", a...
C
#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> #include <string.h> //在一个「平衡字符串」中,'L' 和 'R' 字符的数量是相同的。 //给出一个平衡字符串 s,请你将它分割成尽可能多的平衡字符串。 //返回可以通过分割得到的平衡字符串的最大数量。 int balancedStringSplit(char * s) { int len = strlen(s); int i = 0; int count = 0; int a = 0; int b = 0; for (i = 0; i < len; i++) { if (s[i] =...
C
// һУظĽ㣬ɾظĽ㣬ظĽ㲻ͷָ롣 class Solution { public: ListNode* deleteDuplication(ListNode* pHead) { // Ϊ ֻһڵʱֱӷ if (pHead == NULL || pHead->next == NULL) { return pHead; } ListNode *prev = NULL; ListNode *cur = pHead; ListNode *next = pHead->next; while (next) { if (cur->val != next->val) { ...
C
#include <stdio.h> #include <stdlib.h> #include <conio.h> #include <ctype.h> #include <string.h> #include <time.h> #include "funciones.h" int igresoCadenaChar(char texto[],char dato[]) { int flag=-1; if(texto!=NULL&&dato!=NULL) { flag=0; printf("%s",texto); fflush(stdin); ge...
C
#include<stdio.h> void main() { int a,b,ch; printf("1.add\n2.subtract\n3.multiply\n4.division\n5.square of number\n"); printf("enter your choice: "); scanf("%d",&ch); if (ch==1 || ch==2 || ch==3 || ch==4) { scanf("%d %d",&a,&b); if (ch==1) { printf("the sum of %d and %d is %d\n",a,b,a+b); } else if (ch==2) { ...
C
#include<stdio.h> #include<errno.h> #include<stdlib.h> #include<unistd.h> #include<sys/wait.h> int main(void) { pid_t pid_fils; do { pid_fils = fork(); } while ((pid_fils == -1) && (errno == EAGAIN)); if (pid_fils == -1) { fprintf(stderr, "forfk() impossible, errno=%d\n",errno); return 1; } if (pid_fils ...
C
/*** *heapsrch.c - search the heap for a free block * * Copyright (c) 1989-1997, Microsoft Corporation. All rights reserved. * *Purpose: * Defines the _heap_search() function. * *******************************************************************************/ #ifndef WINHEAP #include <crunt...
C
#include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/stat.h> #include <sys/shm.h> #include <semaphore.h> #include "../helpers/alert_helpers.h" int main(){ sem_t *sem; char *mem_pointer; int memory_handle; memory_handle = shmge...
C
#include<stdio.h> int scan(int *a,int,int); int print(int *c,int ,int); int main() { int m,n,x,y; printf("Enter the dimensions of matrix A"); scanf("%d %d", &m,&n); printf("Enter the dimensions of matrix B"); scanf("%d %d", &x,&y); int a[m][n], b[x][y] ,c[m][n]; int *p=a[m][n],*q=b[x][y]; scan(p,m,n); scan(q,x,y); if(m...
C
/* * File: Random.c * Author: abutel * * Created on January 03, 2016, 02:04 PM */ #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> #include "Random.h" #include "Memory.h" #include "Math.h" #include "PrintManage.h" /**************************************************************/ ...
C
#include "config.h" #include "memory.h" #include "basic_dict.h" #include "utils.h" #include <stdio.h> #include <string.h> #include <assert.h> struct config * config_init(struct memory *mem) { assert(mem); struct config *context = memory_alloc(mem, sizeof(struct config)); context->_mem = mem; context-...
C
/* * [TEST] Macierz odwrotna - Metoda dopelnien algebraicznych */ #include "inversion.h" #define EPS 0.0001 bool FloatEquals(float a, float b) { return fabs(a - b) < EPS; } void printMatrixInt(int* a, uint size) { for(uint i = 0; i < size; ++i) { for(uint j = 0; j < size; ++j) { printf("%d ", a[i ...
C
#include <stdlib.h> #include <string.h> #include "hash_table.h" #ifndef HASH_TABLE_SIZE #define HASH_TABLE_SIZE 5 #endif // According to http://www.cse.yorku.ca/~oz/hash.html int compute_hash(const char *key, int size){ unsigned long hash = 5381; int c; do{ c = *key; hash = hash*33 + c; key++; ...
C
#pragma once unsigned strhash(const char *str) { unsigned hash = 1; for(size_t i = 0; str[i]; i++) hash = 92821 * hash + str[i]; return hash; }
C
#include <fcntl.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #include <assert.h> static const long k_defaultBlockSize = 4096; long get_block_size() { long size = sysconf(_SC_PAGESIZE); if (size < 0) { return k_defaultBl...
C
void main() { struct point{int x; int y;}; struct point l[2]; l[0] = {13, 14}; l[1] = l[0]; assert(l[0].x == 13, "l[0].x must be 13"); assert(l[0].y == 14, "l[0].y must be 14"); assert(l[1].x == 13, "l[1].x must be 13"); assert(l[1].y == 14, "l[1].y must be 14"); }
C
#include "holberton.h" /** * _isupper - C F T U C C. * @c: T I C * Return: 1 I I I U A 0 O. */ int _isupper(int c) { if (c > 64 && c < 91) return (1); return (0); }
C
#include <iostream> #include <string> #include <stack> #include <queue> #include <climits> #include <cfloat> using namespace std; /**********************************************************/ /******** GLOBAL TYPES, CONSTANTS, AND VARIABLES **********/ /**********************************************************/ // d...
C
// Ex 1.3.2: Calculates the area of a right traingle from user inputs (base, height) #include <stdio.h> int main() { float base, height, area; printf("RIGHT TRIANGLE AREA\n\n"); // Ask user for the base and height printf("Please enter length of triangle's base: "); scanf("%f", &base); printf("Pleas...
C
#define _REENTRANT #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <sys/types.h> #include <dirent.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/socket.h> #include <netinet/in.h> #include <string.h> #include <sys/uio.h> #include <unistd.h> #include <pthread.h> #include "server.h" extern i...
C
/* * * This code calculates the house price of a house by learing from * training data. It uses pseudo inverse of a given matrix to find the * weight of different features. * * Predicted Price : Y = W0 + W1*x1 + W2*X2 + W3*X3 + W4*X4 * Weight Matrix : W = pseudoInv(X)*Y * pseudoInv(X) = inverse(transpose(X)...
C
#include<stdio.h> int main(void){ //Question1 float a,b,c; printf("Please enter first value"); scanf("%f",&a); printf("Please enter second value"); scanf("%f",&b); printf("Please enter third value"); scanf("%f",&c); printf("%f",(a+b)/2+3*c); return 0; //Question2 int numbe...
C
/* ******** Reference design #6 LCD Pong Ping with Mutes Semaphores ********* * Author: Richard Wall * Date: September 29, 2011 * Revised: December 22, 2012 * Revised: September 25, 2013 * * Description: An example of FreeRTOS running on an chipKIT Pro MX7 * board with a PIC...
C
#include<stdio.h> #include<math.h> int main() { int pows,a,b; scanf("%d%d",&a,&b); pows=pow(a,b); printf("%d",pows); return 0; }
C
/***********************************************************/ /* */ /* winsuport2.h */ /* */ /* definicio de constants i prototipus de funcions per */ /* utilitzar la interficie d'acces a "curses" implementada */ /* al modul winsuport2.c */ /* */ /*****************************...
C
#include <unistd.h> #include <fcntl.h> #include <errno.h> #include <stdio.h> #include <string.h> #include <signal.h> #include <sys/types.h> #include "calculations.h" int output_fd; char input[20]; // to understand if the p1 process is finished. int isFinished = 0; // SIGUSR1 handler // If SIGUSR1 signal is sent, t...
C
/* Направете глобална константа pi = 3.14, както правихме в предишния урок. Напишете функция, която изчислява площта на кръг, на която като параметър подаваме радиуса и връщаме площта на кръга. Използвайте глобалната константа pi, за да извършите изчисленията. Извикайте функцията в main() и покажете резултата. */...
C
#include "getFileByFirstLetter.h" #include <signal.h> // For sigaction() #include <wait.h> // For waitpid() #include <dirent.h> // For opendir(), readdir(), closedir() #define LINE_LEN 256 const int LO_LEGAL_PORT = 1025; const int HI_LEGAL_PORT = 65535; const int ERROR_FD = -1; const int NUM_CLIENT...
C
int ft_strlen(char *str); int ft_strlen(char *str){ int i=0; int count =0; while(str[i]){ count++; i++; } return count; }
C
#ifndef __DECK_H__ #define __DECK_H__ #include <stdint.h> #include "card.h" typedef struct deck { uint8_t capacity; // number of cards in a full deck uint8_t size; // number of cards in the current deck card_t* cards; // pointer to array of cards } deck_t; void print_deck(deck_t* deck); int deal_card(de...
C
#ifndef DOG_H #define DOG_H /** *struct dog - a structure that creates variables used in the main function *which is also accessed in the main function *@name: A pointer pointing to a string *@age: A float that takes in an a number *@owner: A pointer variable that points to a string */ struct dog { char *name; ...
C
// Program to trapping rainwater problem. #include<stdio.h> #include<conio.h> void main() { int n,i,j,ind1,a[20],m,s=0; clrscr(); printf("Enter size of data of mapping\n"); scanf("%d",&n); printf("Enter %d data value\n",n); for(i=0;i<n;i++) { scanf("%d",&a[i]); } ...
C
#include <stdio.h> #include <stdlib.h> // compteur nb additions. int nb_add=0; /** * Fibonacci avec affichage de la pile d'appel */ int fibo_rec(int n, char* pile) { char localPile[1024]; sprintf(localPile,"%s / %d ",pile,n); printf("Fibo(%d): %s \n",n,localPile); if (n==0) return 0; if (n==1) return 1; nb_add...
C
#include <stdio.h> #include <stdlib.h> #include "board.h" void init_board(int player_count, struct board* b, struct player* p) { b->number_of_players = player_count; for (int i = 0; i < player_count; ++i) { b->player_list[i] = &p[i]; p[i].id = i; init_player(&p[i]); } } void display_board_informatio...
C
#include"bank.h" #include<stdio.h> #include<stdlib.h> #include<sys/types.h> #include<sys/msg.h> #include<sys/ipc.h> #include<signal.h> #include<sys/wait.h> static int msgid1; static int msgid2; //创建消息队列 void init(void){ printf("服务器正在初始化,请稍后...\n"); sleep(2); //创建第一个消息队列 msgid1 = msgget(key1,IPC_CREAT|IPC_EXCL...
C
// Included header files #include "terminal.h" #include "helpers.h" #include "events.h" #include "interface.h" /* Source StackOverflow From http://stackoverflow.com/a/6857444 Author Daniel Leschkowski - http://stackoverflow.com/users/839180/daniel-leschkowski Editor Tim Cooper - http://stackoverflow.com/users/1...
C
#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { /* ŧir}CΨӦsr */ char str[15]="Hello!zn"; printf(" ==|123456789012345|==\n"); printf("1. |%s|\n",str); printf("2. |%5s|\n",str); printf("3. |%15s|\n",str); printf("4. |%-15s|\n",str); printf("5. |%10.2s|\n",str); printf("6. |...
C
#include<stdio.h> #include<stdlib.h> #include <sys/time.h> #include <time.h> /* struct timespec { time_t tv_sec; long int tv_nsec; }; */ int main() { struct timespec timeout; timeout.tv_sec= time(0) + 1; //time(0) ǵǰʱ tv_sec ָ timeout.tv_nsec=0; //printf("time(0) = %ld\...
C
#include<stdio.h> #include<stdlib.h> #include"struct.h" #include<math.h> int max(int p,int q) { if(p>q) return p; else return q; } int height(btree *root) { if(root==NULL) return 0; return max(height(root->lchild),height(root->rchild))+1; } btree *insertelementlevel(btree **root,int level) { if(level==1) { ...
C
//============================================================================================================= //If clauses to check if the user s inputs are logical if (energylab < 0) { cout << "Warning: The beam energy cannot be negative or zero. The beam energy is set by default at 0.01 MeV" << endl; en...
C
#include<stdio.h> int main(){ int vezes =0, x =0, atual =0; long long int vet[9999], a =0, b=0; int fbo=0, i =0; scanf("%d", &vezes); int vet2[9999]; for(x;x<vezes; x++) { a=1,b =0; i =0; scanf("%d", &fbo); vet[x]=0; vet2[x]=fbo; for(i;i<fbo;i++) { vet[x]=vet[x]+a; a = b; b=vet[x]; }...
C
/* range of armstrong numbers 100 t0 200 */ #include<stdio.h> #include<stdlib.h> int main() { int i, n=100,sum=0, temp; temp = n; for (n=100; n <= 200; n++) { while (n>0) { i = n%10; sum+= i*i*i; n = n/10; } if (sum == n) { printf(" %d\n",sum); } } }
C
#define NULL ((void*)0) typedef unsigned long size_t; // Customize by platform. typedef long intptr_t; typedef unsigned long uintptr_t; typedef long scalar_t__; // Either arithmetic or pointer type. /* By default, we understand bool (as a convenience). */ typedef int bool; #define false 0 #define true 1 /* Forward d...
C
// // Created by Stephen on 22/01/2018. // #include <stdint.h> #include "main.h" #ifndef INTERPRETER_COMMANDS_H #define INTERPRETER_COMMANDS_H void exec_CMP_char(char op1_val, char op2_val); void exec_CMP_uchar(unsigned char op1_val, unsigned char op2_val); void exec_CMP_short(int16_t op1_val, int16_t op2_val); void...
C
#include "list.h" void INIT_LIST_HEAD(struct list_head *list) { list->next = list; list->prev = list; } void _list_add(struct list_head *new,struct list_head *prev,struct list_head *next) { next->prev = new; new->next = next; new->prev = prev; prev->next = new; } void list_add(struct list_head *new, struct lis...
C
// "../Debug/Parsing_Debug.c" version 0.0 // gcc -std=c99 "Parsing_Debug.c" -o "Parsing_Debug.exe" #include <stdio.h> // #include "../Core/Parsing.h" #include "Parsing.h" int main( void ){ char Test_String[512]; int Test_Integer; long int Test_Long; float Test_Float; ...
C
#include "LineSeparator.h" #define SEPARATOR "," // Macro for a function for reading a line. #define READ_LINE(l, f) fgets(l, MAX_LINE_LENGTH, f) // The 'read' token for the fopen function #define READ_ONLY "r" // Enums for the command line arguments that are given to this program. enum { PROG_NAME = 0,...
C
// IOS - 2. projekt // Author: Jakub Svoboda // Login: xsvobo0z // Date: 13.4.2016 #include <stdio.h> #include <stdlib.h> #include <sys/wait.h> #include <sys/types.h> #include <unistd.h> #include <time.h> #include <semaphore.h> #include <fcntl.h> #include <string.h> #include <sys/mman.h> #include <sys/ipc.h> int argu...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* eat_sleep_think.c :+: :+: :+: ...
C
#include <stdio.h> #include <pthread.h> #include <time.h> #include <stdlib.h> typedef struct Matrix{ int matrix1[3][3]; /* A matrix */ int matrix2[3][3]; /* B matrix */ int multiply[3][3]; /* result */ }Matrix; void* matrix1(void* arg){ Matrix* arg_s = (Matrix*)arg; for(int i=0; i<3; i++){ for(int j=0; j<3; j+...
C
#include <stdio.h> #include <cs50.h> int main(void) { int height; int spaces; int hashes; do{ printf("Height: "); height = get_int(); } while(height < 0 || height > 23); for(int i = 0; i < height; i++) { for(spaces = height - i; spaces > 1; spaces--) {...
C
#include <stdio.h> void Swap(int *prt1,int *prt2) { int temp = *prt1; *prt1 = *prt2; *prt2 = temp; } void main() { int start = 96 , end = 6; printf("현재값 = %d, %d ",start , end); if(start > end) { Swap(&start , &end); } printf("현재값 = %d, %d ",start , end); } // void...
C
// // This is the main program on the BBB // It launches the DSP code on PRU 0 (slave) // It also launches the I2S and sample period code on PRU 1 (master) // At the end we start tclsh as a child process. // #include <stdio.h> #include <stdlib.h> #include <assert.h> #include <stdint.h> #include <math.h> #inc...