language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include "string.h" /* Copy Memory */ void *memcpy(void *dst, const void *src, size_t n) { char *d = dst; const char *s = src; while (n--) { *(d++) = *(s++); } return dst; } /* Set Memory */ void *memset(void *ptr, int value, size_t num) { char *p = ptr; while (num--) { *(p++...
C
#ifndef UTILS_H #define UTILS_H #include "../include/types.h" #define EXIT_COMMAND "exit\n" struct sockaddr_in; /** * Create the socket to connect to the CC server * * It connects to the command and control server. * * ip_addr - String with ip address of the listener * port - int where the port goes. * so...
C
#include <stdio.h> void main() { char count[7]; memset(count, 0 , sizeof(count)); int bitSum = 0; for (int i=0; i<16; i++) { printf("%d: ", i); bitSum = 0; for (char bit=3; bit>=0; bit--) { bitSum +=( (1<<bit)&i ? bit : 0 ) ; printf("%d ", (1<<bit)&i ? 1 : 0); } printf("sum=%d\n", bitSum); count...
C
/*b03902052 顏廷宇*/ #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <string.h> int main(int argc, char *argv[]) { if(argc < 3) fprintf(stderr, "player doesn't have enough file\n"); char string[100]; sprintf(string, "h...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sqlite3.h> #include "player.h" #include "unit_test.h" static sqlite3 *db; static int load_batter_accolade_data( void *output, int cols, char *data[], char *names[] ) { static batter_accolade_s batter_accolade; batter_accolade_s **pa = (...
C
/* Parte específica de Objeto */ typedef struct { short int ativo; short int visivel; } Objeto; /* Parte específica de lugar */ typedef struct lugar { struct elemento *Saidas[6]; /* N,S,L,O,C,B */ } Lugar; /* Estrutura geral para Elementos */ typedef struct elemento { char *nome; char *longa; char *cur...
C
#include "utils.h" #include <errno.h> #include <stdio.h> #include <string.h> #include "debug.h" hashmap_t *create_map(uint32_t capacity, hash_func_f hash_function, destructor_f destroy_function) { hashmap_t *myhashmap; map_node_t *mynodes; if ((capacity <= 0) || (hash_function == NULL) || (destroy_functio...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <string.h> int main(int argc,char* argv[]) { if(argc!=2) { printf("Usage: ./a.out file_name\n"); exit(0); } char helper[3] = {'.','/','\0'}; strcat(helper,argv[1]); int err; err = unlink(helper); if(err==0) { prin...
C
/* This testcase is part of GDB, the GNU debugger. Copyright 2012-2019 Free Software Foundation, Inc. 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 the Free Software Foundation; either version 3 of the License, or ...
C
/* * (C) Copyright 2014 * http://www.farsight.com.cn/ * http://nj.hqyj.com/ * * This program is distributed in the purpose for training only * and hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * ...
C
#define NITERS 100 /* Sample code demonstrating reader-writers using queue based * synchronization.. Create NITERS agents, numbered from 1 to NITERS. * Each agent is randomly chosen to be a reader (probability 80%) or a * writer (probability 20%). Writers assign their ID to the global * value. Readers read the ...
C
#include <stdio.h> #include <stdlib.h> #include "rubiks.h" int fill_tab(int **table) { table[0][0] = 0; table[0][1] = 0; table[0][2] = 1; table[0][3] = 1; table[1][0] = 0; table[1][1] = 0; table[1][2] = 1; table[1][3] = 1; table[2][0] = 2; table[2][1] = 2; table[2][2] = 3; table[2][3] = 3; t...
C
#include <stdio.h> //*************************************************** /** * 3-1 10個の入力値を最後から表示する */ //*************************************************** void printNum(int array[]); int main(void) { int array[10]; printf("10個の整数を入力してください\n"); for (int i = 0; i < 10; i++) { printf("%d個目 ...
C
/* * Copyright (C) 2018-2019 Eagle Eye Networks * * SPDX-License-Identifier: Apache-2.0 */ #include "pnp_address.h" #include <stdio.h> #include <string.h> #include <stdint.h> /** * @brief Create new address object with specified address * * Function gets address in user-friendly hostname[:port] format, interp...
C
#include <stdio.h> #include<string.h> void main() { char a[100]; int n,i,count=0; scanf("%s",a); n=strlen(a); for(i=0;i<n;i++) { if(a[i]==a[n-i-1]) { count++; } } if(n==count) { printf("yes..it is palindrome"); } else { ...
C
#ifndef DEPARTMENT_C #define DEPARTMENT_C #include <iostream> #include <iomanip> #include <string> #include <vector> #include "department.h" using namespace std; long Department::nextDepartId = 100; //initialize base depart ID value Department::Department() { id = 0; name = "Unknown"; location = "Unknown"; c...
C
#include<stdio.h> #include<stdlib.h> int multiplicacion(int x){ int rta,tabla=2,res=tabla*x; if(x==11){ rta=0; }else{ printf ("%i%s%i%s%i\n",tabla," x ",x," = ",res); rta=x*multiplicacion(x+1); return rta; } } int main(){ multiplicacion(1); return 0; }
C
#include<stdio.h> #include<math.h> //O(1) to find Nth fibonacii number using Binet's formula int NthFibo(int n) { double sqrt5 = sqrt(5); double phi = (1 + sqrt5)/2; double _phi = (1-sqrt5)/2; double num = (pow(phi, n) - pow(_phi, n))/sqrt5; // printf("\nfloor(%f) = %f", num, floor(num)); return (num - floor(nu...
C
/* Programa que converte numeros em decimal, para binário AUTOR: GABRIEL HENRIQUE CAMPOS SCALICI NUMERO: 9292970 DATA:29-04-2015 */ #include<stdio.h> #include<math.h> #include<stdlib.h> int main() { //Declarando as variaveis que serao utilizadas int n; int i =0; char seq[32]; //sequencia com 32 para 32 bit...
C
#ifndef DATA_H #define DATA_H #include <stdio.h> typedef struct filenode_t { struct filenode_t *next; /* pointer to the next node */ struct datahandle_t *data; /* a datafile this file belongs to */ char *name; /* comple path */ int size; /* */ int offset; /* offset in the disk file w...
C
#include <stdio.h> #include "typedef.h" typedef struct employee { u32 x ; }; typedef struct employee employee ; u32 add (u32 count, ...){ u32 *ptr = &count ; u32 result =0; u8 i; for (i=0 ; i<count ;i++){ ptr ++; result =result + *ptr ; } return result; } int main (void) { ...
C
#include<stdio.h> #include<stdlib.h> int main() { int i = 0; int arr[] = {1 ,2 ,3 ,4 ,5}; int arr1[] = {6 ,7 ,8 ,9 ,10}; int tem = 0; for (i = 0; i < 5; i++) { tem = arr[i]; arr[i] = arr1[i]; arr1[i] = tem; printf("%-2d %-2d\n", arr[i], arr1[i]); } system("pause"); return 0; }
C
#include <stdio.h> #include<string.h> int main(void) { int i; char c1[10],c2[10]; gets(c1); gets(c2); for(i=0;c1[i]!='\0';i++) { if(c1[i]>c2[i]) { printf("%s is greater",c1); break; } else if(c1[i]<c2[i]) { printf("%s is greater",c2); break; } else { printf("both are equal"); bre...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int i,x,brElem=100; //printf("Unesite maksimalnu duzinu stringa: \n"); //scanf("%i",&brElem); char* niz = (char*) malloc(brElem * sizeof(char)); printf("Unesite string: "); gets(niz); x=('a')-('A'); i=0...
C
#include<stdio.h> #define MAX 100 int dec,top,stack[MAX]; void Push() { while(dec>0) { int remainder=dec%2; dec=dec/2; if(top>=MAX) printf("Stack overflow!"); else { top++; stack[top]=remainder; } } } void Pop() { in...
C
#include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/msg.h> #include <string.h> struct msguser { long type; char log[1024]; char pass[1024]; int g; int sg[3]; char mess[1024]; int logged; } user, user2; struct msgcomunnicate { long type; ...
C
/* * ui.c * * Created on: 21 nov. 2016 * Author: gaillard_ron */ #include "ui.h" #include "blocks_handler.h" #include "graphics.h" extern char blocks_list[NUMBER_OF_BLOCKS]; extern unsigned char odd_frame; int current_selected_block = 0; void draw_main_ui() { int i,j = 0; /* draw...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef enum { start, left, right, up, down, quit, N_op } commands ; typedef enum { vertical, horizontal } direction ; typedef struct { int id ; int y1, y2 ; int x1, x2 ; int span ; direction dir ; } car_t ; char * op_str[N_op] = { "start",...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include "logger.h" static unsigned int i = 0; void fun(FILE* f) { fprintf(f, "Current number: %d", i++); } int main() { init(34, 35, "log", fun); for(;;) { if (set_log(1, "Example message for log severity MIN") == 2) return EXIT_SUCCESS; if ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* check_wall_utils.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #include <stdbool.h> #include <time.h> typedef struct node { int value; struct node *left; struct node *right; } node; typedef struct { node *left; node *right; } pair; void bst_to_list_helper(node *n, pair *p_parent) { ...
C
/* * @file ledControl.c * @brief Source file that controls the RGB LED * * This source file turns LEDs on and off of a particular color, based * on the function called * * @authors Rahul Ramaprasad, Prayag Milan Desai * @date November 1 2019 * @verison 1.0 */ #include "ledControl.h" //#include "semphr.h" v...
C
/* EP1 - MAC0422 - Anderson Andrei da Silva Shell + Gerenciador de processos */ #include "schedulerSJF.h" void* job(void *argument){ struct rusage ru; float seconds = 0; int i, j; thr *t = (thr *) argument; seconds = 0; while (seconds < (1 * t-> dt)) { for (i = 0; i < 10; i++) { j++; } getrusage(...
C
/*Generate first 25 terms of a fibonacci sequence*/ #include<stdio.h> #include<conio.h> main() { int i,t,old=0,current=1,new; printf("%d\t%d\t",old,current); fibo(old,current); printf("\n\n\n\n\n\nPress any key to exist..."); getch(); } fibo (int old, int current) { static int terms=2; int n...
C
/* * eeprom.c * * Created on: 29 Ara 2020 * Author: mehme */ #include "eeprom.h" void read_eeprom(uint16_t regAddr, uint8_t *data, uint32_t num){ uint8_t devAddr = 0x00; uint8_t arr[2]; arr[0] = 0; arr[1] = 0; write_i2c(devAddr, arr, 1); read_i2c(devAddr, data, num); } void write_eeprom(uint16_t reg...
C
#include <stdio.h> #include<string.h> #define LENGHT 10 int main() { void dopisz(char*a,char *b){ int dlugosc_a = strlen(a); int dlugosc_b = strlen(b); int i=0; int j = 0; if(dlugosc_b+dlugosc_a+1>LENGHT){ printf("Nie moge przepisac\n"); }else{ for(;i<dlugosc_b;i++){ *(a+dlugosc_a+i)=*(b+i); ...
C
#include <string.h> #include <stdlib.h> #include <stdio.h> #include <ctype.h> #include "svm.h" jmplbl_t* __jmp_tbl; int __jmp_tbl_size = 0; int __program_len = 0; /* registers */ int __eax, __ebx, __ecx, __edx, __esi, __edi; int *__esp, *__ebp; int __eip; int __flag; int* __callstack_base = 0; int* __callstack_top ...
C
#include "main.h" #include <stdlib.h> #include <stdio.h> #include <stddef.h> #include "file_parser.h" #include "cluster.h" /** * Takes input list, clusters the data and calculates the ratio of on time * @params values - list of raw data readings * @params len length of the input list * @return float that is the r...
C
/* Program to swap two numbers without using temporary variable */ /*Author:Sravanthi_Yachareni */ #include<stdio.h> #include<conio.h> void main() { int a,b; printf("Enter any two numbers\n"); scanf("%d%d",&a,&b); printf("Variable values before swaping\n"); printf("a=%d b=%d",a,b); /*Swaping */ a=a+b; b=a-b; ...
C
#include<stdio.h> int main() { int no,num; printf("enter the number\n"); scanf("%d",&no); if(no%2==0) { printf("modular:even\n"); } else { printf("modular:not even\n"); } if((no/2)*2==no) { printf("divide:even\n"); } else { printf("divide:not even\n"); } num=no; num=num>>1; num=num<<1; if(no...
C
/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ //https://leetcode.com/problems/sum-of-root-to-leaf-binary-numbers/discuss/836083/Neat-solution-using-realloc-very-good-for-C-programmers-out-here void dfs(struct TreeNod...
C
#include "shell.h" /** * _GetEnv - obtain value of a enviroment var * @var: name of enviroment var * @env: enviroment * Return: value of enviroment var * Authors - Carlos Garcia - Ivan Dario Lasso - Cohort 10 - Cali **/ char *_GetEnv(char *var, char **env) { char **enviroment; char *ValuePos; size_t len = 0; ...
C
#include <stdio.h> #include <limits.h> #include <float.h> int main(void) { printf("Anzahl Byte fuer char: %lu\n", sizeof(char)); printf("Anzahl Byte fuer short int: %lu\n", sizeof(short int)); printf("Anzahl Byte fuer int: %lu\n", sizeof(int)); printf("Anzahl Byte fuer long: %lu\n", s...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_secu_malloc.c :+: :+: :+: ...
C
/* * 코딩마법서 03.5 연습문제 * 삼각형 모양을 출력하는 프로그램 작성 * 약간 변형 : 숫자 넣으면 그 숫자만큼 출력하기 */ #pragma warning(disable:4996) #include <stdio.h> int main() { int n = 0, i = 0, j = 0; printf("n 입력 : "); scanf("%d", &n); for (i = 1; i <= n; i++) { for (j = 1; j <= i; j++) { printf("#"); } printf("\n"); } return 0; }
C
#include <stdio.h> #include "bool.h" #include "tools.h" /* Replace the return 0 with the code to perform the required function. Do not change the function prototypes. Be sure to check for errors in input. Document EACH function with a function header (description, parameters, return). */ /* * getBi...
C
#include "lista.h" /* Interface lista.h */ Lista* inicializa(void){ return NULL; } Lista* insereInicio(Lista *l, int i){ Lista *novo = (Lista*) malloc(sizeof(Lista)); //Cria uma alocao dinmica para o novo elemento novo->info = i; //Atribui o ponteiro novo que aponta para info o valor de i novo->prox = l...
C
/*-----------------------------------------------------+ | defines . H | +-----------------------------------------------------+ | Version : 4-Julio-2002 | | Autor : Joan Vila | | Asignatura : SO2 ...
C
/*ļ1527403034_E53.c *ߣ *ʱ䣺2015128 *ܣͳһӢľеʵĸ *ע */ #include<stdio.h> /* ܣͳһӢľеʵĸ char str[]; Ӣľ ֵint num;ʸ */ int CountWord(char str[]); int main() { char str[80]; // printf("һӢľ:\n"); gets(str); //㵥ʸ printf("Ϊ%d\n",CountWord(str)); return 0; } int CountWord(char str[]) { int i; int flag=2; int count=0; f...
C
#include <stdio.h> #define MAX_SIZE 11 #define NUM_OP 4 #define NUM_RESULT 2 #define INF 1000000000 int calc(int oprnd1, int oprnd2, int oprtr); int max(int a, int b); int min(int a, int b); void _embed(int *src, int n, int *numOp, int *dst, int count, int op, int result); void embed(int *src, int n, int *numOp, int ...
C
#include "SWD.h" /* Initialize device by sending 50 HIGH ticks swdck - SWD clock Pin GPIO number swdio - SWD data Pin GPIO number */ void initDevice(unsigned int swdck, unsigned int swdio) { writeBytes(swdck, swdio, &swd_sync_seq, swd_sync_seq_length); } /* method to make clock tick swd...
C
#include<stdio.h> #include<stdlib.h> int main() { int i; int number, MIN, MAX, *number1, result; float min, max, float1; while(scanf("%d %f %f", &number, &min, &max)!=EOF){ MIN=2147483647; MAX=0; number1=(int *)malloc(number*sizeof(int)); for(i=0; i<number; i++){ scanf("%d", &number1[i]); ...
C
/* * 3. . * * : * . : 0123, 1234, 2345, ..., 6789. * * : * - ATmega168 * - 7seg-mpx4-ca; * * 7seg-mpx4-ca * . , * () ' * . * . * , * . * , * * . , * * . * . * * . * * . , * , . * * ...
C
#include<stdio.h> #include<stdlib.h> #define OIKEALUKU 12 int main() { srand(time(NULL)); int luku = 0; int oikealuku = rand() % 21; do { printf("Arvaapas luku valilta 1-20!\n"); scanf_s("%d", &luku); if (luku < oikealuku) { printf("Eip! Luku on suurempi.\n"); } else if (luku > oikealuku) { ...
C
#include<stdio.h> int main() { int i; printf("pta nhi kya ha"); for(i = 0;i < 10; i++) { printf("%d",i); } return 0; }
C
#include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <string.h> //#include <strings.h> /* * How to update NOR flash layout: * 1. Modify mxp_gen.c for change layout * 2. Build: gcc mxp_gen.c -o mxp_gen * 3. Generate MXP_SF.bin: ./mxp_gen MXP_SF.bin */ typ...
C
#include <stdio.h> int main() { FILE *fp = fopen("test", "r"); int arr[100000]; int i; for (i = 0; i < 100000; i++) { arr[i] = getc(fp); } for (i = 0; i < 100000; i++) { printf("%c\n", arr[i]); } return 0; }
C
#include <stdio.h> #include <stdlib.h> int main() { int arr[50]; int i; int arra2[]={0,0,0,0,0,0,0,0,0,0}; int y; int n; printf("Input a number : "); scanf("%d",&n); int x=n; for(i=0;x!=0;i++){ n = x % 10 ; arr[i]=n; x = x / 10 ; } y = i; ...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <time.h> #include <poll.h> #include "blather.h" int exit_signal = 1; // handle SIGINT helper void handle_SIGINT(int sig_num) { exit_signal = 0; } // handle SIGTERM helper void handle_SIGTERM(int sig_num) { exit_signal = 0; ...
C
#include <stdio.h> int main(void) { #define number 5 int i; int sum = 0; int tensu[number]; for (int i = 0; i < number; ++i) { printf("%-2d号:", i + 1); scanf("%d", &tensu[i]); sum += tensu[i]; } printf("和为:%3d\n", sum); printf("平均数为:%3.2f\n",(double)sum/number); ...
C
#include "check_file_open.h" #include <stdlib.h> FILE *check_file_open(const char *file_name, const char *mode) { FILE *file_ptr; if(!(file_ptr = fopen(file_name, mode))) { fprintf(stderr, "Error: can't open file \"%s\"\n", file_name); exit(EXIT_FAILURE); } return file_ptr; }
C
#include <stdio.h> #include <stdlib.h> //#include <math.h> passer -lm en paramètre //#include <pthread.h> passer -lpthread en paramètre #define Taille = 100; struct info { int * T; int deb; //valeurs d'entrée pour le thread int max; int pos; }; void* calcul(void* arg) { int i; struct info * ptr; ptr = (struct i...
C
#include "testUtils.h" #include "stack.h" #include <String.h> void test_create_stack(){ Stack* stack = createStack(); ASSERT(stack->head == NULL); ASSERT(stack->length == 0); } void test_push_element_at_starting_of_the_stack(){ Stack* stack = createStack(); char element = 'a'; ...
C
#include <stdio.h> int main() { printf("10!:%d\n", factorial(5)); } int factorial(int x) { return x * factorial(x-1); }
C
#include<stdio.h> int q[10],choice,queue_size,f,r,x,i; // Declaration of variables void insert_rear(); void insert_front(); void delete_rear(); void delete_front(); void display(); int main() { r = -1; f=0; printf("\n Enter the size of QUEUE : "); scanf("%d",&queue_size); printf("\nQUEUE IMPLEMEN...
C
#include <stdio.h> // 输入整数的阶乘 int main() { int i=100; char b[i],c[i],d[i],e[i]; char a[i]; b[i]=1; scanf("%c",&c[i]); printf("\n"); for(a[i]=1;b[i]<=c[i];b[i]++) { a[i]=a[i]*b[i]; printf("%c\n",a[i]); } return 0; }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* rush03.c :+: :+: :+: ...
C
#ifndef MATHFUNC_H #define MATHFUNC_H 1 #include "TMath.h" #include "TString.h" #include "Riostream.h" inline Double_t lorentzian(Double_t *x, Double_t area, Double_t mean, Double_t gamma) { return area * (TMath::BreitWigner(x[0],mean,gamma)); } inline Double_t voigth(Double_t *x, Double_t height, Double_t mean,...
C
#include "../domain.h" inherit "/std/room"; void setup(void) { add_area("Gurba"); add_area("GelmirRoad"); add_area("GurbaOutdoor"); set_short("Gelmir Road"); set_long("Gelmir Road widens here as it approaches the town square " + "to the west. A constant stream of people are coming and going " +...
C
#include "header.h" #include "fifo_dir.h" #include "setup_workers.h" #include "sig_actions.h" /* ========================================================================= */ static void reassign_countries(pid_t new_pid, struct worker_stats *w_stats, struct hash_table *ht_workers, int index, int buf_size); // Replac...
C
#include <stdio.h> #include <signal.h> #include <unistd.h> void func( int sig ) { printf("Oops! -- I got a signal\n"); } int main() { signal(SIGINT, func); //catch terminal interrupts for ( int i = 0; i < 20; ++i ) { printf("IT 215 lab on signals\n"); sleep ( 1 ); } return 0; }
C
/* Representasi queue dengan list berkait dengan first (HEAD) dan last (TAIL) */ #ifndef _turnqueue_H #define _turnqueue_H #include "gameproperty.h" #include "boolean.h" #include "listlinierunit.h" #include "listlinierbuilding.h" #include <stdlib.h> #include "map.h" #include "pcolor.h" /* Konstanta */ #define Nil NU...
C
/*Basic program to ask a user for the size of an array they want to input, and then ask them for the numbers they want stored in the array. The program then prints those numbers in a sorted list, using selection sort to do the sort. Selection sort is implemented differently from bubble sort in that a minimum index pos...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* malloc.c :+: :+: :+: ...
C
// returns symbols from 32 to 126 read from /dev/urandom, not thread-safe // s - length of data with trailing zero #include <sys/random.h> char *randstring(size_t *s){ static char buf[256]; char rbuf[255]; ssize_t L = getrandom(rbuf, 255, 0); if(L < 1){ *s = 0; return NULL; } si...
C
#include <stdio.h> #include <math.h> void function(float a, float b, float c); int main() { float a = 0; float b = 0; float c = 0; printf( " a*x^2 + b*x + c = 0\n " ); printf( " input a =\n " ); scanf( "%f", &a ); printf( " input b =\n " ); scanf( "%f", &b ); printf( " input c =\n " ); scanf( "%f",...
C
#include <iostream> #include <memory> class Base { public: virtual ~Base() {} Base* clone() const; }; class ClonerBase { public: virtual Base* clone() const = 0; }; Base* Base::clone() const { dynamic_cast<const ClonerBase*>(this)->clone(); }; template <typename Derived> class Cloner : publi...
C
#include <stdio.h> long long arr[10000+10]; long long get_total_jobs(long long arr[], int n, long long v) { int i; long long sum = 0; for (i = 0; i < n; i++) sum += v/arr[i]; return sum; } long long get_time(long long arr[], int n, long long min, long long T) { long long low, mid, high; long long tjobs; ...
C
#include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <stdint.h> key_t my_ftok(const char *pathname, int proj_id); int main() { printf("my_ftok: %X\n", my_ftok("./", 0x4A)); return 0; } key_t my_ftok(const char *pathname, int proj_id) { struct stat statbuf; uin...
C
/* ******************************************************************************** * COPYRIGHT NOTICE * Copyright (c) 2016 * All rights reserved * * @FileName : ReorderArray.c * @Author : scm 351721714@qq.com * @Creat...
C
/* Includes */ #include "deck.h" /** Initalises a given card with a provided suit and value. * * Parameters: * card *newCard - card to be initalised * int suit - suit of the card * int value - value of the card * * Returns: * card *newCard - initialised...
C
#include <stdlib.h> #include <unistd.h> #include <stdio.h> int main(){ int n; int fd[2]; pid_t pid; char line[80]; if(pipe(fd) < 0){ perror("pipe"); exit(1); } if((pid = fork()) < 0){ perror("fork"); exit(1); } if(pid > 0){ //parent ...
C
#ifndef QUEUE_H_ # define QUEUE_H_ # include "list.h" typedef struct queue { /* Properties */ struct list list; /* Methods */ /* --- Modifiers --- */ void (*push)(struct queue *self, void *data); void (*pop)(struct queue *self); void (*clear)(struct queue *self); /* --- Element access --- *...
C
int susu(int a) { if(a%2==0) return 0; int i,k=1; for(i=3;i<=sqrt(a);i=i+2) if(a%i==0) k=0; return k; } int main() { int n,m,l,z,x; cin>>n; for(z=6;z<=n;z=z+2) for(l=3;l<=(z/2);l=l+2) { if(susu(l)+susu(z-l)==2) {cout<<z<<"="<<l<<"+"<<(z-l)<<endl;break;} else continue; }...
C
#include "repo.h" void repo_aduga(Lista* ptr, Medicament medicament) { /*Functia primeste o lista cu medicamente si caacteristici unui medicament si adauga medicamentul cu caracteristicile date in lista Date de intrare: ptr - pointer la o lista (stocul de medicamente din famacie) cod - un intreg ce reprezin...
C
#include <lib.h> int main(void) { pid_t child; child = fork(); if (child > 0) { sched_yield(); printf("[PID %5u] I am the parent!\n", getpid()); assert(waitpid(child, NULL, 0) == child); } else { printf("[PID %5u] I am the child!\n", getpid()); } return 0; }
C
#include "holberton.h" #include <stdio.h> /** * print_triangle - print triangle * @size: integer * Return: return a triangle in function of the size */ void print_triangle(int size) { int y, i, k; if (size <= 0) { _putchar('\n'); } else { y = 0; while (y < size) { for (i = 0; i < size - y; i++) ...
C
/* ID:eastern3 LANG:C TASK:beads */ #include <stdio.h> #define max(a,b) (a>b?(a):(b)) int main(void){ int N,i,l[800][2],r[800][2]; char neck[800]; int result; freopen("milk2.in","r",stdin); freopen("milk2.out","w",stdout); scanf("%d",&N); for(i=1;i<=N;i++){ scanf(" %c",&neck[i]); neck[i+N] = neck[i]; } l[0...
C
#include <stdio.h> #include <errno.h> #include <assert.h> #include <stdlib.h> #include <string.h> #define MAX_DATA 512 #define MAX_ROWS 100 struct Endereco{ int id; int set; char nome[MAX_DATA]; char logradouro[MAX_DATA]; char cep[MAX_DATA]; char bairro[MAX_DATA]; char cidade[MAX_DATA]; }; struct Database{ /...
C
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <unistd.h> #include <assert.h> #include <sys/types.h> #include <dirent.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <errno.h> #include "exc_parse.h" #include "exc_error.h" #include "exc_str.h" #incl...
C
// Simple HTTP Server // Copyright 2015 Alogfans, all rights reserved. // // Description: Handling errors in httpd #include "httpd.h" // attain bacetrace information from system and print it to screen. void httpd_dump_backtrace() { void * buffer[BACKTRACE_BUFFER_LENGTH]; int nptrs = backtrace(buffer, BACKTRACE_BUFF...
C
#include<stdio.h> int main(){ int i,j,k,l,a[10]; printf("Enter the number of elements\n"); scanf("%d",&i); for(j=0;j<i;j++){ scanf("%d",&a[j]);} for(j=1;j<=i-1;j++){ k=j; while(k>0&&a[k]<a[k-1]){ l=a[k]; a[k]=a[k-1]; a[k-1]=l; k--;}} printf("Sorted list :\n"); for(j=0;j<=i-1;j++){ printf("%d",a[j]);} return 0;}
C
#ifndef VMM_H #define VMM_H #ifndef DEBUG #define DEBUG #endif #undef DEBUG #include <sys/types.h> /* 模拟辅存的文件路径 */ #define AUXILIARY_MEMORY "vmm_auxMem" /* 页面大小(字节)*/ #define PAGE_SIZE 4 /* 虚存空间大小(字节) */ #define VIRTUAL_MEMORY_SIZE (64 * 4) /* 实存空间大小(字节) */ #define ACTUAL_MEMORY_SIZE (32 * 4) /* 总虚页数 */ #define PAGE...
C
#ifndef LIST_H #define LIST_H typedef struct ListElmt_ { void *data; struct ListElmt_ *next; } ListElmt; typedef struct List_ { int size; int (*match)(const void *key1,const void *key2); void (*destroy)(void *data); ListElmt *head; ListElmt *tail; } List; void list_init(List...
C
/* Exercise 7-5. Rewrite the postfix calculator of Chapter 4 to use scanf and/or sscanf to do the input and number conversion. */ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <ctype.h> #include "calc.h" #include "../../../helper_functions.h" #define MAXOP 100 /* reverse Polish calculator */ int ...
C
#include "../../lib/include/csapp.h" static int conflict(int x1, int y1, int x2, int y2) { return x1 == x2 || y1 == y2 || x1 + y1 == x2 + y2 || x1 - y1 == x2 - y2; } static void print_line_sep(int size) { for (int i = 0; i < size; ++i) printf("+---"); printf("+\n"); } ...
C
#include <stdio.h> /* These are the usual header files */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <string.h> #include <unistd.h> #include <ctype.h> #include <stdlib.h> #include <sys/stat.h> #include <time.h> #include <pthread.h> #include "protocol...
C
#include<stdio.h> #include<stdlib.h> #include "mem.h" #include<unistd.h> #include<sys/mman.h> #include<sys/types.h> #include<sys/stat.h> #include<fcntl.h> typedef struct free_list { int size; int free; struct free_list *next; }free_list; free_list *head = NULL; int count = 0; int m_error; /*------------------...
C
#include <stdio.h> #include <stdlib.h> #define N 100 /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int hash(int mat){ return N - 2 - mat % (N-2); } int main(int argc, char *argv[]) { int a = hash(105); printf("valor: %d", a); return 0; }
C
#define MAX_NUMBER 10 struct node{ int data; struct node* prev; }; typedef struct stack{ int count; struct node* top; }STACK; STACK* createStack(); int pop(STACK* st); void push(STACK* st, int d); int stackTop(STACK* st);