language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include "holberton.h" /** * print_sign - prints interger sign and returns 1, 0, or -1 * * @n: random number * * Return: 0, 1, / */ int print_sign(int n) { if (n > 0) { _putchar(43); return (1); } if (n < 0) { _putchar(45); return (-1); } if (n == 0) { _putchar('0'); return (0); } return (0); }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_putnbr_base.c :+: :+: :+: ...
C
#include "search_algos.h" /** * binary_search_help - finds value in sorted array of ints * @array: array given * @lo: current low index * @hi: current high index * @value: value to find * Return: index where value is located, -1 if not found */ int binary_search_help(int *array, size_t lo, size_t hi, int valu...
C
#include "mqtt.h" struct mqtt_subscription *ulwi_mqtt_subscriptions = NULL; struct mqtt_subscription *ulwi_mqtt_get_sub(const char *topic) { struct mqtt_subscription *s; HASH_FIND_STR(ulwi_mqtt_subscriptions, topic, s); return s; } bool ulwi_mqtt_sub_exists(const char *topic) { struct mqtt_subscripti...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "stream.h" /************* *Function Name: updateStream *Function Description: Adds a new post to the stream specified in streamName, if the stream does not exist it will create *Parameters In: (userPost Struct) The new post data *Parameters output: N...
C
#include <stdio.h> int Goldbach(int number); int n=0; int isPrime[25000] = {0, 1}; int main() { int T=0; for (int i = 2; i*i < 25000; i++) if(isPrime[i] == 0) for (int j = i*i; j<=25000; j+=i) isPrime[j] = 1; scanf("%d", &T); for (int i = 0; i < T; i++) { ...
C
#include <stdio.h> //如果需要在一个源文件中引用另外一个源文件中定义的变量,我们只需在引用的文件中将变量加上 extern 关键字的声明即可 /*外部变量声明*/ extern int x; extern int y; int add() { return x+y; }
C
/*====================================================================== C <- IPRES(r,A,B) Integral polynomial resultant. Inputs r : a BETA-digit, r > 0. A,B : in Z[x_1,...,x_r]. A and B have positive degrees in x_r. Output C : in Z[x_1,...,x_{r-1}], the resultant of A and B with res...
C
/* Project Name: LESSON_21 Author: MEHMET AKSU Author Email: mmtaksu.25@gmail.com Date: 26 / January / 2020 File Description: count_characters_in_text.c file counts alphanumeric characters in entered text. */ #include <stdio.h> #include <ctype.h> #define SIZE 100 char *sgets(char *p) { ...
C
extern void exit (int); f (char *x) { *x = 'x'; } main () { int i; char x = '\0'; for (i = 0; i < 100; ++i) { f (&x); if (*(const char *) &x != 'x') abort (); } exit (0); }
C
#define MAX_SIZE 1000000 //! ....:::: CERTAMEN 2 ::::.... //! ********************************* Problema 1 ********************************* typedef tipoElem; typedef struct { tipoElem array[MAX_SIZE]; int len; } tColap; //? borrar el nodo i (y su contenido) pr...
C
// floppyBirbGame.c // Module to start/stop the new game thread and provide routines to retrieve game data. #include "floppyBirbGame.h" //------------ variables and definitions ----------------------- #define BIRDBODY_LENGTH 2 #define N_WALLS 4 #define INIT_WALL_x 3 // The initial walls will be generated starting ...
C
//ഫݪOW #include "bbs.h" int reboard() { int fdr, fdw; boardheader bh; fdr=open(BBSHOME"/.BOARDS", O_RDONLY); fdw=open(BBSHOME"/BOARDS.NEW", O_WRONLY | O_CREAT | O_TRUNC, 0644); while(read(fdr,&bh,sizeof(boardheader))==sizeof(boardheader)) { if((bh.brdattr & BRD_CLASS) || (bh.brdattr & BRD_GROUP))...
C
#include <stdio.h> int main() { /* my first program in C */ printf("Hello, World! \n"); void exit (int status); }
C
#include <stdio.h> /* Templates: Count the number of letters in a string. char s[8] = "asdf123"; countLetters(s) = 4 */ /* char[] -> int Return the count of letters in a given string. int countLetters(char s[]) { return 0; } int countLetters(char s[]) { int result; for (int i = 0; s[i] != '\0'; ++i) { ... s[i] ...
C
#include<stdio.h> int main (void) { // //ȽϣСķǰ //µ˳ int a,b,c,t; scanf ("%d %d %d",&a,&b,&c); if (a>b) { t=b; b=a; a=t; } if (b>c) { t=b; b=c; c=t; } if (a>b) { t=b; b=a; a=t; } printf ("%d %d %d",a,b,c); }
C
#include "ZMagic.h" #include "Z_do.h" #include <stdio.h> #include <string.h> #include <getopt.h> #include "Z_do_util.h" int cmd_key(context_t *context) { int i; int ret; int option_index; char *cmd = *context->argv; char c; static const char *usage = "\x1b[1;32mUsage:\x1b[0m \x1b[31m%s\x1b[0m \x1b[1;34m[--hel...
C
/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ void enqueue(struct TreeNode **queue,int *curr, struct TreeNode *val) { *curr += 1; queue[*curr] = val; return; } struct TreeNode *dequeue(s...
C
#include "interface.h" #include "maps.h" #include "rectangle.h" #include <limits.h> #include <unistd.h> #include <stdlib.h> #include <pthread.h> #include <time.h> #include <termios.h> #define TENTOTHENINE 1000000000 int superflag = 0; int row_bar;/*Max:28 Initial: 14 Min: 6*/ struct termios initial; /* Struc...
C
/*------------------------------------------------------------------- DISPLAY_POSITION */ void display_position(struct particle p,int type) { int i; float x; printf("\n particle %i: ",p.rank+1); for (i=0;i<p.x.size;i++) printf(" %i",q[p.x.s[i]]); printf(" %f",p.f); }
C
#include <FreeRTOS.h> #include <queue.h> #include <task.h> #include "Drivers/interrupts.h" #include "Drivers/gpio.h" #include "Drivers/led.h" enum DemoType { MorsecodeDemo, SosDemo, BlinkyDemo }; // Pick demo type to run //enum DemoType demoType = MorsecodeDemo; enum DemoType demoType = SosDemo; #define UNUSE...
C
#include <cf/path.h> #include <cf/err.h> #include <cf/str.h> #include <cf/memory.h> #ifdef CF_OS_WIN #include <windows.h> #include <io.h> #include <direct.h> #include <sys/stat.h> #else #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #endif CF_DECLARE(cf_errno_t) cf_path_...
C
#include<stdio.h> #include<unistd.h> #include<stdlib.h> #include<string.h> int main() { pid_t pid; int fd1[2]; int fd2[2]; pipe(fd1); pipe(fd2); char *parent_talk[]={"hi","hao are you","mo too","bye",NULL}; char *child_talk[]={"hello","i am fine","too","byebye",NULL}; pid=fork(); if(pid==0) //子进程fd2 {...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* cub3d_utils.c :+: :+: :+: ...
C
#include <stdio.h> /* ** The sequence of triangle numbers is generated by adding the natural numbers. ** So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. ** The first ten terms would be: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55. ** Let us list the factors of the first seven triangle numbers: ** ** 1: 1...
C
void delete_first(node **first, node **last) { node*p; if(*first != NULL) { p = *first; *first = (*first)->next; free(p); if(*first == NULL) *last = NULL; } }
C
#include "test.h" //----------------------------------------------------------------- // Defines: //----------------------------------------------------------------- //----------------------------------------------------------------- // Locals: //----------------------------------------------------------------- THREA...
C
// // Created by darius on 04/07/17. // /* Escriba un programa en C que tome 3 cadenas por lineas de comandos A B C e imprima la cadena A después de haber reemplazado todas las ocurrencias de B por C. Ejemplo: ./programa El ejercicio está mal hecho mal bien El ejercicio está bien hecho */ #include <string.h> #includ...
C
#include <stdio.h> #include <stdlib.h> struct Node { int data; struct Node *next; }; struct LinkedList { struct Node* headNode; }; typedef struct Node Node; typedef struct LinkedList LinkedList; void push(Node* headnode, int data, LinkedList* list) { Node* n = (Node*) malloc(sizeof(Nod...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #define NMAX 100 float rand_uniform() { float ret = ((float) rand() + 1.0f) / ((float) RAND_MAX + 2.0f); return ret; } float rand_normal(float mu, float sigma) { float z = sqrt(-2.0f * log(rand_uniform())) * sin(2.0f * M_PI * rand_un...
C
#include <stdio.h> #include "dog.h" /** * init_dog - funtion that initialises dog structure * @d: struct variable * @name: first variable * @age: second variable * @owner: third variable */ void init_dog(struct dog *d, char *name, float age, char *owner) { if (d == NULL) return; d->name = name; d->age = ag...
C
#include <stdio.h> #include <string.h> int main(int argc, char **argv) { char copy_buff[263]; char exploit_string[1024]; char vuln_array[256]; if(argc <= 2){ printf("Usage: %s <name> <message>.\n", argv[0]); exit(0);} strncpy(vuln_array, argv[1], sizeof(vuln_array)); ...
C
/* ============================================================================ * Name: ex4a1 - Server (gcd) * Written by: Sahar Itzhak, Ron Efraim * ID: 308389485, 204661425 * Login: saharyz, ronef * Program: GCD and Primes servers * ========================================================...
C
/* DESCRIPCION : barca al este del puerto FICHERO : /d/limbo/comun/habitacion/limbo/limbo/barca00.c MODIFICACION : 14-07-98 [Angor@Simauria] Creacion. -------------------------------------------------------------------------------- */ #include "./path.h" #include <moving.h>#include <moving.h> inherit ROOM; #de...
C
/* * Copyright (c) 2000-2010 Apple Inc. * All rights reserved. */ #ifndef _STDINT_H_ #define _STDINT_H_ #include <limits.h> #if __LP64__ #define __WORDSIZE 64 #else #define __WORDSIZE 32 #endif /* from ISO/IEC 988:1999 spec */ /* 7.18.1.1 Exact-width integer types */ #include <_types/_int16_t.h> #include <_ty...
C
/*48. תͼ һ n n Ķάʾһͼ ͼ˳ʱת 90 ȡ ˵ ԭתͼζҪֱ޸Ķά벻Ҫʹһתͼ ʾ 1: matrix = [ [1,2,3], [4,5,6], [7,8,9] ], ԭתʹΪ: [ [7,4,1], [8,5,2], [9,6,3] ] ʾ 2: matrix = [ [ 5, 1, 9,11], [ 2, 4, 8,10], [13, 3, 6, 7], [15,14,12,16] ], ԭתʹΪ: [ [15,13, 2, 5], [14, 3, 4, 1], ...
C
#include <sys/types.h> #include <signal.h> #include <unistd.h> #include <stdlib.h> #include <stdbool.h> #include <stdio.h> volatile int count = 0; volatile bool done = false; volatile bool go = false; void usr2Start() { go = true; } void usr1Receive() { count++; } void usr2EndTransmission() { done = true; } in...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> struct student { char USN[10]; char name[50]; float gpa; }; void mergeSort(struct student* studA, int n); void merge(struct student* studC,struct student* studB,struct student* studA,int j,int k,int n); int main() { time_t start,end; int ...
C
//programmer: HYSTON KAYANGE #include<stdio.h> #include<stdlib.h> #include<math.h> int main() { system("COLOR 1A"); int n; int num1,num2; int result; time_t h; time(&h); printf("JCL COMPUSOFT\n"); printf("******************************\n"); printf("%s\n",ctime(&h)); printf("SI...
C
// Calculate the magnitude of a complex number #include <stdio.h> #include <stdlib.h> #include <math.h> // DO NOT CHANGE THIS STRUCT typedef struct _complex { double real; double imaginary; } complex; double complexAbsolute(complex c); complex complexAdd(complex c, complex c2); void showComplex(complex c); ...
C
#include <stdio.h> #include <math.h> void main (void) { printf("Log10 of 100 is %f\n", log10(100.0)); printf("Log10 of 10000 is %f\n", log10(10000.0)); }
C
#include "logging.h" // The global logger // This may not be the best way to do it but it means I can call LOG from anywhere extern logger *glog = NULL; void timestamp(logger *logger_handle) { time_t rawtime; struct tm * timeinfo; time (&rawtime); timeinfo = localtime (&rawtime); fprintf(logger_...
C
#include <assert.h> main() { int i, n; i = 5; n = 0; do n++; while(i--); assert(n == 6); }
C
/** * $Id: thbrk.h,v 1.6 2006-07-31 12:54:02 thep Exp $ * thbrk.h - Thai word segmentation * Created: 2001-05-17 */ #ifndef THAI_THBRK_H #define THAI_THBRK_H #include "thailib.h" /** * @file thbrk.h * @brief Thai word segmentation */ /** * @brief Find word break positions in Thai string * * @param s...
C
#include<stdio.h> int main() { char c; do { while((c=getchar())!=' ') putchar(c); }while(c!='.'); return 0; }
C
/* ** PERSONAL PROJECT, 2019 ** hangman ** File description: ** main hangman */ #include <stdlib.h> #include "../include/my.h" #include "../include/hangman.h" int error_dictionary(int id); char *get_word_from_dico(char *dictionary_path, uint nth); uint choose_n(uint dico_size); uint get_dico_size(char *dictionary_pat...
C
#ifndef DMATRIX_H #define DMATRIX_H typedef struct matrix Matrix; typedef struct array Array; struct array { float element; Array* next; Array* previous; }; struct matrix { int width; int height; Array* root; }; Array* newArray() { Array* array = NULL; return array; } Array* array_add(Array* root, float el...
C
#include "duLinkedList.h" #include <stdlib.h> #include <stdio.h> int main() { int where = 0; /* record where is inserted */ int number = 0; /* record insert Lnode's value */ int count = 0; /* record the number of Lnode which is created in init Linklist */ int flag = 0; /* a si...
C
// n л ̸ ϱ #include <stdio.h> #include <stdbool.h> #include <stdlib.h> #include <string.h> typedef struct Student { char name[20]; int score; }Student; // qsort int compare(const void *a, const void *b) { Student first = *(Student *)a; Student second = *(Student *)b; if(first.score > second.score) return -1...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> /* * Temporary disable ASLR: * echo 0 > /proc/sys/kernel/randomize_va_space * Compile with: * gcc -no-pie -z execstack -o SwinFor1 SwinFor1.c */ int main(int argc, char **argv) { char buf[1024]; strcpy(buf, argv[1]); printf(buf); printf("\n"); exit(0...
C
/* ** fnlist.c for my_ls in /home/desrum_m/rendu/myls/PSU_2014_my_ls ** ** Made by Martin Desrumaux ** Login <desrum_m@epitech.net> ** ** Started on Thu Nov 27 12:47:40 2014 Martin Desrumaux ** Last update Thu May 7 15:45:23 2015 Alexis Guerville */ #include <stdlib.h> #include "lib.h" #include "list.h" int ...
C
/* ** EPITECH PROJECT, 2018 ** mychap ** File description: ** socket.c */ #include <arpa/inet.h> #include <stdio.h> #include <stdlib.h> #include "chap.h" int init_socket(void) { int fd = socket(AF_INET, SOCK_RAW, IPPROTO_UDP); int optval = 1; if (fd == -1) { perror("socket"); exit(84); ...
C
/* Copyright (c) 2015, Erik Lundin. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIM...
C
#include "../inc/libmx.h" int mx_binary_search(char **arr, int size, const char *s, int *count) { if (arr && s && size > 0 && count) { int Index_first = 0; int Index_last = size - 1; int Index_middle; while (Index_first <= Index_last) { (*count)++; Index_mid...
C
struct counter {int seconds,minutes,hours;}; struct counter c; /*@ requires 0<=c.seconds<60 && 0<=c.minutes<60 && 0<=c.hours<24; behavior one: assumes c.seconds < 59 && c.minutes < 59; ensures c.seconds == \old(c.seconds)+1; behavior two: assumes c.seconds == 59 && c.minutes < 59; ensures c.secon...
C
#include<stdio.h> main() { int i,value=10,sum=0; for(i=0;i<=value;i++) sum +=i; printf("the sum of a numbers A and B is %d \n", &sum); }
C
#include<stdio.h> #include<string.h> #include<limits.h> int main0201() { //ֱʾ - ԭ롢롢 //ֱʾзλֵλ֣λ0ʾ1ʾ //1.ԭȫͬ //2.ԭֵλ䣬λΪ1䷴ڲĻϷλ䣬λλȡ 䲹Ϊ+1 int a = 20;//14 00 00 00 //00000000 00000000 00000000 00010100 - ԭ //0x00000014 - ڵ - - ڴʮƵĸʽʾ - Խת int b = -10;//f6 ff ff ff //10000000 00000000 00000000 00001010 - ԭ //11111...
C
#include<stdlib.h> #include<stdio.h> #include<math.h> int main(){ // declarando constantes int n_points = 30000; float k = 16*3.141592; float sigma = 0.05; float *x = malloc(n_points*sizeof(float)); float *v = malloc(n_points*sizeof(float)); float *i_initial = malloc(n_points*sizeof(float)); float *r...
C
/** * Copyright (C) 2013-2015 * * @author jxfengzi@gmail.com * @date 2013-11-19 * * @file TcpExchange.c * * @remark * set tabstop=4 * set shiftwidth=454 * set expandtab */ #include <tiny_malloc.h> #include <tiny_log.h> #include "TcpExchange.h" #define TAG "TcpExchange" TINY_LOR sta...
C
// main.c - Johan Smet - BSD-3-Clause (see LICENSE) #include <stdio.h> #include "utils.h" #include "dyn_array.h" #include "spirv_binary.h" #include "spirv_text.h" #include "spirv_module.h" #include "spirv_simulator.h" #include "runner.h" #include "spirv/spirv.h" void execute_runner(const char *filename) { SPIRV...
C
// // String.c // string // // Created by 王俊 on 2019/3/19. // Copyright © 2019 王俊. All rights reserved. // #include "String.h" #include <string.h> #include <stdlib.h> #include <math.h> #pragma mark - test void StringTest(void) { printf("================ StringTest ================\n"); String s1; ...
C
#include<stdio.h> int main () { int a; int b; b=40; printf("number please "); // printf("enter the digit of your number "); scanf("%d",&a); while( a>b) { printf("%d ",a++); } }
C
#include<stdio.h> #include<conio.h> void main() { int a=32767,b,c; clrscr(); b=a+1; c=a+2; printf("%d\n%d\n%d",a,b,c); getch(); }
C
#include <file/file_path.h> #include <streams/file_stream.h> #include <string/stdstring.h> #include <vfs/vfs_implementation.h> #include <compat/msvc.h> #include <wchar.h> #include "quasi88.h" #include "drive.h" #include "event.h" #include "disks.h" disk_t retro_disks[MAX_DISK_COUNT]; static drive_swap_t swap; void ...
C
///////////////////////////////////////////////////////////// // // // This file holds the allocation algorithms // // // ///////////////////////////////////////////////////////////// #include ...
C
#include <stdio.h> int main() { int n,a, m,b=0, c = 0,x; printf("Check from Number :\t"); scanf("%d", &n); printf("Check To Number :\t"); scanf("%d", &m); while(x>n) { printf("\nTry again\n Check from Number:\t"); scanf("%d", &n); printf("Check ...
C
/************************************************************************* > File Name: save_http.c > Author: yangjx > Mail: yangjx@126.com > Created Time: Wed 18 Jan 2017 04:09:53 PM CST ************************************************************************/ #include<stdio.h> #include<stdlib.h> #include<unist...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> int getnum(char c){ if(c == '1') return 1; else return 0; } int test(int n){ int result=1,i; if( n == 0 ) result = 128; else{ for(i=0;i<(7-n);i++){ result=result*2; } } return result; } int main(){ int count,i,m,j=0,k,x,y; char n[8]; cha...
C
#include<stdio.h> int main() { struct{int x;int y;}x; struct{int x;int y;}y; x.x=8; x.y=5; y.x=x.x; y.y=x.y; printf("x=%i %i\n",x.x,x.y); printf("y=%i %i\n",y.x,y.y); return 0; }
C
/* * This example program runs a full instance of chiventure with an in-memory game. * The CLI is monkey-patched to accept functions that serve to showcase dialogue. * Unfortunately, we did not have time to integrate the dialogue module with the * UI/CLI of chiventure, though the backend is functional, as this will...
C
#include <fcntl.h> #include <unistd.h> #include <stdio.h> #include "rootkitutil.h" /* * Changes the length of a file by adding filler zero's to the end * * by Method */ main(int argc, char **argv) { int fd; long pos1,pos2,diff; char *buf; BASENAME(argv[0]); if(argc!=3) USAGE("original replacement") ...
C
#include<stdio.h> #include<time.h> #include<math.h> long int no_of_operation=0; long no_of_swaps=0; long no_of_comparison=0; void random_quicksort(long int arr[],long int l,long int r) { long int random_pivot,t,fp,sp; if((r-l)<1) return; srand(time(0)); random_pivot = l + rand()%(r-l+1); no_of_operation++; no_o...
C
//Author: Sneha Sirnam //NetId: s_s1078 #include <stdio.h> #include <pthread.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> /* Global Variables shared among threads*/ static FILE* fp; static int seed = 12; static int dealerscore; static int scoreofallplayers[8] = { 0,0,0,0,0,0,0,0 }; static...
C
/* File: exceptions.c * * Interrupt service routines for hardware exceptions. */ #include "exceptions.h" /* IMPORTANT NOTE: * * Compiler may insert "leave, retn" instructions after the inline asm; * we cannot use those however, as the ISR wrapper function makes a FAR * call to this routine. Why does it make a ...
C
#include "general.h" #include "ModbusAP.h" int main() { uint16_t registers[1000]; uint16_t *val=NULL, st, n, transaction_identifier; uint8_t op; int fd, comm_socket; //server listening socket if(server_connect(&fd) ==-1) { printf("error creating connection\n"); re...
C
/* * * Program to determine type of entered character. * i.e. Upper case, lower case, digit or special character. * */ #include <stdio.h> // Uncomment the line below if executing on Windows. //#include <conio.h> int main() { /* * Declare a variable to hold a character. */ char c; /* * Ask the user to input a ...
C
/** @autor: Patrick da Silveira Porto */ #include <stdio.h> #include <locale.h> #include <stdlib.h> #define NUM_CLIENTES 10 struct Cliente { char nome[80]; int diasHospedado; char endereco[255]; float valorConta; }; float calcConta (int diasHospedado) { float valor = 0; valor = 100 * diasHospedado; ...
C
#include "Fichier.h" //************************** //Principe : Permet d'crire dans un fichier les cellules vivantes et morte a chaque gnrations // //Entre :nombre de cellule vivantes , nombre de cellule morte et numro de la gnration //Sortie : fichier texte //Note : //*************************** void FWrite(FILE* pFil...
C
/* vi: set sw=4 ts=4: */ /* * Copyright (C) 2000 by Glenn McGrath * * based on the function base64_encode from http.c in wget v1.6 * Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc. * * Licensed under GPLv2 or later, see file LICENSE in this source tree. */ //usage:#define uuencode_t...
C
#include <assert.h> #include <json-c/json.h> #include <stdio.h> #include <string.h> #include "objecthash.h" bool object_hash(/*const*/ json_object *j, byte hash[HASH_SIZE]); static void hash_init(hash_ctx * const c) { sha256_init(c); } static void hash_update(hash_ctx * const c, const byte * const b, const siz...
C
#include <stdio.h> #include <sys/ipc.h> int main() { int i ; int x = 10 ; int pid1, pid2, status ; printf("Before forking, the value of x is %d\n", x); /* After forking, we make the parent and its two children increment x in different ways to illustrate that they have different copies of x */ if ((pid1 = f...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* sorting_three.c :+: :+: :+: ...
C
#include <math.h> #include <stdio.h> #include <stdlib.h> //#define SCALAR double #define SCALAR float #define SMALL_NUMBER 1.e-20 #ifndef M_PI // standardy C99 i C11 nie wymagają definiowania stałej M_PI # define M_PI (3.14159265358979323846) #endif #define DOKLADNOSC 0.001 #define MAX_LICZBA_WYRAZOW 111111 /**...
C
#include <stdio.h> #include "../x_thread.h" int func_suspend (void *arg) { printf ("#%d suspend #3\n", x_thread_self ()); fflush (stdout); x_thread_suspend (3); x_thread_sleep (2); printf ("#%d resume #3\n", x_thread_self ()); fflush (stdout); x_thread_resume (3); return 0; } int func_sleep (void *arg...
C
#ifdef NDEBUG #undef NDEBUG #endif #include <stdio.h> #include <stdlib.h> #include <string.h> #include "map.h" bool badName(const char *city); City *cityExists(Map *map, const char *city); Road *isConnected(City *city1, City *city2); City *addCity(Map *map, const char *city); void connectCities(Map *map, City *city1,...
C
#include<stdio.h> #define INF 99999 int D[50][50]; void floyd_warshall(int n) { int i,j,k; for(int k=0;k<n;k++) { for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(D[i][k]+D[k][j]<D[i][j]) { D[i][j]=D[i][k]+D[k][j]; ...
C
#include<stdio.h> int main() { long long n,m,i,j,k,a[50000]; while(scanf("%lld %lld",&n,&m)==2) { for(i=m,j=0;(j<=n-(m%n))&&(i<=n*n);i+=n+1,j++) { a[j]=i; if(m%n==0) { j++;break; } } for(k=0;k<j;k++) { ...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <unistd.h> char binaryCode[]= "\x31\xc0" /* xorl %eax,%eax */ "\x50" /* pushl %eax */ "\x68""./harsh" /* pushl $0x68732f2f */ "\x89\xe3" /* movl %esp,%ebx */ "\x50" /* pushl %eax */ "\x53" /* pushl %ebx */ "\x89\xe1" /* movl %esp,%ecx */ "\x99" /* cdq...
C
#define _XOPEN_SOURCE #define EXIT_FAILURE 1 #define EXIT_SUCCESS 0 #include<stdio.h> #include<stdlib.h> #include<unistd.h> #include<signal.h> #include<sys/wait.h> #include<time.h> //#include <locale.h> pid_t pid; void au(int sig_no) { signal(SIGTSTP, au); if(sig_no==SIGTSTP){ if(pid > 0){ ...
C
/* example.c */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include "parser.h" #include "CommandExecutor.h" #include "Colors.h" void show_command (command * C); char * getCurrentPath() { long size = pathconf(".", _PC_PATH_MAX); char *buf = malloc(sizeof(char) * size); return getcwd(...
C
#include "sys.h" #include "delay.h" #include "usart.h" #include "stm32f4xx.h" void TIM3_init(void); #define START_TIMING TIM_Cmd(TIM3, ENABLE) int main(void) { float float_num = 0.01; int counter = 0; delay_init(168); //ʱʼ uart_init(115200); TIM3_init(); printf("stm32F407Ը\n"); delay_ms(100); wh...
C
#include "stack.h" int peep(Stack S) { //if stack is empty, return stackempty if ( S.top == NULL ) { return STACKEMPTY; } else { //take a local reference to traverse along the stack SLink *temp = S.top; //iterate till the last of the list and print what ever is there in the list while(temp) { ...
C
#include <stdio.h> double k_1(xn, yn){ return (xn + yn); } double k_2(xn, yn, K1, H){ return xn + (H / 2.0) + yn + (H / 2.0) * K1; } double k_3(xn, yn, K2, H){ return (xn + (H/2.0) + yn + (H/2.0) * K2); } double k_4(xn, yn, K3, H){ return (xn + H + yn + H * K3); } double FI(K1, K2, K3, K4){ return (1.0/6...
C
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include "wiringARTIK.h" int inputPin =128; int outputPin =129; int setup(int pin,int dir){ if(!digitalPinMode(pin,dir)) return -1; return 0; } int main(void){ int count=1; if(setup(inputPin,INPUT)==-1) exit(1); if(se...
C
// Identify error #include <stdio.h> #define PI =3.14159 main() { float r = 3.5; float area = PI * r * r; // = is also substituted when macro PI is callled printf("Area : %g \n" , area); } /* 1) float area = PI * r * r becomes float area == 3.14159 * r * r ---> == is not allowed in declar...
C
/* ------------------------------------------------------------------------- @file pool_persons.c @date 11/22/16 21:35:41 @author Martin Noblia @email martin.noblia@openmailbox.org @brief @detail Licence: This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Publ...
C
#include<stdio.h> #include<stdlib.h> #include<limits.h> long int diff(long int a,long int b) { long int d=a-b; if(d<0)return -d; else return d; } int main() { int t,i,n,j; long int min=INT_MAX,d,s[10000]; scanf("%d",&t); while(t--) { min=INT_MAX; scanf("%d",&n); ...
C
#if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)isatty.c 5.2 (Berkeley) 3/9/86"; #endif LIBC_SCCS and not lint /* * Returns 1 iff file is a tty */ #include <termios.h> #include <unistd.h> #include <sgtty.h> int isatty(f) { struct sgttyb ttyb; if (ioctl(f, TIOCGETP, &ttyb) < 0) return(0); ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> //#include "my_func.c" // Լ ǵ #include "my_func.h" // Լ int main() { Sch_list temp; // Ͽ о ϳ ϱ ӽ ü int cnt = 0; // ϱ int option; // ޴ int Month; // ˻ϰ ϴ char Place[30]; // ˻ϰϴ char Type[30]; // ˻ϰ ϴ FILE *fp = fop...
C
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> int main() { int j = 0, t = 0; int a[10] = { 1,2,3,4,5,6,7,8,9,0 }; int b[10] = { 0,9,8,7,6,5,4,3,2,1 }; for (int i = 0; i < 10; i++, j++) { if (i == j) { t = a[i]; a[i] = b[j]; b[j] = t; } printf("%2d", a[i]); } printf("\n"); for (int j = 0; j < ...