language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <unistd.h> #include <string.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> //Bitwise stuf #include <sys/wait.h> #include <stdlib.h> #include <assert.h> #include "tokenize.h" #include "svec.h" #include <fcntl.h> // for open sysCall // Written By Josh Spicer // Used Nat Tuck's "sort-pipe....
C
#include "malloc2.h" static char big_block[BLOCKSIZE]; static char* mem_val[MEMSIZE]; //stores memory addresses of allocated memory // return a pointer to the memory buffer requested void* my_malloc(unsigned int size, char *file, int line) { static int initialized = 0; static struct MemEntry *root; struc...
C
#include <stdio.h> //vetores //struct //ponteiros void troca(int valores[]); int main(){ int a = 2; int b = 3; int numeros[2]; numeros[0] = 24; numeros[1] = 3; troca(numeros); printf("%d %d", numeros[0], numeros[1]); return 0; } void troca(int valores[]){...
C
#include<stdio.h> int main() { int a,b,c; scanf ("%d",&a); scanf ("%d",&b); c=a+b; printf ("sum=%d",c); return 0; }
C
#include <signal.h> #include <stdlib.h> #include <stdio.h> #include <sys/wait.h> int main(int argc, char** argv) { int child, status; child = fork(); if (child == 0) { srand(time(NULL)); if (rand() < RAND_MAX/4) { /* kill self with a signal */ kill(getpid(), SIGTERM); } return rand(); } else { ...
C
#include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <sys/wait.h> #include <math.h> #include <sys/mman.h> #include <semaphore.h> #include <pthread.h> #include <fcntl.h> #include <sys/shm.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/fcntl.h> #includ...
C
/* FILE * long_out_profile.c * * For profiles of the longitudinal output variable. * * Copyright (c) 2002 Regents of the University of California * */ #include "long_out_profile.h" /* reads a profile item from a character string */ void read_profile_item (char *linebuffer, profile_item *pitem) { sscan...
C
#include <stdio.h> #define M 3 #define N 5 double row_avg(const double a[], int n) { double total = 0; int i; for (i = 0; i < n; i++) total += a[i]; return total / n; } double avg(const double a[][N], int m) { double total = 0; int i; for (i = 0; i < m; i++) total += row_a...
C
#include "../includes/minishell.h" static char *get_outfile(char **arg, char *text) { int i; int j; char *check; char *file; char *temp; i = 0; j = 0; temp = *arg; while (*temp && (*temp == '>' || *temp == ' ' || *temp == '\t') && !check_inside(text, temp)) { j++; temp++; } while (!ft_strchr(">< \...
C
#include "light.h" void clear_all_order_lights(){ HardwareOrder order_types[3] = { HARDWARE_ORDER_UP, HARDWARE_ORDER_INSIDE, HARDWARE_ORDER_DOWN }; for(int f = 0; f < HARDWARE_NUMBER_OF_FLOORS; f++){ for(int i = 0; i < 3; i++){ HardwareOrder type = order_types[i...
C
#include <stdio.h> #include <stdlib.h> typedef int RecType; void merge(RecType * R,int low,int m,int high) { int i=low,j=m+1,p=0; RecType *R1; R1=(RecType*)malloc((high-low+1)*sizeof(RecType)); if(!R1) { return; } while(i<=m&&j<=high) { R1[p++]=(R[i]<R[j])?R[i++]:R[j++]; } while(i<=m) { R1[p++]=R[i++...
C
#include<stdio.h> int main() { char i,ch,j; printf("enter the character:-\n"); scanf("%c",&ch); if(ch>='a' && ch<='z') { ch=ch-32; } if(ch>='A' && ch<='Z') { ch=ch+32; } else printf("Wrong input\n"); printf("\nAfter ch=%c\n",ch); }
C
#include "Task.h" int TaskThree(void) { int first_number = 0; int second_number = 0; int temp = 0; int a = 1; printf("Write two number, to find lowest common divisor"); if (2 != scanf("%i %i", &first_number, &second_number)) { printf("Input Error"); return -1; } if (...
C
#include "holberton.h" /** * _isalpha - function that return 1 if c is a letter and 0 otherwise * * @r: parametre from 4-main.c * Return: 0 or 1 */ int _isalpha(int r) { if ((r >= 65 && r <= 90) || (r >= 97 && r <= 122)) return (1); else return (0); }
C
/* Praxis der Programmierung Projekt 1 Abgabedatum: 2.6.2019 Gruppennummer : <64> Gruppenmitglieder : - <Johnny Hänsel> - MatrikelNr: 796033 - <Florian Frankreiter> - MatrikelNr: 796762 - <Maximilian Metzner> - MatrikelNr: 793692 */ #include <stdlib.h> #include <stdio.h> struct le { ...
C
#include "debug-string.h" typedef struct PccDebugString { int len; char s[PccDebugStringLength]; } PccDebugString; RTE_DEFINE_PER_LCORE(PccDebugString, gPccDebugString); void PccDebugString_Clear() { RTE_PER_LCORE(gPccDebugString).len = 0; RTE_PER_LCORE(gPccDebugString).s[0] = '\0'; } const char* PccDebugStr...
C
/* ** EPITECH PROJECT, 2019 ** my_libc ** File description: ** my_strf */ #include "my_libc.h" #include "my_strf.h" static const op_t ptr_tab[] = { {"d", &my_strf_int}, {"i", &my_strf_int}, {"u", &my_strf_uint}, {"c", &my_strf_char}, {"s", &my_strf_str}, {"f", &my_strf_float}, {"e", &my_st...
C
#include <stdio.h> #include <stdlib.h> #include "funciones.h" /** \brief Funcion que permite hacer la operacion de suma * * \param numeroUno float Primer operando * \param numeroDos float Segundo operando * \return float resultado * */ float sumar(float numeroUno, float numeroDos) { float resultado; resu...
C
#include "Types.h" #include "Page.h" #include "ModeSwitch.h" void kPrintString( int iX, int iY, const char* pcString ); BOOL kInitializeKernel64Area(); BOOL kIsMemoryEnough(); void kCopyKernel64ImageTo2Mbyte(); // Main // c코드의 엔트리 포인트 함수 // 0x10200 어드레스에 위치 // 보호모드 엔트리 포인트(EntryPoint.s)에서 최초로 실행되는 C코드 // Main()함수를 가장...
C
/** * Gerencia e chama as funções relacionadas ao casamento de palavras através da * força bruta, imprimindo e lendo os dados necessários * * Gustavo Viegas (3026) e Heitor Passeado (3055) * @author Heitor Passeado */ #include "bruteForceInterface.h" // Tela inicial da busca de padrão com força bruta void _brut...
C
//gcc test2.c -lcurl -o test #include <stdio.h> #include <stdlib.h> #include <string.h> #include <memory.h> #include <curl/curl.h> #define SIZE 200 //Buffer struct string { char *ptr; size_t len; }; //Initialize Buffer void init_string(struct string *s) { s->len = 0; s->ptr = malloc(s->len+1); if (s->ptr ==...
C
/* Based on f477.c, from https://sourceforge.net/projects/egm96-f477-c/ which is, in turn, based on F477.F, from http://earth-info.nga.mil/GandG/wgs84/gravitymod/egm96/egm96.html Preprocess the constant files CORCOEF and EGM96 to be included in compilation. */ #include<stdio.h> #include<math.h> #include ...
C
#include "lists.h" /** * add_nodeint_end - Add new node at end of list * @head: Pointer to pointer to head * @n: Value for n in node * * Return: Address to new node */ listint_t *add_nodeint_end(listint_t **head, const int n) { listint_t *new, *last; new = malloc(sizeof(listint_t)); if (new == NULL) { retu...
C
/* Program 1 Using circular representation for a polynomial, design, develop, and execute a program in C to accept two polynomials, add them, and then print the resulting polynomial. */ #include<stdio.h> #include<string.h> #include<malloc.h> #include<math.h> struct node{ int coef,exp; struct node *lin...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> #include <assert.h> #include <pthread.h> #include <unistd.h> #include <errno.h> #define NUM_THREADS 2 #define GULP_SIZE 156252 #include "mkl.h" /* DGESVD prototype extern void sgesvd_( char* jobu, char* jobvt, int* m, int* n, float* a, ...
C
#include <stdio.h> #include <fcntl.h> #include <stdlib.h> #include <unistd.h> int main(int argc, char **argv) { int i; int fd; char *buff; fd = open(argv[1], O_RDONLY); buff = (char *)malloc(sizeof(char) * 25); read(fd, buff, 25); i = 0; while (i < 25) { printf("%c", buff[i] - i); i++; } printf("\n"...
C
#include "curlhttps.h" /* 读取文本文件的数据,发送给服务端的https服务器 */ int mycurl(char *url, char *filename, char param[][10]) { CURL *curl; CURLcode res; char str[4094] = { }; char newurl[5120] = { }; FILE *p_file; int size; /* 读取文本文件中到数据 */ p_file = fopen(filename, "r"); if (p_file) { memset(str, 0, sizeof(str)); siz...
C
#define N 4 #include <stdio.h> #include <stdlib.h> int main(int argc, char** argv) { int n; int i = 0; float tempoMedio = 0; int vet[N]; //Vettore contenente tempi di esecuzione float accumulatore; //Vettore contenente tempi di attesa perogni processo. int scelta;//Variabile per il ...
C
/* Author: Ruiqi(Rachel) Tao Purpose of the document: Unix HW1 Game Of Life Default input filename: life.txt Compiled with std=c99 */ #include<stdio.h> #include<string.h> #include<stdlib.h> #include <errno.h> extern int errno; void generate(int rows, int columns, int **arr){ //create a new 2D array int **next_...
C
/* Copyright 2021 <Bivolaru Andra> */ #include <stdlib.h> #include <string.h> #include "server.h" server_memory* init_server_memory() { // Allocating memory for the server server_memory *server = malloc(sizeof(server_memory)); DIE(server == NULL, "Unable to allocate memory for the server!\n"); // Initializing me...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* rotations.c :+: :+: :+: ...
C
/** @file * @brief Header file for master player */ #ifndef PLAYER_H #define PLAYER_H #include "buffer.h" #include "audio.h" /** * @defgroup PlayerInterface * * @{ */ /** On stop callback type description */ typedef void(*playerCb_t)(void); /** Callback structure for various player events */ typede...
C
#include<stdio.h> int main(){ int arr[10]; int i,j; printf("Enter 10 numbers:\n"); for(i=0;i<10;i++) scanf("%d",&arr[i]); for(i=0;i<10;i++){ for(j=i+1;j<10;j++){ if(arr[j]<arr[i]){ int temp=arr[i]; arr[i]=arr[j]; arr[j]=temp; } } } printf("After sorting in ascending order,the array is:\n"...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> //Struct Definitions typedef struct { char*firstname; char*lastname; } NAME; typedef struct { int*streetno; char*streetname; char*streetname1; char*city; char*state; char*country; int*zip; } ADDRESS; typedef struct { ...
C
/* Filename: mergeSort.c Author: Tony Zeng Mail: laoweiyeah@gmail.com Function: implement of merge sorting algorithm Time: 2013-6-24 13:56:25 */ #include <stdio.h> #include <stdlib.h> #include "array.h" void merge(int* array, int low, int half, int high) { int leftLength = half - low + 1; int rightLenght = hig...
C
#include "Init_IO.h" //ʼPB5PE5Ϊ.ʹڵʱ //LED IOʼ void LED_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); //ʹPC˿ʱ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15; //LED0-->PB.5 ˿ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; // GPIO_InitStructure.G...
C
#include "ev_iochannel.h" #include <string.h> // memset int check_for_close( ev_iochannel_t* self ) { if (self->rio.eof && !self->wio.len) if (self->on_close) self->on_close( self ); return 0; } int on_rio_full( iobuf_t *io ) { ev_iochannel_t *self = (ev_iochannel_t*)io->ctx; ev_io_stop( self->loo...
C
/*! * \~chinese * @header LLErrorCode.h * @abstract SDK定义的错误类型 * @author Hyphenate * @version 3.00 * * \~english * @header LLErrorCode.h * @abstract SDK defined error type * @author Hyphenate * @version 3.00 */ typedef enum{ LLErrorGeneral = 1, /*! \~chinese 一般错误 \~engli...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* heredoc_node.c :+: :+: :+: ...
C
#include "LinkedList.h" #include <stdio.h> #include <stdlib.h> #include <string.h> linked_list_t* ll_create(unsigned int data_size) { linked_list_t *list = malloc(sizeof(linked_list_t)); list->data_size = data_size; list->head = NULL; list->size = 0; return list; } /* * Pe baza datelor trimise ...
C
#include <stdbool.h> #include <stddef.h> // stdbool.h for bool // stddef.h for size_t, ptrdiff_t struct linked_list; struct node; typedef double value_t; typedef struct linked_list { struct node* first; struct node* last; size_t size; } linked_list; typedef struct node { struct node* prev; struct node* next; ...
C
#include <stdio.h> #include <stdlib.h> #include "ulity.h" void *int_to_pointer(int i) { int *pi = (int *)malloc(sizeof(int)); *pi = i; return (void*)pi; } void *float_to_pointer(float f); { float *pf = (float *)malloc(sizeof(float)); *pf = f; return (void*)pf; } int pointer_to_int(void *pi); { r...
C
#define MAX 100 int posx = 0, posy = 0; int cursx = 30, cursy = 30; int nbmouv = 0; int Choix7 ; int Visibilite; FILE *f ; void Effacer_Curseur(int x, int y) { set_drawing_color(color_WHITE); draw_circle_full(x, y, 15); update_graphics () ; return ; } int Verifier_Cases_Autour(int CASE[MAX][MAX], int n) //Ve...
C
#include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <unistd.h> #include <string.h> #include <errno.h> int main() { pid_t result1; pid_t result2; printf("<A> -- pid = %d, ppid = %d\n", getpid(), getppid()); result1 = fork(); if (result1 < 0) { perror("Failed to create p...
C
/* file: $RCSfile: v6init.c,v $ ** rcsid: $Id$ ** Copyright Jeffrey W Percival ** ******************************************************************* ** Space Astronomy Laboratory ** University of Wisconsin ** 1150 University Avenue ** Madison, WI 53706 USA ** ***********************************************************...
C
/* * Copyright (C) ST-Ericsson SA 2010. All rights reserved. * This code is ST-Ericsson proprietary and confidential. * Any use of the code for whatever purpose is subject to * specific written permission of ST-Ericsson SA. */ /* * UNIX domain socket server external interface. */ #ifndef __sockserv_h__ #define...
C
// // Post_processing.c // Astrophysical_Turbulence // // Created by Mrinal Jetti on 09/09/20. // Copyright © 2020 Mrinal Jetti. All rights reserved. // #include "parameters.h" #include "post_processing.h" #include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char *argv[]) { //Variable...
C
#include <stdio.h> main() { int boyut,i,dizi[]={2,5,8,9,5}; boyut=sizeof dizi / sizeof*dizi; printf("%d\n",boyut); getch(); int dizi2[boyut]; for(i=0;i<boyut;i++) { dizi2[i]=dizi[boyut-i-1]; printf("%d,",dizi2[i]); } getch(); }
C
/* * sockselectcl.c : sockselect client * gcc -Wall -ggdb3 sockselectcl.c -o sockselectcl */ #include <fcntl.h> #include <stdlib.h> #include <errno.h> #include <netinet/in.h> #include <resolv.h> #include <sys/socket.h> #include <arpa/inet.h> #include <unistd.h> #include <stdio.h> #include <string.h> #define PORT 55...
C
#include<stdio.h> #include<stdlib.h> void selctionsort(int a[], int n); void main() { int i,n,a[100]; printf("enter the value of n\n"); scanf("%d",&n); printf("enter the elements of the array\n"); for(i=0;i<n;i++) { scanf("%d",&a[i]); } selectionsort(a,n); } void selectionsort(int a[], int n) { int i,j,...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> #include <malloc.h> #include <xmmintrin.h> #include <omp.h> //algorytm eliminacji gaussa-jordana int main(int argc, char *argv[]) { double **A, *b, *x; double c; clock_t begin_t, end_t; double begin_to, end_to; long i,j,k,l,n; n=atoi(argv[1]...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> void swap(char*,int); void gotoloop(char*,int); void main() { char *ch; int i,j,k,l; ch=(char*)malloc(20); //clrscr(); printf("Enter the string\n"); gets(ch); l=strlen(ch); gotoloop(ch,l); return; } void gotoloop(char *ch,int l) { int i,k; k=l; if(l<...
C
#include "led.h" #include "delay.h" #include "sys.h" #include "usart.h" #include "EEpromI2C.H" //1,2,3,4,5,6,7,8,9 int main(void) { u16 i=0; u16 times=0; u8 ReadData[256]={0}; u8 WriteData[256]={0}; for(i=0;i<256;i++) { WriteData[i]=(255-i); } delay_init(); //ʱʼ uart_init(115200); //ڳʼ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* utils.c :+: :+: :+: ...
C
#ifndef TESTVECTEUR_H #define TESTVECTEUR_H #include "cpptest.h" #include "../src/vecteur.h" /** *@brief TestVecteur * La classe de tests sur les vecteurs. */ CPPTEST(TestVecteur) Vecteur vUn(1,1); Vecteur vZero(0,0); TESTCASE(multi1,{ Equals(1*vUn, vUn); }); TESTCASE(multi0,{...
C
#include<stdio.h> int main() { int n1,n2,temp; printf("Enter Number 1 :"); scanf("%d",&n1); printf("Enter Number 2 :"); scanf("%d",&n2); temp = n1; n1 = n2; n2 = temp; // Without Use Of Temp Variable // n1 = n1 + n2; // n2 = n1 - n2; // n1 = n1 - n2; printf("\nThe Number1 and Number2 ...
C
/* ** my_strupcase.c for my_strupcase.c in /home/kiwi/my_lib ** ** Made by Kiwi ** Login <lyes.kaidi@epitech.eu> ** ** Started on Tue Jan 3 10:13:35 2017 Kiwi ** Last update Wed Jan 11 14:51:31 2017 Kiwi */ char *my_strupcase(char *str) { int i; i = 0; while (str[i]) { if (str[i] >= 'a' && str[i...
C
#include <assert.h> int square_of(int x) { return x * x; } int cube_of(int x) { return x * x * x; } int average(int a, int b, int c) { return (a + b + c) / 3; } int calculate_with(int a) { return average(a, square_of(a), cube_of(a)); } int main (int argc, char* argv[]) { assert(calculate_with(10) == 37...
C
/* Date : 2-1-2021 Aim : chart Source : ansi c e4.4 */ #include <stdio.h> void main() { float n1, n2, n3, n4; int i, j, k; printf("Enter four number between 0.0 and 20.0 : "); scanf("%f%f%f%f", &n1, &n2, &n3, &n4); //for(i = 0; i < 4; i++) //{ printf("\n"); for(j = 0; j < 3; j++) { for(k = 0; k...
C
#include<stdio.h> //指向函数的指针变量没有指针的++ -- //函数指针中的形参可有可无 /* int Find_Max(int a,int b) { return a > b ? a : b; } int main(int argc,char* argv[]) { int num1,num2,num3; int (*P)(int,int); P = Find_Max; scanf("%d%d",&num1,&num2); num3 = (*P)(num1,num2); printf("num1 = %d,num2 = %d,num3 = %d\n",num1,num2,num3);...
C
#include <Python.h> #include <numpy/arrayobject.h> #include <stdio.h> #include <stdlib.h> #include <limits.h> PyDoc_STRVAR(popdrop__doc__, "popdrop(n_particles, box_edge_length, particle_radius, droplet_radius, random_seed=None)\n\nDrOP algorithm\n\nPopulate box with particles at non-overlapping locations and cut out ...
C
// File name: ExtremeC_examples_chapter15_3.c // Description: Demonstrate how to use a shared memory and a shared // mutex to cancel a number of processes in progress. #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <string.h> #...
C
/*!*************************************************************************** * Mikroprosessorsystemer * * Labving reaksjonstidsmler * * NTNU Insitutt for elektrofag og fornybar energi * * Ro...
C
#include "str.h" #include "err.h" #include <assert.h> #include <ctype.h> #include <errno.h> #include <error.h> #include <stdlib.h> #include <string.h> char* stringDelete(char *str, const char *pat) { char *strPtr = NULL; while (NULL != (strPtr = strstr(str, pat))) { memmove(strPtr, strPtr+strlen(pat...
C
#include "minishell.h" int count_separator(t_shell sh) { t_token *token; int i; i = 0; while (sh.tokens) { token = sh.tokens->content; if (token->type == SEPARATOR) i++; sh.tokens = sh.tokens->next; } return (i); } int ft_count_exec(t_shell sh) { t_token *token; int i; i = 0; while (sh.tokens)...
C
#include<STC12C5A60S2.h> #include<string.h> #include<pwm.h> #include<ds1302.h> #include<lcd1602.h> /********************************************************************************************* 뼶CPUʱ ãDELAY_MS (?); 1~65535Ϊ0 ֵ ռCPUʽʱֵͬĺʱ עӦ1TƬʱi<600Ӧ12TƬʱi<125 /************************************************...
C
#include <stdio.h> #include <stdlib.h> #include "calculo_cenarios.h" #include "ler_entrada.h" vetor_de_parametros *create(Dados_entrada* pe) { vetor_de_parametros *vetor_de_params = (vetor_de_parametros *)malloc(sizeof(vetor_de_parametros)); vetor_de_params->p = (Parametros_da_saida *)calloc(10, sizeof(Paramet...
C
#define ENDSTRING '\0' int strlen(char *string){ int len=0; while(string[len]!=ENDSTRING) len++; return len; }
C
// // main.c // 02AddTwoNumbers // // Created by apple on 16/11/14. // Copyright © 2016年 fht. All rights reserved. // #include <stdio.h> #include <stdlib.h> struct ListNode { int val; struct ListNode *next; }; struct ListNode* addTwoNumbers(struct ListNode* l1, struct ListNode* l2) { struct ListNode *...
C
// Cezary Stajszczyk 317354 #include "traceroute.h" #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <stdbool.h> #include <errno.h> #include <string.h> #include <assert.h> #include <unistd.h> #include <arpa/inet.h> #include <netinet/in.h> #include <netinet/ip_icmp.h> static inline uint16_t seq_num(...
C
/*Считать с клавиатуры целое основание и целый неотрицательный показатель. Вывести через пробел степени числа основания от нулевой до заданной.*/ #include <stdio.h> int main() { int base, power; int number = 1; scanf("%d %d", &base, &power); for ( int i = 0; i < power; i++ ) { p...
C
int addNewStudent(void) { //repeatable1 char buffer[MAXNAMELENGTH], char ch = getchar();//does this get /\n? int i = 0, subject, j; struct Student *newStudent, *currentStudent = studentHead; //repeatable1 newStudent = (struct Student *)malloc(sizeof(struct Student)); newStudent->subject...
C
#include <stdio.h> int main(void) { int size; scanf("%d",&size); int arr[size],max = 0; for(int i = 0; i < size; i++) { scanf("%d",&arr[i]); if(arr[i > max]) max = arr[i]; } printf("%d",max); return 0; }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* threads.c :+: :+: :+: ...
C
/* ** parse.c for zappy in /home/anthony/repository/zappy/parse.c ** ** Made by Anthony LECLERC ** Login <anthony.leclerc@epitech.eu> ** ** Started on lun. juin 19 23:17:29 2017 Anthony LECLERC ** Last update Fri Jun 30 11:54:58 2017 Hugo Baldassin */ #include <string.h> #include <assert.h> #include <stdlib.h> #i...
C
#include <stdio.h> #include <stdlib.h> #include "tree.h" #include "mylib.h" #include <string.h> #define IS_BLACK(x) ((NULL == (x)) || (BLACK == (x)->colour)) #define IS_RED(x) ((NULL !=(x)) && (RED == (x)->colour)) struct treenode{ char *key; tree left; tree right; int freq; tree_t type; rbt_c...
C
#include<stdio.h> int main(void) { int n,b,c,a; char str1[5],str2[5],str3[5]; scanf("%d",&n); printf("%d",n); scanf("%d %d %d",&a,&b,&c); printf(" \n %d %d %d",a,b,c); scanf("%s %s %s",&str1,&str2,&str3); printf("\n %s %s %s",str1,str2,str3); for (int i=1; i<=100; i++) { if ((i%a) =...
C
#include <stdio.h> double valorAbsoluto(double x) { if (x >= 0.0) return x; else return -(x); } int main(void) { double valor; printf("Digite um número:\n"); scanf("%lf", &valor); printf("%.2lf\n", valorAbsoluto(valor)); return 0; }
C
#include "holberton.h" /** * more_numbers - Prints from 1 to 14, ten times. */ void more_numbers(void) { char num, i; for (i = 0; i < 10; i++) { for (num = 0; num <= 14; num++) { if (num >= 10) _putchar(num / 10 + '0'); _putchar(num % 10 + '0'); } _putchar('\n'); } }
C
#include <stdio.h> #include <dirent.h> #include <sys/stat.h> /** * Main */ int main(int argc, char **argv) { // Parse command line DIR *dir; struct dirent *ent; struct stat fileStat; // Open directory if(argc < 2){ dir = opendir("."); } else{ dir = opendir(argv[1]); } if(dir == NULL)...
C
/** * @file gdt.h * @author James T Oswald * @brief This header library contains code for loading the Global Descriptor Table. * @details For information on why we need a global descriptor table and how we set it up, see: * <a href="https://wiki.osdev.org/LGDT">The OS dev GDT reffrence</a>, * <a href="https://...
C
// seating arrangement #include<stdio.h> int main(){ int testcase,seat; printf("number of testcases: "); scanf("%d",&testcase); for(int i=0;i<testcase;i++){ printf("seat number: "); scanf("%d",&seat); switch(seat%6){ case 0: printf("%d WS\n",seat+1);break; case 1: printf("%...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> int main(int argc, char** argv){ if(argc < 2){ exit(0); } int size; for(int i = 1; i < argc; i++){ size = strlen(argv[i]); printf("%c", argv[i][size - 1]); } printf("\n"); return 0; }
C
/* Generates the Nth lexicographical permutation of * the integers 1, 2, ... n * * Internally it first calculates the factoradic representation of N * before the permutation is generated and returned. * * The returned array will have n elements and it is * the responsibility of the caller to free it. * * Ref...
C
#include <pebble.h> #include "window.h" #include "loadscreen.h" // Keys for AppMessage Dictionary enum { STATUS_KEY = 0, MESSAGE = 1, MODE = 2, CURRENT = 3, REMAIN = 4, BATTERY = 5, RECORDING = 6, POWER = 7 }; static bool initialized = false; static int mode = -1; char* tupleStr(DictionaryIterator *recei...
C
#include "binary_trees.h" /** * binary_tree_is_root - Check if @node is root of binary tree * * @node: Node to be checked * * Return: (1) If @node is the root of binary tree * (0) All other cases */ int binary_tree_is_root(const binary_tree_t *nod...
C
#include <stdio.h> #include <string.h> // #include <math.h> int main(int argc, char *argv[]) { char truthTable[17]; char cur[5]; char gate[5]; int inputs; int totalBits; int truthTableLen; // power function int pow(int b, int e) { int result=1; int power = e; ...
C
#include <stdio.h> #include <time.h> double factorial_with_ll(int number, int ll) // ll - lower limit { if (number < 2) return 1; double product = 1; for (double i = number; i > ll; --i) { product *= i; } return product; } double combinations(int n, int r) { if (n - r < r) r = n - r; return factorial_with_l...
C
/************************************************************* * This is the code by Saurabh Lanje. * YouTube Channel - www.youtube.com/saurabhlanje * Linkedin - www.linkedin.com/in/saurabhlanje *************************************************************/ #include <stdint.h> // Integer declaratio...
C
//----------------------------------------------------------------------------- // Includes //----------------------------------------------------------------------------- #include <softi2c.h> void delay_1ms(void) // 0us ʱ1ms { uint8 a,c; for(c=4;c>0;c--) { //for(b=142;b>0;b--) { ...
C
#include<stdlib.h> #include<stdio.h> // Video resolution #define W 1920 #define H 1279 // Allocate a buffer to store one frame unsigned char frame[H][W][3] = {0}; int main() { int x, y, count; //ffmpeg -loop 1 -i after_10_mins_nnet_1L.jpg -c:v libx264 -t 10 -pix_fmt yuv420p -vf "pad=ceil(i...
C
#include "matriks.h" #include <stdio.h> void BuatMatriks(int Baris, int Kolom, Matriks *M){ indeks i,j; (*M).Baris = Baris; (*M).Kolom = Kolom; for (i = 0; i < Baris; i++){ for (j = 0; j < Kolom; j++){ (*M).Mem[i][j] = 0; } } } indeks BarisPertama (Matriks M) { return BarisMi...
C
/* inherit to have the attachment functionality, i.e. the * object (which must have an inventory) gets the possibility to * hold items in its attach slots. * E.g. a bag which is attached to a belt. */ #include <composite.h> #include <event.h> #include <language.h> #include <macros.h> #include <properties.h> #inclu...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* map.c :+: :+: :+: ...
C
/************************************************************************* > File Name: triangle.c > Author: > Mail: > Created Time: Sat Oct 22 23:30:35 2016 ************************************************************************/ #include<stdio.h> int main() { int line; int lspace = 0; scanf("%d",...
C
#ifndef _STACK_H_ #define _STACK_H_ #include <stddef.h> #include <stdlib.h> typedef struct stack Stack_t; /** * Initializes a stack. * * @return Pointer to a new Stack_t structure. */ Stack_t *stack_init(); /** * Pushes an element to the stack. * * @param stack The stack to push the element onto. * @param e...
C
// 6-3. ϰ Ű ִ get_factorial Լ ȣ #include <stdio.h> int get_factorial(int num) { int i; int result = 1; for (i = 1; i <= num; i++) result *= i; return result; } int main() { int i; int fact; for (i = 0; i <= 5; i++) { fact = get_factorial(i); printf("%2d!= %3d\n", i, fact); } get_factorial(20); }
C
/* screen.h - (c) 2016 James S Renwick ----------------------------------- Authors: James S Renwick */ #pragma once #define _packed_ __attribute__((packed)) #define _noreturn_ __attribute__((noreturn)) typedef unsigned char uint8_t; typedef unsigned short int uint16_t; typedef unsigned long int uint32_t; typ...
C
#include "headers.h" int main(int argc, char const *argv[]) { printf("Parent process started...\n"); if (fork() == 0) { printf("Inside first child process\n"); if (fork() == 0) { printf("Inside second child process\n"); } } printf("Parent process ends.\n"); return 0; }
C
#include "FileManager.h" #include "assert.h" void photostovis_get_filenames_from_client(char* const currentPath, const unsigned int currentPathLen, char full_exe_path[]) { DIR *dirp; char* path = currentPath; assert(path[currentPathLen-1]=='/'); struct dirent *dp; char * filename; char * fullpa...