language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char* argv[]) { char* line1 = NULL; char* line2 = NULL; char tok[1024]; char* t; char* lr1 = NULL; char* lr2 = NULL; char* c1 = NULL; char* c2 = NULL; FILE* in = fopen(argv[1], "r"); FILE* out = fopen(argv[2], "a")...
C
#include <stdio.h> #include <stdlib.h> void insertsort(int &array, int elemente) { int i,j,k,t; for(i=2;i<=elemente;i++) { j=i; t=array[i]; k=t;
C
#include <stdio.h> #include <string.h> int mystrcmp(char *str1, char *str2); int main() { int i = 0; int y, x = 0; /* * i is evaluated then incremented * ex: when i = 9, it will get evaluated and then incremented to 10 * Below prints from 1 to 10 * */ while (i++ < 10) { printf("\n[Debug] i++ %i",...
C
/***************************************************** * Copyright 2016 Bumjin Im, Patrick Granahan * * * * COMP 421/521 Lab 3 (Yalnix yfs) test code * * create_close.c * * ...
C
#include<stdio.h> #include<string.h> #include<json-c/json.h> #include "json_parser.h" #include "json_msg.h" #include "daemonLog.h" //this function create json_object when you need json_object struct json_object* json_createObject(void) { struct json_object *ret; ret = json_object_new_object(); if(ret==NULL) { ...
C
//General Library #include "unity.h" #include <malloc.h> #include <stdint.h> #include <stdlib.h> #include <stdio.h> //STM32F1XX standard Library #include "stm32f10x_rcc.h" #include "stm32f10x_spi.h" #include "stm32f10x_tim.h" #include "stm32f10x_gpio.h" //Own Library #include "Host.h" #include "Linklist.h" #include "Re...
C
#include <stdio.h> int linearSearch(int a[],int size,int element) { for(int i=0;i<size;i++) { if(a[i]==element) { return i; } } return -1; } int main() { int a[6]={1,2,3,4,5,6}; int search; ...
C
#include<stdio.h> #include<conio.h> #include<stdlib.h> int main(){ int *ptr; ptr=(int*)malloc(10*sizeof(int)); printf("\n7 Table till 10"); for(int i=0;i<10;i++){ ptr[i]=7*(i+1); printf("\n7 x %d =%d ",i+1,ptr[i]); } ptr=realloc(ptr,15*sizeof(int)); printf("\n\n7 Tab...
C
#include<stdlib.h> #include<string.h> int main() { sigset_t s1,s2; char buf1[512]; struct sigaction act1,act2; int ret; sigemptyset(&s1); sigaddset(&s1,SIGINT); sigaddset(&s1,SIGQUIT); act1.sa_handler = SIG_DFL; //default action to be installed sigfillset(&act1.sa_mask); // all signals are ma...
C
#include<stdio.h> const int WORK_WEEK_MAX_HOURS=40; const int MAX_NAME=20; float addOT(float workedHours, float hourly) { float overtimeHrs, overtimeRate, overtimePaid; overtimeHrs = workedHours - WORK_WEEK_MAX_HOURS; overtimeRate = (hourly * 1.5); overtimePaid = overtimeRate * overtimeHrs; return overtimeP...
C
/* Return the file system path of the object. If the object is str or bytes, then allow it to pass through with an incremented refcount. All other types raise a TypeError. */ PyObject * PyOS_RawFSPath(PyObject *path) { if (PyObject_HasAttrString(path, "__fspath__")) { path = PyObject_CallMethod...
C
#include "mylib.h" // Prototypes void setPixel(int , int , unsigned short ); void drawRect(int row, int col, int height, int width, unsigned short color); void delay(int n); void waitForVblank(); int rand(); int canMoveRight(int row, int col); int isGround(int row, int col); int canMoveLeft(int row, int col)...
C
/* * check_bloomFilter.cpp * * Copyright 2010-2012 Yahoo! Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless require...
C
// quickSort.c #include "stdio.h" #include "stdlib.h" void swap(int *a,int *b) { int temp; temp = *a; *a = *b; *b = temp; } void all(int *array,int length) { for (int i = 0; i < length; ++i) { printf("%d ",*(array+i)); } printf("\n"); } int quickSort(int *a,int left,int right) { int pivot; int i = left,...
C
#include <stdio.h> #include <ctype.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <arpa/inet.h> #include <sys/types.h> #include <netinet/in.h> #include <sys/socket.h> int main(int argc, char *argv[]) { struct sockaddr_in dest; struct sockaddr_in serv; char buffer[513]; int connectSocket; ...
C
/* play_again1.c * * purpose: ask if user wants another transaction * method: ask a question, wait for yes/no answer * returns: 0=>yes, 1=>no * better: do no echo inappropriate input * * version 0.1 * immediate response * */ #include <stdio.h> #include <termios.h> #define QUESTION "Do you want an...
C
#include <stdio.h> #include <stdarg.h> #include "memalloc.h" #include "list.h" #include <debug.h> #include <pthread.h> #define debug //#define verbose static struct list free_list; // list of free blocks static pthread_mutex_t lock; /* Comparator for Pintos list functions. */ static bool mem_block_less(const struc...
C
// Copyright (c) Edgeless Systems GmbH. // Licensed under the MIT License. /* This mmap implementation manages the whole enclave heap memory. The first pages are reserved for a bitmap that saves the state of all other pages: 1 if the page is in use, 0 otherwise. malloc calls mmap to reserve enclave heap space. */ #in...
C
#include <stdio.h> #include <stdlib.h> int pilihanawal; int main() { puts("BATTLE OF OLYMPIA"); puts("1. New Game"); puts("2. Load Game"); printf("Masukkan pilihan : "); scanf("%d", pilihanawal); switch (pilihanawal) { case 1 : } }
C
#include <stdio.h> #include <stdlib.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char *argv[]) { int number[10]; int i = 0; float media; printf("Insira 10 numeros: "); for(i = 0; i < 10; i++){ scanf("%d", &number[i]); media += nu...
C
#include "AST.h" #include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include "Util.h" #include "Error.h" char const * operator_bin_to_str(Operator_Bin operator) { switch (operator) { case OPERATOR_BIN_ASSIGN: return "="; case OPERATOR_BIN_LOGICAL_AND: return "&&"; case OPERATOR_BIN_LOGICAL_OR: ...
C
// Integer overflow for educational reasons, discard the warning of the compiler #include <stdio.h> #include <limits.h> #include <float.h> int main(void) // demonstration of overflow and underflow behavior of int and float types { printf("INT_MAX \t= %d\n", INT_MAX); printf("INT_MAX + 1 \t= %d\n\n", INT_MAX + 1); ...
C
#include<stdio.h> #include<stdlib.h> #include"sqlite3.h" #include<string.h> int main(int argc,char **argv) { // 校验参数有效性 char *dbname = argv[1]; char *tablename = argv[2]; if (argc < 3) { printf("Error: Must specific a db file and select table name\n"); printf("\nUsage:\n\t%s file.db table_name...
C
#include<stdio.h> #include<string.h> char sen[200]; char tar[200]; int mark[200]; ///E --> E+E | E-E | E*E | E/E | (E) | a | b | c struct st{ int value; int index; }ar[200]; void Sort(int n) { int i, j, a, b; for (i = 0; i < n; ++i) { for (j = i + 1; j < n; ++j) { if (ar...
C
// EX 1.19 #include <stdio.h> // a program that reverses the input, one line at a time. # define MAXLENGTH 1000 char line[MAXLENGTH]; void reverse(char l[], int length); int getLine(char l[], int lim); main(){ int len = 0; while((len = getLine(line, MAXLENGTH)) != 0){ reverse(line,len); pr...
C
/*for undirected graph by adjacency matrix*/ #include <stdio.h> #include <stdlib.h> #include <malloc.h> struct adjmat { int v; int e; int **adj; }; struct adjmat* graph() { int i,j,w,m,n; char x,y; struct adjmat *z=(struct adjmat*)malloc(sizeof(struct adjmat)); printf("Enter the number o...
C
#include <stdio.h> void merge(int ary1[5], int ary2[5], int ary3[10]); int main(void) { int ary1[5], ary2[5]; int ary3[10]; int i; printf("Input arrayA: "); for(i = 0; i<5; i++) { scanf("%d", &ary1[i]); } printf("Input arrayB: "); for(i = 0; i< 5; i++) { scanf("%d", &ary2[i]); }...
C
#include<stdio.h> #include<GL/gl.h> #include<GL/glut.h> #include<string.h> #include<math.h> /* Function that returns -1,0,1 depending on whether x */ /* is <0, =0, >0 respectively */ #define sign(x) ((x>0)?1:((x<0)?-1:0)) int ww = 640, wh = 480; int first = 0; int xi, yi, xf, yf; int count=0; int xmin=-50,ymin=-50,xmax...
C
#include "../opcode.h" /* struct opcode_group_one_byte { unsigned char byte; the byte of the main opcode unsigned char reg; what must modrm->reg be ? enum mode mode; default operand mode unsigned short operand1; flags unsigned short operand2; flags enum opcodes opcode; / constant for mnemonic...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> typedef struct _student_info{ unsigned char student_id[20]; unsigned char department_id; unsigned char department_name[40]; unsigned char grade; unsigned char name[80]; unsigned char birthday[20]; }student_info; void Selection_Sort(st...
C
#include <stdio.h> #include <stdlib.h> #define TURE 1 #define FALSE 0 #define OK 1 #define ERROR 0 #define INFEASIBLE -1 #define OVERFLOW -2 typedef int Status; typedef int KeyType; typedef struct BiTNode{ KeyType data; struct BiTNode *lchild,*rchild; }BiTNode,*BiTree; Status Visit(KeyType e) { printf("%...
C
#include <stdio.h> #include <string.h> int main(void){ char string[1024], word[512][16]; gets(string); printf("%s\n",string); int i, len = strlen(string); int if_l = 0, if_n = 0, count = -1, k = 0; for(i = 0; i < len; i++){ if((string[i] >= 'a' && string[i] <= 'z') || (string[i] >= 'A' && string[i] <= 'Z')) ...
C
/* Given a string, reverse only vowels in it. Leave the remaining string as it is. Input Format One string. Constraints 1 <= Length of string <= 10^5 Output Format One string, the original string with vowels reversed. Sample Input 0 trumpisshit Sample Output 0 trimpisshut Explanation 0 ...
C
#include "ArrayList.h" #ifndef _DEPOSITOS_H #define _DEPOSITOS_H typedef struct { int idProducto; char descripcion[50]; int cantidad; }Depositos; #endif// _DEPOSITOS_H Depositos* depositos_new(int idProducto,char* descripcion,int cantidad); void depositos_delete(Depositos* this); ...
C
/* * trsm.h */ #pragma once #include <stdio.h> #include "matrix.h" #include "gemm.h" void trsm_loop(matrix L, matrix B) { long m = B.n_rows; long n = B.n_cols; long i, j, k; /* n * (m + (m - 1) + ... + 1) = 1/2 n m (m + 1) */ for (k = 0; k < m; k++) { real lkk_inv = 1.0 / L(k,k); /* n (m - k...
C
#include <stdio.h> #include <malloc.h> int func(int n) { int i = 0; int ret = 0; int* p = (int*)malloc(sizeof(int) * n); do { if( NULL == p ) break; // 注意这里break的用法 if( n < 5 ) break; if( n > 100) break; for(i=0; i<n; i++) { ...
C
#include <stdio.h> #include <stdlib.h> int main() { int n, x1, y1, x2, y2, i, j; int** a; scanf("%d", &n); a = (int**)malloc((n + 1) * sizeof(int*)); for (i = 1; i <= n; i++){ a[i] = (int*)malloc((n + 1) * sizeof(int)); } while (1){ scanf("%d", &x1); if (...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> #include <unistd.h> #include <sys/ipc.h> #include <sys/sem.h> #include <sys/shm.h> #include <sys/types.h> #include "function.h" #include "pile.h" #define LG_CHAINE 1024 int *adjM = NULL; // pointeur d'attachement shared memory == matrice...
C
#include<stdio.h> #include <stdlib.h> #include <string.h> #include <dirent.h> void return_pid(char *result); void return_thread(char *result,char *number); void return_child(char *result,char *number); void return_name(char *result,char *number); void return_state(char *result,char *number); void return_cmdline(char *r...
C
#include"coordonnee.h" coordonnee_t creer_coordonnee(int x,int y){ coordonnee_t pos; pos.x=x; pos.y=y; return pos; }
C
#include<stdio.h> #include<stdlib.h> //为qsort准备的比较函数! int cmp(const void *a,const void *b) { //把a,b先由一般形式 void *,转化为我们需要的int *形式! //const是为了保证我们不去修改它! return *(int *)a-*(int *)b; } int main() { int n,w; //n代表有n个男孩,也代表有n个女孩! //w代表茶壶的总容量! scanf("%d%d",&n,&w); int i; //我们创建一个2n长度的数组a! ...
C
// Задача callCost // Условие задачи // Считать с клавиатуры 2 целых числа - номер телефона и количество минут. // Стоимость минуты разговора составляет 1$ за звонок на городской номер и 40$ за // звонок на короткий номер. За звонок по номерам специальных служб плата не взимается. // В случае неопределенности выве...
C
#include <linux/module.h> //所有模块都需要的头文件 #include <linux/init.h> // init&exit相关宏 MODULE_LICENSE("GPL"); MODULE_AUTHOR("feifei"); MODULE_DESCRIPTION("hello world module"); static int __init hello_init(void){ printk(KERN_ERR "hello world"); return 0; } static void __exit hello_exit(void){ printk(KER...
C
/* This program adds two matrices of order 3x3. */ #include<stdio.h> #include<conio.h> #include<stdlib.h> void main() { int x[3][3],y[3][3],z[3][3],r,c; clrscr(); gotoxy(10,3); printf("MATRIX 1"); gotoxy(30,3); printf("MATRIX 2"); gotoxy(50,3); printf("SUM 1 & 2"); gotoxy(22,6); printf("+"); gotoxy(4...
C
/* * input_validation.c * Author: Gabriel Servia */ #include "input_validation.h" /** * \brief Verifica si la cadena ingresada es un texto valida * \param cadena Cadena de caracteres a ser analizada * \param len Define la longitud de la cadena * \return Retorna 1 (verdadero) si la cadena es valida y 0 (falso) ...
C
#include <stdio.h> int sumMultiplesOf3And5(int max); int sumMultipleOfMax(int multiple, int max); int main(void) { printf("%i\n", sumMultiplesOf3And5(10)); // 23 printf("%i\n", sumMultiplesOf3And5(1000)); // 233168 return 0; } int sumMultiplesOf3And5(int max) { return sumMultipleOfMax(3, max) + sumMultipleOfMax(...
C
#include <stdarg.h> #include <stddef.h> #include <setjmp.h> #include <cmocka.h> #include <stdbool.h> #include "../lib/shell.c" /* A test case that does nothing and succeeds. */ static void null_test_success(void **state) { char command0[18]; sprintf(command0, "-c %s /bin/ls ; %s", "\"", "\""); printf("com...
C
#include <stdio.h> int main() { int age; printf("Enter your age;"); scanf("%d", &age); if( age > 17 ){ printf("You not a kid\n"); } else if(age < 17){ printf("You a kid :) \n"); } return 0; }
C
#ifndef __GLOBAL_DEFINE_H__ #define __GLOBAL_DEFINE_H__ #define CHECK_NULL(ptr, ret) \ { \ if (NULL == ptr) \ { \ printf("ptr is null"); \ return ret; \ } \ } #endif // __GLOBAL_DEFINE_H__
C
#include "../../include/netif.h" #include "../../include/ethernet.h" #include "../../include/arp.h" #include "../../include/lib.h" #define BROADCAST_ADDR ((unsigned char *)"\xff\xff\xff\xff\xff\xff") /* arp请求,广播 */ void arp_request(struct arpentry *ae){ struct pk_buff *pkb; struct ethernet_hdr *ehdr; stru...
C
#include <unistd.h> #include <sys/file.h> #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> #include <stdlib.h> #include <pthread.h> #define ALSA_CLIENT_FIFO "/data/alsa_client_%d_fifo" #define ALSA_DAEMON_FIFO "/data/alsa_daemon_fifo" #define TIMEOUT_SEC 3 #define TIMEOUT_...
C
#define _GNU_SOURCE #include <sched.h> #include <stdio.h> #include <stdlib.h> long int get_ncpus_sched() { int i; long int count; cpu_set_t cs; CPU_ZERO(&cs); if(sched_getaffinity(0, sizeof(cs), &cs)==-1){ perror("sched_getaffinity"); exit(EXIT_FAILURE); } count=0; for(i=0; i<CPU_SETSIZE; i++) if(CPU_I...
C
#include <array.h> #include <string.h> Array *newArray(size_t element_size) { Array *array = malloc(sizeof(Array)); void *content = malloc(element_size); if (array != NULL && content != NULL) { array->content = content; array->element_size = element_size; array->size = 0; array->ca...
C
#include "matrix.h" void init_mat(Mat* mat) { mat->internal = (int *) malloc(sizeof(int) * mat->rows * mat->cols); mat->data = (int **) malloc(sizeof(int*) * mat->rows); for(int i = 0; i < mat->rows; i++) mat->data[i] = &mat->internal[i * mat->cols]; } void read_mat(char *file_name, Mat *mat) { ...
C
#include <stdlib.h> #include <stdio.h> #include "rnglong.h" #define L 128 /* Linear dimension */ #define N (L*L) #define EMPTY (-N-1) int ptr[N]; /* Array of pointers */ int nn[N][4]; /* Nearest neighbors */ int order[N]; /* Occupation order */ void boundaries() { int i; for (i=0;...
C
#ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include "pdig_ptrace.h" #include "pdig_debug.h" #include <stdint.h> #include <sys/ptrace.h> #include <sys/uio.h> #include <sys/user.h> #ifndef MIN #define MIN(X,Y) ((X) < (Y)? (X):(Y)) #endif static inline void* page_align(void* ptr) { uintptr_t aligned = ((uintptr_t...
C
//N = 10 // //un processo padre crea N processi figli ( https://repl.it/@MarcoTessarotto/crea-n-processi-figli ) // //shared variables: countdown, process_counter[N], shutdown // //usare mutex per regolare l'accesso concorrente a countdown // //dopo avere avviato i processi figli, il processo padre dorme 1 secondo e po...
C
#include "key.h" void Key_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE, ENABLE); /* 配置 S1 S2 S3 按键*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4; GPIO_InitStructure.GPIO_S...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <arpa/inet.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <fcntl.h> const int MAX_SIZE = 100; void error( char *msg ){ perror( msg ); exit(1); } void main(){ int client_socket_fd, new_soc...
C
void ft_swap(int *a, int *b) { int aux; aux = *a; *a = *b; *b = aux; } void ft_rev_int_tab(int *tab, int size) { int start; int end; end = size - 1; start = 0; while (start < end) { ft_swap(&tab[start], &tab[end]); end--; start++; } } #include <stdio.h> #include <stdlib.h> void ft_rev_int_tab(int *...
C
#include<conio.h> #include<stdio.h> void main() { int n; printf("Enter a number = "); scanf("d",&n); if (n%2==0) printf("Even"); else printf("odd") getch(); }
C
/****************************************************************************** * The Linux Programming Interface practices. * File: p5.c * * Author: garyparrot * Created: 2019/07/25 * Description: Chapter 18 Exercise 5 *********************************************...
C
int ji,m; void fang(int a,int b) { int i; if(b==1) ji++; else { for(i=m;i<=(a/b);i++) { m=i; fang(a-i,b-1); } } } main() { int k,n,p,q; scanf("%d",&n); for(k=1;k<=n;k++) { scanf("%d %d",&p,&q); ...
C
#include <stdio.h> #include <fcntl.h> #include <libgen.h> #include <unistd.h> #include <string.h> #include <sys/stat.h> #include <errno.h> #include <stdlib.h> #define RETURN_IF_ERROR(expr) \ do { \ int err = (expr); \ if (err == -1) { \ fprintf(stderr, "Error calling " #expr " : %s\n",...
C
/** * Carter Bourette (Feb 2017) * cbourette@gmail.com * * A string library containing common string functions. * Edit: NONE. **/ #include <stdlib.h> #include <stdio.h> #include <string.h> #include "stringy.h" /** * newSplit * Return a structure of type split, splits on a delimeter. * * IN: (char*) str...
C
#include<stdio.h> #include<unistd.h> #include<sys/wait.h> int main(void) { pid_t pid; printf("Main process id : %d.\n",getpid()); pid = fork();//fork1 if(pid==0){ printf("Fork1, I'm the child %d, my parent is %d.\n",getpid(),getppid()); } else{ wait(NULL); } if(pid==0){ pid=fork();...
C
#include <stdio.h> #include <time.h> #include <stdlib.h> /** * main - prints numbers 0 to 9 only using putchar. * Return: 0 */ int main(void) { int number = 48; while (number < 58) { putchar(number); number++; } putchar('\n'); return (0); }
C
// Phillip Stewart // CPSC 351, Spring 2015 #include <sys/shm.h> #include <sys/msg.h> #include <sys/types.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include "msg.h" #define SHARED_MEMORY_CHUNK_SIZE 1000 const char recvFileName[] = "recvfile"; FILE* fp; /* Sha...
C
/*RUN: PO_SPEW_LEVEL=info ./threadPool_runTaskTimeout */ #include <unistd.h> #include <stdint.h> #include <stdio.h> #include <errno.h> #include <signal.h> #include <string.h> #include <stdlib.h> #include <stdbool.h> #include <alloca.h> #include <time.h> #include <stdarg.h> #include <inttypes.h> #include "debug.h" ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_next_line_aux.c :+: :+: :+: ...
C
#include<stdio.h> int add(int,int); int sub(int,int); int main(int argc,char const *argv[]) { printf("Addition: %d\n",add(10,20)); printf("Differ: %d\n",sub(10,20)); return 0; }
C
#include <unistd.h> #include <stdio.h> #include <time.h> #include <string.h> #include <sys/types.h> #include <sys/wait.h> #include <sys/stat.h> #include <fcntl.h> #define SIZE 128 int main() { time_t curTime; struct tm * timeInfo; unlink("file_fifo"); if((mkfifo("file_fifo", 0666)) == -1) { ...
C
#include<stdio.h> #include<conio.h> void FIFO(); void LRU(); void OPTIMAL(); int n,nf,i,j,pos; int queue[100]; int a[50]; int front=-1; int rare=-1; int insert(); int insertn(); void display(); void main() { int op; printf("\nselect one page replacement algorithm\n"); printf("1.FIFO\n"); printf("2...
C
/** \package Common This package contains the base class for all classes in the toolbox (IASObject). The base class provides a simple management of the settings using a parameter pool. See Common.Settings and Common.IASObject. The Common package is still under construction, but the main functionality that is requir...
C
/* * Revision Control Information * * $Source: /users/pchong/CVS/sis/sis/st/st_bench1.c,v $ * $Author: pchong $ * $Revision: 1.1.1.1 $ * $Date: 2004/02/07 10:14:46 $ * */ #include <stdio.h> #include "array.h" #include "st.h" #include "util.h" #define MAX_WORD 1024 extern long random(); /* ARGSUSED */ main(ar...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define BUFFSIZE 128 void exit_if_null(void *ptr, const char *msg); int main(int argc, char const *argv[]) { FILE *filename; char buffer[BUFFSIZE]; char *sequence; char **ipinfo; int str_size = 10, str_count = 0, i; filename = fopen("...
C
/******************************************************************************* *(c) Copyright 2015 Microsemi SoC Products Group. All rights reserved. * * CoreGPIO example program. * * Please refer to the file README.txt for further details about this example. * * SVN $Revision: 8017 $ * SVN $Date: 2015-10-1...
C
#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/wait.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <errno.h> #include <stdbool.h> #include <stdint.h> #include <signal.h> #define SERVER_PORT ((uint16_t)7007) #define...
C
#include <stdio.h> #include <math.h> int input(int *n, int *arr); double count(int *n, int *arr); void output(double *s); int main() { int n, flag; printf("Введите количество элементов массива: "); int flag1 = ((scanf("%d", &n) != 1) || (n < 1) || (n > 10)); if (!(flag1)) { int arr[10]; ...
C
#include <stdio.h> #include <math.h> int main() { int power; long gig_2 = (long)pow(2, 30); long gig_10 = (long)pow(10, 9); scanf("%d", &power); printf("%ld", (gig_2*power - gig_10*power)); return 0; }
C
#include <stdio.h> short sss[100000]; int num = 0; main () { FILE *fp; fp = fopen ("wor16.asc", "rb"); while (!feof (fp)) { fread (&sss[num], sizeof (short), 1, fp); num++; } fclose (fp); fp = fopen ("desc.dat", "rb"); while (!feof (fp)) { unsigned char c = fgetc (fp), c...
C
#include "head.h" void set(char *fomula, polyNode **array) { int state=STATE_COEF,i=0; char coef[MAX]={}, expo[MAX]={}; // printf("set fomula:%s\n",fomula); for(;*fomula!='\0';fomula++) { switch(state) { case STATE_COEF: // coef state if(char_parity(*fomula,"0123456789.")) coef[i++]=*fomula; ...
C
#include <stdio.h> #include <stdlib.h> #define LEN 100 main () { FILE *fp; int i, k; double x, data[LEN]; if ((fp = fopen("random.dat", "w")) == NULL ) { printf("Errore nell'apertura del file random.dat\n"); exit(EXIT_FAILURE); } for (i = 1; i <= LEN; i++) { x = (double)rand() / (double)RAN...
C
#include <linux/kernel.h> #include <linux/module.h> #include <linux/sched.h> #include <linux/list.h> #include <linux/slab.h> #define PDEBUG(fmt, args...) printk("[%s:%d]" fmt, __FUNCTION__, __LINE__, ## args) struct simplelist { struct list_head node; char buffer; }; LIST_HEAD(mylist); struct simp...
C
//Calendar.h #include<iostream> #include<cstring> #include<conio.h> #include<iomanip> class Calendar { private: int month; int year; int firstday; public: Calendar(int =2, int =2017); void setFirstDay(); void print(); }; //Calendar.cpp Calendar :: Calendar (int _month, int _year){ month = _month; year ...
C
#include <stdio.h> struct process{ int p[50]; float at[50]; float bt[50]; float ct[50]; float tat[50]; float wt[50]; }o, a, b, c; int i, j, n, pos; float min, temp, temp1, temp2, total; void user_input(){ printf("Enter the number of processes you wish to enter: "); scanf("%d", &n); printf(...
C
/* * ============================================================================ * * Filename: stoi.c * * Description: 将输入的字符串中16进制数字提取出来,并计算其10进制的值 * * Version: 1.0 * Created: 07/01/2020 10:02:26 AM * Revision: none * Compiler: gcc * * Author: lin chuan , ...
C
/*17mutex.c Usando mutex */ //Miguel Angel Mendoza Guadarrama //02 - abril - 2018 #include <stdio.h> #include <pthread.h> #define NUM_HILOS 2 #define CICLO 100 double b; void* hiloDeposito(void *i){ double m = *(double *) (i); int j; printf("Entrando a hiloDeposito \n"); for(j = 0; j < CICLO + 1; j++){ b += m;...
C
#include <stdio.h> int main() { char str[100]; char srt[100]; printf("ENTER STRINGS:\n"); gets(str); gets(srt); int i,j,check=0; for(i=0;str[i]!='\0' || srt[i]!='\0';i++) { if(str[i]!=srt[j]) { check=1; } } if(check==0) { print...
C
int sum(int n){ int res = 0; res = (n+1)*n/2; return res; }
C
#include <stdio.h> #include <string.h> #include "choose.h" int choose(int numOfUsers){ int ans; printf("\n\nPlease select which user you would like to provide friend suggestions for.\n"); printf("(E.g. Enter '1' for your first user, '2' for your second user etc): \n"); scanf("%d", &ans); ...
C
#include <stdio.h> float approx_pi(int); int main(){ int n; scanf("%d", &n); printf("%.6f\n", approx_pi(n)); return 0; } float approx_pi(int reps){ int i; int sign = 1; float pi = 0; for(i = 0; i < reps; i++){ pi += sign * 4.0 / (2*i + 1); sign *= -1; } retur...
C
#include <stdio.h> int main() { char ch; int a[201],b[201],sum[102]; int i,m,n,max; while(scanf("%c",&ch)!=EOF){ i=101; do{ if(ch>='0'&&ch<='9') a[i++]=ch-'0'; else a[i++]=ch-'a'+10; }while((ch=getchar())!='\n'); m=i; i=101; while(...
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
#include <stdio.h> #include <stdlib.h> #include <time.h> int main(void) { //Variablen werden deklariert int a, b, c; //Ein offset wird eingegebe printf("Offset: "); scanf("%i", &a); srand(time(NULL) + a); //Die Größer der Klasser wird eingegeben printf("Größe der Klasse: "); scanf("%i", &b); //Es wird ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.c :+: :+: :+: ...
C
#include "test_kvtree.h" #include "test_kvtree_util.h" #include "kvtree_mpi.h" #include <mpi.h> #include <stdio.h> //This is the test of kvtree_write_gather/kvtree_read_scatter functionality. The former writes a hash from multiple processes to files with specified prefex, //and the latter reads them from files. int m...
C
/* * AI - Computational Search Using A* Search Algorithm. * * http://en.wikipedia.org/wiki/A*_search_algorithm * * To allow this A* Search algorithm to be used on any problem, * the search is written independent of the Model State, the Actions, etc. * * Actions and Model States have 'data' field for data specif...
C
//Pogram liczy 2^n #include<stdio.h> main(){ int n, i, wynik=1; printf("Podaj wykładnik: "); scanf("%d", &n); if (n>=0){ for (i=0; n>i; ++i) wynik=wynik*2; printf("%d", wynik); } else printf("Podałeś złą liczbę!"); }
C
//Copyright (C) 2013 Steve Taylor (steve98654@gmail.com), Davis E. King //License: Boost Software License. See LICENSE.txt for full license. #ifndef DLIB_NUMERIC_CONSTANTs_H_ #define DLIB_NUMERIC_CONSTANTs_H_ // pi -- Pi const double pi = 3.1415926535897932385; // e -- Euler's Constant co...