language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <std.h> inherit "/d/common/obj/weapon/dagger"; create() { ::create(); set_id(({ "curved dagger", "dagger", "shining dagger", "shining curved dagger", "lichbane", "Lichbane" })); set_name("curved dagger"); set_short("%^BLACK%^%^BOLD%^L%^RESET%^%^RED%^i%^BOLD%^c%^YELLOW%^h%^RESET%^%^BOLD%^b%^YELLOW%^a%^...
C
#include <stdio.h> #include <cs50.h> #include <string.h> int power(int a, int b); int main(int argc ,string argv[]) { int n = strlen(argv[1]); int move_number; int move_number_total = 0; //printf("%i\n", n); if(argc == 2) { for(int i = 0; i < n; i++) { //printf("suc...
C
#include <stdio.h> #include <math.h> double NB(double n, double Hn, double Pn, double k, double c, double a) { int i=1; double Hn2, Pn2, x; printf("Gen Host Parasitoid\n"); printf("%3d %9.4lf %12.4lf\n", i, Hn, Pn); for (i=2; i<n+1; i++) { Hn2=k*Hn*(exp(-a*Pn)); Pn2=c*Hn*(1-exp(-a*Pn)); print...
C
#include <stdio.h> #include "contiki.h" /* We declare the process */ PROCESS(hello_world_process, "Hello world process"); /* We require the processes to be started automatically */ AUTOSTART_PROCESSES(&hello_world_process); /* This is the implementation of our process */ PROCESS_THREAD(hello_world_process, ev, data)...
C
/* Test : Expression */ #include <stdlib.h> #include <string.h> #include <stdio.h> #include "testfw.h" #include "test_expr.h" #include "cparse.h" #define TEST(tfw, component, source, expected_success, expected_output) \ test2(tfw, component, source, expected_success, expected_output, __LINE__) static int test2(t...
C
#include "MainAux.h" extern int** board; extern int markErrors; static int running; void init() { running = 1; mode = Init; printf("Welcome To console Sudoku"); } int edit(char* fileName) { /* * we first make sure the move list is empty (if its not we empty it) * then we try to load the file in edit mode an...
C
#ifndef HASH_H #define HASH_H #include "md5.h" MD5_CTX mdContext; // needed to compute MD5 int hash(char * word) { int result; int * temp; MD5Init(&mdContext); // compute MD5 of password MD5Update(&mdContext, (unsigned char *)word, 4); MD5Final(&mdContext); temp = (int *) &mdContext.digest[12]; result = *t...
C
//################################################################################################# /*! \file M_JAVAIO.c * * \brief Modulo simulado da biblioteca java.io * * Modulo responsavel por implementar servicos que simulam os metodos e atributos da * biblioteca java.io */ //#############################...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> //#include <algorithm> #include <math.h> //#include <bits/stdc++.h> //using namespace std; typedef long long int lli; int times=0; typedef struct matrix { lli a,b,c,d; } matrixc ; struct matrix mul(struct matrix m1,struct matrix m2) { struct matrix temp...
C
// write a program that read a number and display it is prime or not #include<stdio.h> int main() { while (1) { int num, i; printf("\nEnter any positive number: "); scanf("%d", &num); for (i=2; i<num; i++) { if (num%i==0) ...
C
#include <pthread.h> #include <stdio.h> #include <stdbool.h> #include <stdlib.h> #define NUM_THREADS 4 void initializeDeck(); void shuffleDeck(); void* playPairWar(void*); int deck[52]; //card deck pthread_t players[NUM_THREADS]; //player threads pthread_mutex_t deckLock = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t...
C
// // дMyStrcat()ϵͳṩַӺstrcat()ʵַӵĹܡ // // У // һַȲ20 // ڶҲַȲ20 // // Ӻַ // ʾ // Very good! // Hello // ʾ // Very good!Hello // ݷΧ // ΪַַȲ20 #include<stdio.h> int main() { MyStrcat(); return 0; } int MyStrcat() { char str[41]; char str1[21]; int i=0,j; gets(str); ...
C
#include <stdlib.h> #include <stdio.h> #include <math.h> int number; int block[1001]; int count; int newlength; int maxvalue,length; int newcount; int lengthdiff; int j; int value; int zerocount; int newval; int main(int argv, char *argc[]) { for(zerocount=0;zerocount<1001;zerocount++) { block[zerocount...
C
/* * File: view.h * Author: Bryan Daniel */ #ifndef VIEW_H #define VIEW_H #include "sorting.h" /** * Prints the main menu of the program */ void print_main_menu(); /** * Prints a menu to select a sorting algorithm */ void print_algorithm_menu(); /** * Prints a menu to select a file for sorting * * @p...
C
#include <stdint.h> #include <string.h> #include <errno.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <dirent.h> #include <fcntl.h> #include <edgeos_fsapi.h> #include <edgeos_logger.h> #include <shmem.h> int edgeos_create_file(const char *filename) { int fd; if (!filename) { ...
C
// 15) Programa que introduzca un número entero por teclado, // si este es 0 me tiene que mostrar su valor en letra y // si es distinto de 0 se visualiza sucuadrado: #include <stdio.h> int main(int argc, char const *argv[]) { int n; printf("*MUESTRA EL CUADRADO DE UN NUMERO*\n\n"); printf("Ingresa un Numero: ");s...
C
//template for testing code //download with: wget troll.cs.ua.edu/ACP-C/tester.c //STUDENT: The strings I entered are qwertyqwertyqwerty and asdfjkl;asdfjkl;asdfjkl; //STUDENT: The output of the strings are . and asdfjkl;asdfjkl;asdfjkl; #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> int ...
C
// write a program to read content from the file using fscanf function; #include<stdio.h> #include<conio.h> void main() { FILE *fp; char ch[100]; clrscr(); fp=fopen("c:/temp/sample12.txt","r"); while(fscanf(fp,"%s",ch)!=EOF) { printf("%s",ch); } fclose(fp); getch(); }
C
//#undef NDEBUG #ifndef __munit_h__ #define __munit_h__ #include <time.h> #include <stdio.h> #include <stdlib.h> #include "dbg.h" #define mu_suite_start() char * message = NULL #define mu_assert(test, message) \ if(!(test)){ \ log_err(message); \ return message; \ } #define mu_run_test(test) \ debug("...
C
// // tfthreadpool.h // tfcommon0.4 // // Created by yin shen on 11/5/12. // // #ifndef tfcommon_tfthreadpool_h #define tfcommon_tfthreadpool_h /*! @file tfthreadpool @abstract the file provides functions to add tasks to a thread pool. @discussion version 0.5 (update at tufu) @author sh...
C
#include<stdio.h> int main() { int previous, actual; previous = getchar(); putchar(previous); while ((actual = getchar()) != EOF) { if (previous == ' ' && actual == ' ') { continue; } putchar(actual); previous = actual; } printf("\n"); return ...
C
int glob = 32; int f(int x) { if (x < 45) return x * x; else return 2 + x * x; } int g(int x) { int i; int j = 0; for (i = 0; i < x; i++) { j += 2; } return j; } int h(int x) { return x + glob; } int h2(int x) { return h(x + 30); } int h3(int x) { ...
C
//#define _XOPEN_SOURCE 600 #include <sys/types.h> #include <sys/stat.h> #include <fts.h> #include <stdio.h> #include <stdlib.h> #include <dirent.h> #include <string.h> #include "myls.h" void usage(void){ (void)fprintf(stderr, "usage: ls [-l] [file ...]\n"); exit(1); } int filter(const FTSENT *a, const FT...
C
#include <stdio.h> void f(int x) { switch (x) { case 0: puts("0"); break; case 1: puts("1"); break; case 2: puts("2"); case 3: puts("3"); break; default: puts("default"); } }
C
#include <stdlib.h> #include <stdio.h> #include "ringbuffer.h" #include "testing.h" #define S 8 void test_write_read() { char tmp[256]; int tmplen = 0; char buff[S]; struct ringbuffer b; rb_init(&b, buff, S); eqint(RB_ERR_INSUFFICIENT, rb_write(&b, "abcdefgh", 8)); eqint(RB_OK, rb_wri...
C
#include <stdio.h> #include <stdlib.h> #include <mqueue.h> #include <string.h> int main(int argc, char* argv[]){ struct mq_attr attr; attr.mq_maxmsg = 10; //message q size attr.mq_msgsize = 4; //message size, bite char msg[100]; int stat; mqd_t mfd; mfd = mq_open("/lab3_test", O_WRONLY, 06...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> typedef char String[1024]; int main(void) { const int DAIKICHI = 1; const int CHUKICHI = 2; const int KICHI = 3; const int KYO = 4; printf("あなたの運勢を占います\n"); ssrand((unsigned)time(OUL)); int fortune = rand() % 4 + 1; switch (fortune) { case DAIKICHI:...
C
#include<stdio.h> struct rectangle{ int l; int w; }; int main() { struct rectangle r= {10,5}; struct rectangle *p=&r; // storing the address in p pointer. r.l=15; // noraml variable dot operator. printf("%d\n",r.l); (*p).l=20; // changing value of lenght using address. // pointer variable the ab...
C
/* shell.c ------ Simple example of some code that creates processes ... */ #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <unistd.h> #include <sys/wait.h> #include <string.h> struct globals { char *name; char *value; }; int pid, rc; char s[50]; struct globals glob[20]; int...
C
#include "testbase64.h" #include "base64.h" #include <string.h> int BASE64TESTSHOWDATA = 0; int SHOWTIMING = 0; const int BASE64TESTMAXDATALEN=1<<27; // Tests up to 128 MB // Function for automated testing of base64.h. Also times. int testBase64( const void* data, int dataLen ) { unsigned char* binaryPtr = (unsig...
C
#include <Arduino.h> // // INTERFACE // void loadConfigModules(uint8_t pos); void saveConfigModules(uint8_t pos); // CONFIG void loadConfig() { EEPROM.begin(512); uint8_t load = 0; int pos = 0; EEPROM.get(0, load); pos = 1; if(load == 1) { EEPROM.get(pos, config); pos += sizeof(struct Config); ...
C
#include <ChainableLED.h> #include <Arduino.h> #include <Wire.h> #include "DS1307.h" #include <SPI.h> #include <SD.h> #include <SparkFunBME280.h> #include "functions.c" #include "initialisation.c" #include "functions.h" #include "carteSD.c" //**************************************************************** //* Nom ...
C
#include <stdio.h> int main(int argc, char* argv[]) { short day = 0; system("clear"); printf("Hey. This is a test program that displays the day of the week.\nPlease enter the day of the week as a number:\n\n"); scanf("%d", &day); switch (day) { case 1: printf("It's Monday"); break; case 2: p...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include "../cfitsio/fitsio.h" #include "psf.h" #define PANIC_ON_BAD_FITSIO_STATUS(error_message, status) { \ const int status_value = (status); \ if (status_value != 0) { \ fprintf(stderr, "KABUKINAI_PSF_FAILURE: %s at line %d in file %s\n", (error_messag...
C
#include "../global.h" void echo(args_vector *argv) { for (int i = 1; i < argv->used - 1; i++) { printf("%s ", argv->argv[i]); } if (argv->used > 1) { printf("%s", argv->argv[argv->used - 1]); } printf("\n"); }
C
/* Autor: Felipe de Assis Costa RA: 0049539 Data: */ #include <stdio.h> #include <stdlib.h> #include <string.h> #define tam1 5 // vendedores #define tam2 4 // vendas semanais int main(int argc, char const *argv[]) { float vendas[tam1][tam2], totalVendas[tam1], totalMes, totalSemana[tam2]; totalMes = 0; for (in...
C
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <ctype.h> #include <string.h> #define DICTIONARY "dictionaries/small" typedef struct Node { bool is_word; struct Node *letter[27]; } Node; bool load(const char* dictionary, Node **head) { Node *root, *p; root = (Node*) malloc (size...
C
#include <stdlib.h> #include <string.h> #include "pathfinding.h" #include "list.h" typedef struct node_t { double distance_from_start; double distance_to_end; double distance; void * position; struct node_t * parent; } node_t; typedef struct astar_t { void * start; void * end; list_t ...
C
#include <stdio.h> #define MAX 1000 int main() { int arr[MAX]; int digits_count=0; do { scanf("%d", & arr[digits_count]); if(arr[digits_count]==42) { break; } digits_count++; }while(digits_count < MAX); int i=0; for( i=0 ; i<digits_count ; ++i ) { for( int j=digits_count-1; j>i; --j ) { ...
C
#include <stdio.h> #include <stdlib.h> void eject(char *message) { char *usage = "Usage: \n\tmakenote 'note' [-b notebook] [-i]\ \n\tmakenote -r [a/f/l/i] [-b notebook]\ \n\tmakenote -c [-b notebook]\n"; printf("Error: %s\n%s", message, usage); exit(1); }
C
#include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <sys/types.h> #include <fcntl.h> int main(void) { int fd; char *file_path = "/dev/video0"; fd = open(file_path, O_CREAT | O_RDWR, 0777); if (fd < 0) { perror("open"); exit(-1); } printf("fd = %d\n", fd);...
C
#include <inttypes.h> #include <stdbool.h> #include <avr/io.h> #include <avr/interrupt.h> #include <util/delay.h> // I/O definitions. (PS) indicates an interface with the // PlayStation console, (SS) indicates an interface with the // Saturn controller. // (PS) MISO pin. Set as output to use SPI. #define MISO_DDR_R...
C
/* whisper.c */ inherit M_COMMAND; string *usage(void) { string *lines; lines = ({ "Использование: шепнуть [-h] ИГРОК СООБЩЕНИЕ" }); lines += ({ "" }); lines += ({ "Шепнуть сообщение указанному игроку." }); lines += ({ "" }); lines += ({ "Опции:" }); lines += ({ "\t-h\tПомошь, вызывает эту справк...
C
/* Useful function signatures int connect(int sockfd, const struct sockaddr *addr,socklen_t addrlen); int socket(int domain, int type, int protocol); int getaddrinfo(const char *node, const char *service,const struct addrinfo *hints,struct addrinfo **res); ssize_t read(int fd, void *buf, size_t count); ssize_t write(in...
C
/* AOJ 0073 * * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0073 * */ #include <stdio.h> #include <math.h> double heron(double a, double b, double c){ double s; s = (a + b + c)/2; return sqrt(s*(s-a)*(s-b)*(s-c)); } int main(){ int x; int h; double d; double S; wh...
C
/* ** EPITECH PROJECT, 2018 ** my_rpg_2017 ** File description: ** draw_maze function */ #include "game_info.h" #include "hud.h" #include "game_object.h" #include "obj_decor.h" void draw_maze_projectile(game_t *game) { game_obj_t *sp_proj; for (projectile_t *it = game->projectile->next; it != game->projectile ; ...
C
#include <stdio.h> #include <stdlib.h> #define MAX 1000000 int arcs[10][10];//邻接矩阵 int D[10];//保存最短路径长度 int p[10][10];//路径 int final[10];//若final[i] = 1则说明 顶点vi已在集合S中 int n = 0;//顶点个数 int v0 = 0;//源点 int v,w; void ShortestPath_DIJ() { int i = 0, min = 0; for (v = 0; v < n; v++) //循环 初始化 { final[v]...
C
/* * dfunc.c * Kim Buckner * * this function is designed to do nothing important but give a chance * to trace execution with the debugger. */ int dfunc(int one, int two) { int temp; temp=one * 5; temp+= two; temp=temp * 3; return temp; }
C
/* CTU Open Contest 2002 ===================== Sample solution for the problem: symmetry Pavel Kos, Oct 2002 */ #include <stdio.h> #include <stdlib.h> #define MAX_COUNT 100000 typedef int Point[2]; Point points[MAX_COUNT]; int compare(const void * a, const void * b) { const Point * aa = (const Point...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* utils2.c :+: :+: :+: ...
C
/** * Implementasi ADT Dynamic Array * * Dibuat dan ditulis oleh Bayu Laksana * -- tanggal 22 Januari 2019 * Struktur Data 2020 * Implementasi untuk bahasa C * * !!NOTE!! * cara menggunakan lihat pada fungsi main() */ #include <stdlib.h> #include <stdbool.h> // Struktur ADT DynamicArray typedef struct dy...
C
/* use randomised restricted local search to find regular vertex-induced subgraphs with a prescribed valency in undirected, unweigted graphs; first, a subgraph with the desired number of edges is found using the objective function from sub_search.c; next, an attempt is made to find a "nearby" regular s...
C
#include <stdlib.h> size_t ft_strlen(const char *str) { size_t i; i = 0; while (*str++) i++; return (i); }
C
/******************************************************************************* * * File Name : ft_errors.c * * Purpose : * * Creation Date : 22-10-13 16:28:16 * * Last Modified : 22-10-13 16:36:09 * * Created By : * *******************************************************************************/ #include <stdio...
C
#include "stdafx.h" #include "utils.h" void print_signal(double* signal, size_t len) { for (size_t i = 0; i < len; i++) { printf("%e ", 10*log10(signal[i])); } printf("\n"); } void print_complex(_Dcomplex num) { printf("%f%+fi ", num._Val[0], num._Val[1]); } plot_signal(_Dcomplex* signal, size_t size) { for (...
C
#include<stdio.h> /* We will learn about array and how to perfom basic functions on an array Definition: An Array is a collection of similar data type stored in a contigious memory location. This means, that arrays are collection of various data belonging to same data type like int or char. This data is stored in a co...
C
/* * File: calculate.c * * Calculation of sector numbers and pages */ #include <stdint.h> #include <stlink.h> #include "calculate.h" #include "common_flash.h" uint32_t calculate_F4_sectornum(uint32_t flashaddr) { uint32_t offset = 0; flashaddr &= ~STM32_FLASH_BASE; // page now holding the actual flash addre...
C
#include "nm.h" #include <stdio.h> int get_symtab_command( unsigned char *file_content, t_symtab_command *syc) { t_mach_header mach_header; long long offset; unsigned int i; ft_memcpy(&mach_header, file_content, sizeof(t_mach_header)); offset = sizeof(t_mach_header); i = 0; while (i < mach_header.ncmds...
C
#include<ncurses.h> void rldnum(int y, int x) //czysci miejsce na wpisanie liczby zaczynajace sie w (x,y) { move(y,x); int a; attron(COLOR_PAIR(2)); for(a=0; a<70; a++) printw(" "); attron(COLOR_PAIR(1)); mvprintw(y,x-1," "); return; } void rldscr() //czysci terminal { ...
C
#include <stdio.h> #include <string.h> int main() { char a[50],b[50]; printf("Primeira Nome: \n"); scanf(" %[^\n]s",a); printf("Segundo Nome: \n"); scanf(" %[^\n]s",b); printf("---------\n"); if (strcmp(a,b) > 0) { printf("%s %s \n", b,a); } else if (strcmp(a,b) < 0) { printf("%s %s \n", a,b); } e...
C
// ----------------------------------------------------------------- // ----------------------- BUILTIN PROCEDURES ---------------------- // ----------------------------------------------------------------- extern void exit(uint64_t code); extern uint64_t read(uint64_t fd, uint64_t* buffer, uint64_t bytes_to_read...
C
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <stdint.h> typedef struct { int height; int width; int length; } box; typedef struct { box **storage; int size; } boxStack; int comparator(const void * a, const void * b) { int left = (* (box **) a)->height; int right = ...
C
//Author: Abs_; /* This is simple problem, we know Diameter = 2 * radius. we will use this formula */ #include<stdio.h> #include<math.h> #define pi 3.1416 void main() { int x1, y1, x2, y2, x, y; float radius, area; printf("Enter the values of x1, y1, x2, y2: "); scanf("%d %d %d %d", &x1, &y1, ...
C
#include <stdio.h> #include <stdlib.h> #include "ArrayList.h" #include "eLetra.h" #include "parse.h" // ###TU_TIPO_DE_DATO### int parser_eLetra(FILE* pFile, ArrayList* AL_eLetra, char* nomArch) { eLetra *auxeLetra; //DECLARO EL TIPO DE ELEMENTO QUE VA A LEER DESDE EL ARCHIVO // RECORDAR QUE TODAS...
C
#include<stdio.h> void turn(double a[], int n); int main(void) { double a[] = { 1.1, 2.2, 3.3, 4.4 }; turn(a, 4); printf("%f,%f,%f,%f\n", a[1], a[2], a[3], a[4]); return 0; } void turn(double a[], int n) { int m; double mid; for (m = 0; m < (n / 2); m++) { mid = *(a + m); *(a + m) = *(a + n - m); *(a...
C
/* BY SUBMITTING THIS FILE AS PART OF MY LAB ASSIGNMENT, I CERTIFY THAT ** ALL OF THE CODE FOUND WITHIN THIS FILE WAS CREATED BY ME WITH NO ** ASSISTANCE FROM ANY PERSON OTHER THAN THE INSTRUCTOR OF THIS COURSE ** OR ONE OF OUR UNDERGRADUATE GRADERS. ** optionThree.c created by Kohl Kuntze */ #include ...
C
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> int main() { int n,i,j,k,one; scanf("%d", &k); one=1; // Complete the code to print the pattern. for(i=1;i<=(2*k-1);i++){ for(j=1;j<=(2*k-1);j++){ for(n=1;n<=k;n++){ if(i==...
C
/* * SPISD.c * * Created: 29.04.2019 10:20:54 * Author : Paul */ #include <avr/delay.h> #include <avr/io.h> #include "USART.h" #define EN1 PD4 #define EN2 PD5 #define SS PB4 unsigned char CMD0[] = {0x40, 0x00, 0x00, 0x00, 0x00, 0x95}; unsigned char CMD1[] = {0x41, 0x00, 0x00, 0x00, 0x00, 0x01}; unsigned char...
C
#define _GNU_SOURCE #include <dirent.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> #include <time.h> #include <unistd.h> // function to find latest modified directory char* findLatestDirectory(char* path, char* prefix){ struct stat dirStat; char directoryNa...
C
/* wunzip.c takes in a compressed file and writing (to standard output again) the uncompressed results author: Athena Evans date: Jan 29, 2020 class: CIS3207 */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> // main int main(int agrc, char *argv[]){...
C
#include <stdio.h> #include <stdlib.h> typedef struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; } TreeNode; void postOrder(TreeNode *root) { if (root == NULL) return; postOrder(root->left); postOrder(root->right); printf("%d ", root->val); } TreeNode *reCo...
C
#include "SDL.h" #include "SDL_image.h" #include "include/scene.h" int main(int argc, char *argv[]) { SDL_Window * window; SDL_Renderer * renderer; SDL_Event event; scene scene1; if (SDL_Init(SDL_INIT_VIDEO) < 0) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", ...
C
/* PREDICTOR_RANDOM.C ------------------ */ #include <stdlib.h> #include <stdio.h> #include "predictor_random.h" double CSP_predictor_random::predict(uint64_t user, uint64_t movie, uint64_t day) { user = user; movie = movie; day = day; // return a random value between min and max return dataset->minimum + rand...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* polybe.c :+: :+: :+: ...
C
/**************************************************************** Copyright (C) 2015 Sean Guo. All rights reserved. > File Name: < leds.h > > Author: < Sean Guo > > Mail: < iseanxp+code@gmail.com > > Created Time: < 2015/07/31 > > Last Changed: < 2015/10/28 > > De...
C
#include<stdio.h> #include<stdlib.h> #include<signal.h> int interrupt(){ printf("interrupt called\n"); //sleep(1); printf("Interrupt function ended\n"); } int main() { signal(SIGINT,interrupt); printf("signal set\n"); sleep(10); /*why isn't main func sleeping after pressing Ctr+C?" */ printf("main func resumed\n"); r...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <pthread.h> #include <semaphore.h> #define MAXSIZE 10 sem_t sem; int stack[MAXSIZE]; void handler_data() { int i; for(i=0;i<MAXSIZE;i++) { sem_wait(&sem); printf("%d\n", stack[i]); } } void provider_data() { int i; for(i=0;i...
C
#include "ft_printf.h" static void params_parsing(unsigned long c, t_fmt *params, int hex_len) { if (params->precision >= 0) params->zero = 0; if (c == 0 && params->precision == 0) params->precision = 0; else if (hex_len > params->precision) params->precision = hex_len; if (params->width < 0) { params->mi...
C
#include <stdio.h> #include "library.h" #include "Unittest.h" enum constants { INF = 2147483647, ERCODE = -1, ORLEQ = 4, ONE = 1, TWO = 2, ZERO = 0 }; int main() { double a = NAN; double b = NAN; double c = NAN; double x1 = NAN; double x2 = NAN; printf("This program can...
C
#include <stdlib.h> #include "holberton.h" /** * create_array - create array with dinamic memory * @size: size of array * @c: string * * Return: pointer to array */ char *create_array(unsigned int size, char c) { char *str; unsigned int i = 0; if (size == 0) return (NULL); str = malloc(size * sizeof(*str))...
C
// // Ex3Q1.c // // // Created by Alexandre on 02.04.15. // // //#include "Ex3.h" #include <complex.h> #define PI 3.14159265358979323846 #include <stdio.h> #include <math.h> #include <float.h> #include <complex.h> #include <stdlib.h> complex double **make_matrix(int ,int ); complex double **MakeCn(int); complex ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_lstdel.c :+: :+: :+: ...
C
/* Problem 1: ADT Value Definition abstract typedef <int small, int big> ORDEREDPAIR Conditions small <= big Operators abstract NUMBERS makeOrderedPair(s, b) int s, b precondition s <= b postcondition makeOrderedPair.small = s makeOrderedPair.big = b abstract int getSumInRange(n) NUMBERS n postcondition fo...
C
#include <stdio.h> #include <string.h> #include <unistd.h> #include <errno.h> #include <stdlib.h> #include <signal.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <kj_evo/kj_evo.h> #define PORT 49152 // listening port tcp #define BACKLOG 10 // dimensione del...
C
/* ~ bigint/bigint.h * * Copyright (c) 2014 Rafal (robin92pl@gmail.com) * For licensing information please see LICENSE file located in main directory. * * This file contains declarations of public objects provided by bigint library. */ #ifndef BIGINT_H_ #define BIGINT_H_ #include <stdint.h> /** Stores big inte...
C
#include <stdio.h> #include <stdlib.h> #include "dish.h" #include "mother.h" #include "child.h" void print_begin_message(int m, int n, int t) { printf("There are %d baby crows, %d feeding pots, and %d feedings\n", n, m, t); } int main() { int m, n, t; printf("Enter m(dish plate), n(children),...
C
#ifndef __GARDEN_H #define __GARDEN_H #include <stdio.h> #include <stdlib.h> #include "child.h" typedef enum {Chova, TromChova ,TromTromChova ,NofTypes} Type; typedef struct { char* nameOfGarden; Type typeOfGarden; Child** allChildren; int numOfChildren; } Garden; const char* typeTilte[NofTypes]; int initGarden...
C
#include<stdio.h> #include<stdlib.h> #define max 3 int top = -1; int n; int stack[4]; int push(); int pop(); int show(); int main() { int choice; do { printf("choose an option\n"); printf("1 to push\n2 to pop\n3 to show\n4 to exit\n"); scanf("%d",&choice); switch(choice) { case 1:printf("enter elem...
C
#include "argparse.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #define ARGCAP 3 struct argParser argParser; void initArgs() { argParser.capacity = ARGCAP; argParser.argList = malloc(sizeof(struct arg) * argParser.capacity); argParser.len = 0; } void addArg(char *name) { if (argParser.len <...
C
// Author: Luke Williams // Light Control code (includes motion detector code) #include <light.h> #include <sensors.h> /*! \brief change the light as directed by maintenance panel * * Outputs: change state on light pin to control the light */ void led_maintenance(unsigned char lightState) { switch (lightState)...
C
#include <stdio.h> #include <stdlib.h> int main() { // 上下弹跳小球思路 给定一个上界和下届,一个最大高度,如果到达最大高度,则使方向相反,方向用正负表示 int i, j; int x = 5; int y = 10; int volicity = 1; int height = 20; while (1) { x += volicity; system("cls"); for (i = 0; i < x; i++) { pri...
C
/* time interval in seconds to sleep before looking for updates in the main loop */ #define SLEEPINTERVAL 1 #define PATH(name) "/home/mikhail/.config/dwmblocks/blocks/"name /* If interval of a block is set to 0, the block will only be updated once at startup. * If interval is s...
C
#include<stdio.h> #include<stdlib.h> #include"queue.h" queue creat_queue(){ queue q = (queue) malloc (sizeof(queue)); q->front = NULL; q->rear = NULL; return q; } int is_empty(queue q){ return ((q->front == q->rear) && (q->front == NULL)); } int is_full(queue q){ return 0; } node makenode(el...
C
// // Created by Ahmed Bahnasy on 15.08.20. // #ifndef ALGORITHMS_GREATESTCOMMONDIVISOR_H #define ALGORITHMS_GREATESTCOMMONDIVISOR_H int gcd (int a, int b) { if (b == 0) { return a; } else { return (b%a, a); } } #endif //ALGORITHMS_GREATESTCOMMONDIVISOR_H
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <signal.h> #include <sys/wait.h> #include <arpa/inet.h> #include <sys/socket.h> #define BUF_SIZE 1024 //버프사이즈 지정 void error_handling(char *message); void read_childproc(int sig); int main(int argc, char *arg...
C
#include<stdio.h> void showbits(unsigned char m); main() { unsigned char n=0xD9; unsigned char a; unsigned char b; int pos=4,nob=4; a=n<<(pos-(nob-1)); b=a>>(8-nob); printf("%x\n",b); printf("%d\n",b); showbits(b); } void showbits(unsigned char m) { int i; unsigned char a; for (i=7;...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* rr_operations.c :+: :+: :+: ...
C
// ReceiverLogger.c // Implementation of the ReceiverLogger ADT // The ReceiverLogger ADT logs events and maintain statistics // for the receiver // Written by Kevin Luxa (z5074984 - k.luxa@student.unsw.edu.au) // for the Simple Transport Protocol (COMP3331 18s2 Assignment) #include <err.h> #include <semaphore.h> #inc...
C
#include <check.h> #include "../src/Calculator.h" START_TEST(add) { ck_assert_str_eq("II", roman_add("I", "I")); ck_assert_str_eq("V", roman_add("IV", "I")); ck_assert_str_eq("MVI", roman_add("MIV", "II")); } END_TEST START_TEST(subtract) { ck_assert_str_eq("I", roman_subtract("III", "II")); ck_assert_str_e...
C
#include "lf_list.h" #include "limits.h" #include "string.h" int is_marked(long i) { return (int) (i & 0x1L); } long get_unmarked(const long w) { return w & ~0x1L; } long get_marked(const long w) { return w | 0x1L; } list* list_new(list *l) { node* head = (node*) malloc(sizeof(node)); head->nex...