language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> int main(void) { unsigned int x = 0x87654321; unsigned int y, z; unsigned int buffer = 0x000000FF; y = buffer&x; buffer = 0xFFFFFF00; z=buffer&x; z+= 0x000000FF; printf("%08x %08x\n", y, z); return 0; }
C
#include <stdlib.h> #include <sys/types.h> #include <stdio.h> #include <sys/mman.h> #include <sys/stat.h> #include <fcntl.h> #include <ctype.h> #include <sys/ipc.h> #include <sys/sem.h> /*---------Global Variables-----------*/ /*Semaphore initialization and incrementing/decrementing*/ int sem; key_t key; struct sem...
C
// #include <stdio.h> // #include <fcntl.h> // #include <unistd.h> // #include <string.h> // int main(void) // { // int fd; // char rdbuf[10] = {0}; // char wrbuf[10] = "helloworld"; // int i; // fd = open("/dev/mem",O_RDWR); // if(fd < 0) // { // printf("open /dev/mem failed."); // } // read(fd...
C
/* * Christian Legaspino & clega001@ucr.edu * Carissa Lo & clo020@ucr.edu * Lab Section: 23 * Assignment: Lab 3 Exercise 3 * * I acknowledge all content contained herein, excluding template or * example code, is my own original work. */ #include <avr/io.h> // Bit-access function unsigned char SetBit(unsig...
C
#include <stdio.h> #include <sys/signal.h> void ger_nova(); main() { void (*ger_antiga)(); /* ctrl-c == sinal SIGINT */ printf ("Primeiro trecho de tratamento de ctrl-c \n"); signal(SIGINT, SIG_IGN); sleep(5); printf("\n"); printf ("Segundo trecho de tratamento de ctrl-c \n"); signal (SIGINT, ger_nova); slee...
C
#include<stdio.h> #include<conio.h> int main() { int TS,basic,hra,da,allowance,pf; char grade; clrscr(); printf("Enter the basic salary: "); scanf("%d",&basic); printf("Enter the grade: "); scanf("%s",&grade); if (grade==65) { allowance=1700; } else if (grade==66) { allowance=15...
C
#include "libft.h" char *ft_strdup(const char *str) { char *s; int i; s = (char *)malloc(sizeof(char) * ft_strlen(str) + 1); i = 0; if (!s) return (NULL); while (str[i] != '\0') { s[i] = str[i]; i++; } s[i] = '\0'; return (s); }
C
/* getch/putchͨͷļ"getputch.h" */ #ifndef __GETPUTCH #define __GETPUTCH #if defined(_MSC_VER) || (__TURBOC__) || (LSI_C) /* MS-WindowsMS-DOSVisual C++, Borland C++, LSI-C 86 etc ...*/ #include <conio.h> static void init_getputch(void) { /* */ } static void term_getputch(void) { /* */ } ...
C
/* * 变量分类演示 * */ #include <stdio.h> void func(void) { static int val = 100; printf("val是%d\n", val); val = 10; } void func1(void) { int val = 1000; func(); } int main() { func(); func1(); return 0; }
C
#ifndef NODE_H #define NODE_H struct Node{ /*Position in the array where we keep track of all nodes*/ int arrayIndex; int numberofEdges; int isLeaf; /*Specifes to which string Si from the set of strigs this (leaf) node belongs*/ int stringIndex; /*Fields used by the temporary list of edges for all nodes*/ in...
C
#ifndef LOG_DEFINED #define LOG_DEFINED #include <stdio.h> typedef enum { LOG_LEVEL_ALWAYS = -1, LOG_LEVEL_DEBUG = 0, LOG_LEVEL_INFO = 1, LOG_LEVEL_WARN = 2, LOG_LEVEL_ERROR = 3, LOG_LEVEL_FATAL = 4, LOG_LEVEL_NEVER = 5 } LogLevel; void log_init(FILE *out, LogLevel minLevel); void log_im...
C
/* ** EPITECH PROJECT, 2017 ** my.h ** File description: ** Définition fonctions */ #ifndef _MY_H_ #define _MY_H_ #include <stdarg.h> int sum_stdarg(int i, int nb, ...); void my_putchar(char c, int *count); char *my_strcpy(char *dest, char const *src); void my_put_nbr(int nb, int base, int *count); void my_swap(int *n...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <netdb.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <string.h> #include <ctype.h> static int sock; static int rec; static char buffer[1024]; static char serverMessage[1024]; static c...
C
#include <stdio.h> int funcao(int V[], int N, int k){ if (N == 0) { return -1; } if (V[N-1]==k) { return N-1; } return funcao(V,N-1,k); } int main(void) { int N=5,V[N],k=5,r; V[0]=5,V[1]=4,V[2]=3,V[3]=6,V[4]=1; r=funcao(V,N,k); printf("%d\n",r); return 0; }
C
/** * K&R Exercise 8-7 * Page 189 * malloc accepts a size request without checking its plausibility; free believes that the block it is asked to free contains a valid size field. Improve these routines so they take more pains with error checking. * Completed **/ int main(void) { return 0; }
C
/*============================================================================ framebuffer.h A "class" for doing primitive manipulations of a Linux framebuffer device. The usual sequence of operations is framebuffer_create framebuffer_init framebuffer_set_pixel (probably many times) framebuffer_deinit ...
C
int deriPrimiCano(void) { float a, b, c; printf("\n\n a = "); scanf("%f", &a); printf(" b = "); scanf("%f", &b); printf(" c = "); scanf("%f", &c); printf("\n Soit p(x) = %.3fx^2 + %.3fx + %.3f\n\n", a, b, c); printf("=====================2. DERIVEE DE p(x) - EXPRESSION ALGEBRIQUE DE p'(x).===...
C
#include <stdint.h> #include <sys/time.h> #include <time.h> #include <stdlib.h> #include <math.h> #include <stdarg.h> #include <stdio.h> #include "utils.h" Rect create_rect(double tl_x, double tl_y, double br_x, double br_y) { Rect o; o.tl.x = tl_x; o.tl.y = tl_y; o.br.x = br_x; o.br.y = br_y; return o; } //...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> int main() { int a; int b; int max; printf("Podaj pierwsza liczbe calkowita: "); scanf("%i",&a); printf("Podaj pierwsza liczbe calkowita: "); scanf("%i",&b); max = abs(a); if (max<abs(b)) max = b; p...
C
#include<stdio.h> void main() { int a,b,c,d; float avg; printf("Program to find average of 4 numbers\n"); printf("\nEnter Numbers one by one\n"); scanf("%d",&a); scanf("%d",&b); scanf("%d",&c); scanf("%d",&d); avg=(a+b+c+d)/4; printf("The average of entered values are = %f",avg);...
C
#include <stdio.h> #include <stdlib.h> #include <errno.h> int cmp( const void *A, const void *B ) { int a = *( const int * ) A; int b = *( const int * ) B; if ( a < b ) return -1; if ( a == b ) return 0; return 1; } int main( int argc, char **argv ) { int total = 0; int dim...
C
/* Popa Mircea-Marian 332CB */ #include "so_scheduler.h" #include "list.h" #include "so_scheduler.h" #include <pthread.h> #ifndef PRIORITY_QUEUE_H #define PRIORITY_QUEUE_H #define isSimpleQueueEmpty(p_q) (!(*(p_q->head))) /* structura unei cozi simple */ typedef struct SimpleQueue { SimpleLinkedList_A head, tail; }...
C
#include<stdio.h> inline int factorial(int n){ if(n ==1 || n == 0) return 1; else return (n * factorial(n-1)); } double nPr(int n, int r){ return factorial(n)/factorial(n-r); } int main(int argc, char *argv[]){ int a, b; a = factorial(5); b = nPr(5, 2); printf("%d\n %d", a, b); return 0; }
C
#include"headers.h" void func_ls(){ int i = 0; struct dirent **lr; int no = scandir(".", &lr, 0, alphasort); //lr points to allocated array of pointers to allocated strings if (no >= 0){ for(i = 0; i < no; i++ ){ if(strcmp(lr[i]->d_name, ".") == 0 || strcmp(lr[i]->d_name, "..") == 0...
C
#ifndef PESSOA_H #define PESSOA_H typedef struct pessoa Pessoa; #include "listaPlaylist.h" #include "listaAmigo.h" /* Aloca e preenche uma pessoa com seu nome e inicializa suas listas de playlist e amigos input: String com o nome da pessoa a ser preenchida output: Ponteiro para struct pessoa pré-condiçã...
C
/* file.c ʾε PHP еĺ õĺ function.h Ѿװ˵ļ ĵ÷, function.c ļ */ #include <stdio.h> #include "../plato/plato.h" /* C */ int main() { printf(" Plato ģС"); return 0; } /* main */ int PLT_CALL plato_main(int argc, void *args[]) { char *file = "test.txt"; /* file_exists */ p_file_exists(file); /* úķֵΪʹ, жļ...
C
/*Write a C program with a recursive function itoa, which converts integer into a string.*/ #include<stdio.h> #include<string.h> #include<math.h> void itoa(int ,char *); int main() { int number,result; char str[80]; printf("\nEnter the number: "); scanf("%d", &number); itoa(number, str); printf("\nNumber ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define TOTAL_LOOPS 0 #define UNIQUES_GENERATED 1 #define NO_HINTS 2 #define TWO_GUESSES_PLUS 3 #define ONE_PLUS_HINTS 4 typedef struct { int real_part; int imag_part; } complex ; /* Function getWidth returns the appropriate width value based on the give...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_next_line.c :+: :+: :+: ...
C
#include "sym.h" #include "tokenize.h" #include "mem.h" const char*ISYMBOLS = "`-=[];,./~!@$%%^&*()+{}:<>?|"; int B_BEGIN[] = {S_LEFTQUARE, S_LEFTCIRCLE, S_LEFTBIG}; int B_END[] = {S_RIGHTQUARE, S_RIGHTCIRCLE, S_RIGHTBIG}; bool in_str(const char *s, char c) { int i = 0; while (s[i]) if (s[i++] == c) return true; ...
C
/*======================================================================= *Subsystem: *File: DS3231.c *Author: Wenming *Description: ͨţ ӿڣPJ1PJ0 ʣ100KHz ======================================================================== * History: ޸ʷ¼б * 1. Date: Author...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* nao_q_sort_aux.c :+: :+: :+: ...
C
/* * 1677 Nested Dolls */ #include <assert.h> #include <stdio.h> #include <stdlib.h> #include "Source/heap.c" struct doll { int y, x; }; struct doll *doll_new(int y, int x) { struct doll *d; assert(d = malloc(sizeof(struct doll))); d->y = y; d->x = x; return d; } void doll_destroy(struct doll *d) { if (...
C
#include "Bignumber.h" long long cpucycles() { return __rdtsc(); } void set_bigint(bigint_st *bi_X, word *Input) { int cnt_i; for (cnt_i = 0; cnt_i < WORD_LEN; cnt_i++) { bi_X->a[cnt_i] = Input[WORD_LEN - (cnt_i + 1)]; //? Input된 배열의 값을 실질적으로 대입해줌 단 메모리 저장순서는 역순으로 -> 계산의 편리성을 위하여 } bi...
C
#include<stdio.h> o_to_c(int x); int main (void){ int o, c; printf("Enter ounces to convert to cups: "); scanf("%d", &o); c=o_to_c(o); printf("%d ounces require %d cups.\n", o, c); return 0; } o_to_c(int x){ int res; if (x%8!=0){ res=(x/8)+1; ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> const int MAX_ELEMENT = 25; //linked list struct NodeOrder { char dishName[255]; int totalPrice; NodeOrder *nextOrder, *prevOrder; } * headOrder, *tailOrder, *currOrder; //hash table struct Node1 { char name[255]; int totalPrice; NodeO...
C
#include <stdio.h> #include <stdlib.h> #include "funciones.h" int main() { char seguir='s'; int opcion=0; int numA, numB, resultado=0; long long resultadoFactorial; while(seguir=='s') { printf("1- Ingresar el primer numero \n"); printf("2- Ingresar el segundo numero \n"); ...
C
#include "../inc/check_sort.h" void sort_check(int *array1, const int len1, int *array2, const int len2) { mysort(array1, len1, sizeof(int), comparator); int r = comparison_of_arrays(array1, len1, array2, len2); ck_assert_int_eq(r, SUCCESS); } START_TEST(norm_sort) { int array1[] = {1, 2, 9, -23, 3...
C
#include "at24c512.h" #include "at_iic.h" /****************************************************************************** صı ******************************************************************************/ //unsigned char buffer[4]; /** *************************************************...
C
/* * Joel Doumit * token.h, based off the token structure given to us in class by Dr. J */ #ifndef TOKEN_H #define TOKEN_H #include <stdio.h> typedef struct token { int category; /* the integer code returned by yylex */ char *text; /* the actual string (lexeme) matched */ int lineno; /* t...
C
#include "main.h" /*Función que inserta números aleatorios en una lista*/ void inserta_datos_de_prueba(Lista lista); int main() { // Se crea la lista Lista lista = crea_lista(); printf("La lista tiene %d elementos\n", longitud(lista)); // Se insertan datos de prueba inserta_datos_de_p...
C
/* * Date:2021-12-08 19:00 * filename:6_条件变量-生产者和消费者模型.c * */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <pthread.h> pthread_cond_t cond; pthread_mutex_t mutex; //链表的结点类型 struct Node { int number; struct Node* next; }; //头节点 struct Node* head = NULL; //生产者 void* producer(void* arg) {...
C
#include "ft_printf.h" int ft_pf_write_char(va_list vl, t_type *type) { char temp; int p_len; int rst; fprintf(stderr, "ft_pf_write_char\n"); rst = 0; p_len = type->width - 1; if (type->type == 'c') { temp = (char) va_arg(vl, int); if (type->is_left) { rst += write(1, &temp, 1); rst += ft_pf_wr...
C
#include <stdio.h> int main(void) { union { float f; unsigned int n; } x; x.n = 0x00000000; printf("+0 = %.50f\n", x.f); x.n = 0x80000000; printf("-0 = %.50f\n", x.f); x.n = 0x00000001; printf("min postive = %.50f\n", x.f); x.n = 0x7f7fffff; printf("max positive = %.50f\n", x.f); x.n = 0x00800000;...
C
void main(){ //подаваемое напряжение в вольтах double u0 = 5; //начальные значения сопротивлений в омах double r1 = 1000; double r2 = 1000; double r3 = 1000; double r4 = 1000; //изменение сопротивления резистора r4 в процентах double dr; cin >> dr; //новое значение сопротивления резистора r4 r4 *= 1 + dr*0...
C
/* * half.c * FluidApp */ #include "half.h" #include "memory.h" #include <stdio.h> #include <stdlib.h> #include <math.h> //To properly convert, we need to sort of structure to gain access to //the individual bits, without the system trying to muck things up. This //set of function calls will essentially do that...
C
// Problem 10 - Summation of Primes /* The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. */ #include <stdio.h> #include <stdbool.h> typedef unsigned int u32; bool is_prime(u32 num) { if(num < 2) return false; else if(num == 2) return true; else { for(u32 i =...
C
#include "mylist.h" /*pre: takes a void* representing an elem, and a pointer to a pointer that points to the head of an existing list*/ /*post: constructs a new node with void *e as the elem, and adds it the front of the list*/ void add_elem(void *e, t_node **ph) { if (e != NULL) { add_node( new_node(e,NUL...
C
/* ** EPITECH PROJECT, 2018 ** CPE_matchstick_2018 ** File description: ** fonction_for_play.c */ #include "../include/matchstick.h" int count_total_stick(char **game_board, char **av) { int nb_map = my_getnbr(av[1]); int nb_cols = ((nb_map * 2) + 2); int nb_rows = (nb_map + 2); int nb_compt_stick = 0...
C
// // overload.c // Heck // // Created by Mashpoe on 10/22/19. // #include "overload.h" #include "class.h" bool add_op_overload(heck_class* class, heck_op_overload_type* type, heck_func* func) { // look for a pre-existing overload of the same data type const vec_size_t num_overloads = vector_size(class->op_ove...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char *argv[]){ //We need 4 arguments "program source -o binary" if(argc < 4){ printf("Insufficient arguments\n"); return 1; } char * sourceFilename = argv[1]; char * destFilename = argv[3]; FILE * inputFile = fo...
C
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <omp.h> #define MXITER 1000 #define NPOINTS 2048 typedef struct { double r; double i; }d_complex; // return 1 if c is outside the mandelbrot set // reutrn 0 if c is inside the mandelbrot set int testpoint(d_complex c){ d_complex z; ...
C
/* * Author: Jessica Programmer * Student Number: 12345678 * Lab Section: L1X * Date: October 13, 2017 * * Purpose: This program loads the DAQ simulator and runs * a simple program involving a switch and LED. */ #define _CRT_SECURE_NO_WARNINGS...
C
#include "gf2d_entity.h" typedef struct { List * entList; Uint8 size; Uint8 count; }EntityManager; static EntityManager entManager = {0}; void gf2d_entity_init_manager() { entManager.entList = gfc_list_new(); entManager.size = 100; entManager.count = 0; atexit(gf2d_entity_close); } Entity * gf2d_entit...
C
/* ** EPITECH PROJECT, 2019 ** navy ** File description: ** connaction */ #include "header.h" int end_game(struct a *c) { int x = 1; int y = 1; while (y <= 9) { x = 0; while (x <= 16) { if (c->game[y][x] == '2' || c->game[y][x] == '3' || c->g...
C
/* Server side of the client-server application that uses datagrams * in the UNIX domain. * * The server program enters an infinite loop. It receives datagrams from * the client, converts the received text to upper-case and returns * it back to the client. * * Author: Naga Kandasamy * Date created: July 1...
C
/* * Copyright (c) 1996 - 2013 SINA Corporation, All Rights Reserved. * * test_ae.c: Huaying <huaying@staff.sina.com.cn> * * test for ae event driven library. */ #include <stdlib.h> #include <stdio.h> #include "ae.h" static int max_loop = 10; static int loop_count = 0; int time_proc(aeEventLoop *event_lo...
C
minal#include<stdio.h> void mergeSort(int a[], int length){ printf("Sorted Array -: \n"); for(i=0;i<length;i++) printf("%d\n",a[i]); } int main(){ int a[20],i,size; printf("Enter size of Array -: "); scanf("%d", &size); for(i=0;i<size;i++) scanf("%d",&a[i]); mergeSort(a,size); return 0; }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* parse.c :+: :+: :+: ...
C
#include "server.h" void mx_new_table_profiles(sqlite3 *database) { sqlite3_exec(database, "CREATE TABLE IF NOT EXISTS PROFILES(" \ "USER_ID INTEGER PRIMARY KEY NOT NULL," \ "NAME TEXT NOT NULL," \ "BIRTH TEXT," \ "EMAIL TEXT," \ ...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> int compar(const void *a, const void *b) { if (*(char*)a < *(char*)b) return -1; if (*(char*)a > *(char*)b) return 1; return 0; } int isPermutation(char* s1, char* s2) { int l1 = strlen(s1), l2 = strlen(s2); if (l1 != l2) return 0; char s1cp[l1 + ...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> int main() { srand((unsigned int)time(NULL)); char name[10]; int dice1, dice2; int sumDice; printf("What is your name?\n> "); scanf("%s", name); printf("Hello, %s!\n", name); dice1 = rand() % 6 + 1; dice2 = rand() % 6 + 1; ...
C
#include <pthread.h> #include <stdio.h> void *detachfun(void *arg) { int i = *((int *)(arg)); if (!pthread_detach(pthread_self())) return NULL; fprintf(stderr, "My argument is %d\n", i); return NULL; }
C
/* Common */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <time.h> #include <errno.h> #include <sys/mman.h> /* System */ #include <unistd.h> #include <signal.h> /* Net */ #include <netdb.h> #include <fcntl.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/...
C
#include<stdio.h> int main(){ int * ptr = 0; char * chptr = 0; float * fpptr = 0; double * dbptr = 0; printf("%d", (int) ++ptr - 0); printf("\n%d", (int) ++chptr - 0); printf("\n%d", (int) ++fpptr - 0); printf("\n%d", (int) ++dbptr - 0); return 0; }
C
#pragma once // Syntaxe : AT&T /* desactive les interruptions */ #define DISABLE_IRQ() asm("cli"::) /* reactive les interruptions */ #define ENABLE_IRQ() asm("sti"::) /* ecrit un octet sur un port */ #define outb(port,value) \ asm volatile ("outb %%al, %%dx" :: "d" (port), "a" (value)); /* ecrit un octet sur u...
C
#include <stdio.h> #define INCHES_PER_POUND 166 int main(void) { int height, length, width, volumn, weight; printf("Input the height: \n"); scanf("%d", &height); printf("Input the length: \n"); scanf("%d", &length); printf("Input the width: \n"); scanf("%d", &width); /* calculate the volumn */ v...
C
#include "search_algos.h" /** * print_array - prints the array * @array: pointer to the first element of the array * @lo: first element * @hi: last element */ void print_array(int *array, int lo, int hi) { int i; printf("Searching in array: "); for (i = lo; i <= hi; i++) { if (i == lo) printf("%d", arra...
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 "sna.h" #include <conio.h> #include <windows.h> void os_clean() { int x, y; HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE); x = y = 0; static HANDLE hConsole = 0; static int InstanceCount = 0; COORD coord; if (!InstanceCount) { hConsole = GetStdHandle(STD_OUTPUT_HANDLE); InstanceCount = 1; } c...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> #define MAX_STACK_SIZE 2 typedef struct Stack{ int top; int* value; int capacity; }stack; // ΰ ť ⺻ ̵ //1.Լ Ű ϳ Է ޴ٰ ٸ ű ǹǷ //ű⼭ ٽ popŰ deQueue Ѵ. //2.޴ ̹Ƿ //޴ ϴ ð ϴ  //enQueueÿ enQ ÿ 빰 //deQueueÿ ǰ deQ ÿ Ű popѴ. //3.FULL Ǹ ι ø ۾ ׳ pushҶ...
C
#include "util.h" #ifndef GEN_LLIST #define GEN_LLIST typedef struct llist_node node; /* Generic linked list node */ struct llist_node { void* data; node* next; }; /* Supported operations: initialise list, add element, sorted add element, get element, delete element, count, unload list */ /* initialis...
C
#ifndef GAMEUTILS_H #define GAMEUTILS_H #include "Headers.h" #define Pi (float)3.1415926535 #define Rad2Deg (float)180.0f/Pi #define PiDiv2 (float)Pi/2.0f #define PiDiv3 (float)Pi/3.0f inline int Abs(int Value) { static const int INT_BITS = sizeof(int) * 8; int TopBit = Value >> (INT_BITS - 1); ...
C
#include<stdio.h> struct main_var { int* x; int* y; }; struct main_var main_v = { NULL, NULL }; void funcHasNoLabelStmt() { int x = 5; int i; for ( i=0; i<5; i++ ) { printf("%d ", x+i); } printf("\n"); } void foo () { printf("x inside foo = %d\n", (*main_v.x)); printf("Incrementing ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* preliminary_parse.c :+: :+: :+: ...
C
#include<stdio.h> int main() { int i,alive; int a[10]; for(i=0;i<10;i++) a[i]=i+1; alive=kill(a); printf("remain people is :%d\n",alive); return 0; } int kill(int a[]) { int i=0,k=0; int alive = 10; //people alive while(1) { int j=0; alive = 0; for(j=0;j<10;j++) if(0 != a[j])//number of a...
C
/* chapter 27 exercise 14 page 1034 */ #include <stdio.h> #include <stdlib.h> typedef struct Results { int smallest; int largest; double median; double mean; }Results; int comparator(const void* elem1, const void* elem2) { return (*(int*)elem2) < (*(int*)elem1); } Results find_results(int* array, size_t...
C
// // Created by leoll2 on 10/4/20. // Copyright (c) 2020 Leonardo Lai. All rights reserved. // // Options: // -f <func> : function ('ping' or 'pong') // #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <time.h>...
C
//INSERTION SORT is a simple sorting algorithm that builds the final sorted array (or list) one item at a time. #include <stdio.h> #include<conio.h> #define size 5 void insertion_sort (int array[], int n); int main () { int i, n, array[size]; // clrscr() It is a predefined function in "conio.h" (c...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.c :+: :+: :+: ...
C
/*** *fdopen.c - open a file descriptor as stream * * Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved. * *Purpose: * defines _fdopen() - opens a file descriptor as a stream, thus allowing * buffering, etc. * *****************************************************************...
C
#include<stdio.h> #include<string.h> #include<stdlib.h> #define ATTACH_FILE "./attach_device" int main(int argc,char **argv){ char linebuffer[512]={0}; FILE *fp_attach_device; int ch= 0; fp_attach_device = fopen(ATTACH_FILE,"r"); /*first judge whether the dest file is empty */ if(NULL != fp_attach_device) { ...
C
/* * GccApplication1.c * * Created: 5/15/2019 9:11:08 PM * Author : user */ #ifndef F_CPU #define F_CPU 16000000UL #endif #include <avr/io.h> #include <util/delay.h> void PWM_init() { /*set fast PWM mode with non-inverting output*/ TCCR0=(1<<WGM00)|(1<<WGM01)|(1<<CS01)|(1<<CS00); TCCR2=(1<<WGM...
C
#include <stdio.h> #include <pthread.h> #include <semaphore.h> #include <unistd.h> #define FILE_LOGS "logs.txt" #define MAX_BUFFER_SIZE 10 #define START_BUFFER_LENGTH 5 #ifdef FILE_LOGS #define printf(...) fprintf(pFile, __VA_ARGS__) FILE *pFile; #endif /* Потокові змінні */ pthread_t thread1; pthread_t thr...
C
#include <stdlib.h> #include <stdio.h> #include <math.h> #include "system.h" #define Tmax 1000 #define T0max 200 // Tmax = Maximum Timesteps For The Correlation Time // T0max = Maximum Number Of Time Origins void SampleDiff(int Switch) { int Tcounter,i,T,Dt; static int Tvacf,Tt0[T0max],T0; double Dtime; sta...
C
// // AutoreleaseStack.c // Human // // Created by BenNovikov on 03.07.15. // Copyright (c) 2015 ___Basic_Notation___. All rights reserved. // #include <stdio.h> #include <assert.h> #include <stdlib.h> #include "BNAutoreleaseStack.h" #include "BNObject.h" #include "BNMacros.h" struct BNAutoreleaseStack { BNO...
C
/* ----------------------------------------------------------------------------------- Nom du fichier : bateau.h Auteur(s) : Joel Dos Santos Matias, Géraud Silvestri, Valentin Kaelin Date creation : 30.05.2021 Description : Met à disposition les bases nécessaires à la gestion du port. S...
C
#include <fcntl.h> #include <stdio.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <stdlib.h> #include <sys/wait.h> #define MAX_LINE 80 /* 80 chars per line, per command */ #define READ_END 0 #define WRITE_END 1 int main(void) { char *args[MAX_LINE/2 + 1]; /* command line (of 80) has ma...
C
/* ************************************************************************* */ /* Organizacion del Computador II */ /* */ /* Definiciones de los filtros y estructuras de datos utiles */ ...
C
/* Copyright (C) 2016 Contact: Dmitry Sigaev <dima.sigaev@gmail.com> */ #include "../../utests/tests.h" #include <stdint.h> #include <stdio.h> #include <malloc.h> #include "../sw.h" #include "../gc_sw.h" #include "../lal_encoding.h" #include "../lal_tables.h" START_TEST(test_sw_double_symbols) { char seq1[] = { "A...
C
#include <stdio.h> #include "constants.h" #include "operations.h" #include "pairMemory.h" #include "value.h" void testInt(char *msg, int expected, int actual) { if (actual == expected) { printf("."); } else { printf("x\n\nTest Failed: %s. Expected: %i Actual: %i\n\n", msg, expected, actual); } } void t...
C
#include<stdio.h> #include<conio.h> int add(int,int); void main() { int a,b,c; clrscr(); printf("enter two numbers:"); scanf("%d%d",&a,&b); c=add(a,b); printf("a+b=%d",c); getch(); } int add(int x,int y) { int c; c=x+y; return c; }
C
/** * \file keyboard.c * \brief Process keyboard entries * \author Lady team * \version 1.0 * \date 14 January 2015 * */ #include "keyboard.h" /**********************************************************************************/ /* Global variables */ /*************...
C
/* atsa-nogui.c * atsa: ATS analysis implementation * Oscar Pablo Di Liscia / Pete Moss / Juan Pampin */ #include "atsa.h" void usage(void) { fprintf(stderr, "ATSA "); fprintf(stderr, VERSION); fprintf(stderr, "\natsa soundfile atsfile [flags]\n"); fprintf(stderr, "Flags:\n"); fprintf(stderr, "\t -b sta...
C
#include <stdio.h> #include <stdlib.h> #include "triangle.h" Triangle* TriangleCreate(Vec3 a, Vec3 b, Vec3 c, Color color, Color specularColor, float phongExponent, Col...
C
/* student name:nikita lama subject :programming fundamental roll no :09 lab no :02 program :write a c program to print area of triangle;base and height are asked from user. date :nov16,2016 */ #include<stdio.h> #include<conio.h> #include<math.h> int main(){ int b,h,area; printf("En...
C
/* ** built_utils.c for built_utils in /u/a1/kadiri_a/tmp/grosli_o-42sh/src/builtins ** ** Made by anass kadiri ** Login <kadiri_a@epita.fr> ** ** Started on Sun Jan 16 18:42:47 2005 anass kadiri ** Last update Mon Jan 17 20:36:17 2005 anass kadiri */ #include "builtins.h" static const char oct_tab[] = "01234567";...
C
#include <stdio.h> #include <math.h> #include "ok/ok.h" #include "spline/shape.h" #include "test.h" #define check(cond) do { if (!(cond)) fail_test(#cond " failed\n"); } while (0) int test_no_simplification_needed(void) { struct spline_shape s = { .n = 1, .outlines = (struct spline_outline[]) { { .n = 4,...
C
#include <getopt.h> #include <stdlib.h> #include <stdio.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include "support.h" /* * sort_file() - read a file, sort its lines, and output them. reverse and * unique parameters are booleans to affect how the lines are * sorted, ...
C
#include <stdio.h> #include<stdlib.h> int main5() { int i, j,tmp=0; int a[9] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; for (i=0;i<9;i++){ for (j = 8; j >= 0; j--) { if(a[j]%2==1 && a[i]%2==0 && i<=j){ tmp = a[i]; a[i] = a[j]; a[j] = tmp; } } } for (i = 0; i < 9; i++){ printf("%d ", a[i])...