language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include "tests.h" int isDigit(char test, const char numbers[]) { return strFind(numbers, test); } int isOperator(char test) { if(strFind("+-", test)) return 1; if(strFind("*/", test)) return 2; return 0; } int isMinus(char test) { return (test == '-'); } int isBraquO(char test) { return (test == '('); } ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> char * stringCopy(char *dest, char *src) { while (*src != 0) { *dest = *src; dest++; // *dest++=*src++ src++; } return dest; } int main(int argc, char *argv[]) { char dest[20]; char src[20]; ...
C
/** * @file freqout.c */ #include "simpletools.h" int int_fraction(int a, int b, int shift); void square_wave_setup(int pin, int freq, int* ctr, int* frq); void freqout(int pin, int msTime, int frequency) { int ctr, frq, channel; char s[32]; square_wave_setup(pin, frequency, &ctr, &frq); if(!CTRA) { ...
C
#include <stdio.h> // void arrayPrint(int array[], int size) { // int last = size - 1; // for ( int i = 0; i < last; i++ ) { // printf("%d ", array[i]); // } // printf("%d\n", array[last]); // } int powerOf2(int exponent){ return 1 << exponent; } int main() { // int size = 6; // int array[] = { ...
C
#include <stdio.h> #define VECTORSIZE 10 typedef struct my_vector { int data[VECTORSIZE]; int size; } my_vector; int main() { int i; my_vector Vector; for (i=0;i<VECTORSIZE;i++) printf("Vector[%d] = %d\n", i, Vector.data[i]); return 0; }
C
/* * bhuan019_lab4_part3.c * * Created: 11-Apr-19 22:54:36 * Author : Boi-Hien Huang */ #include <avr/io.h> enum states {init, start, pass, wait, unlock, incorrect} state; void lock() { switch (state) { case init: state = start; break; case start: if (PINA & 0x04) { state = wait; } break; ...
C
/* #include<stdio.h> int main() { static int i=5; if(--i) { main(); printf("%d ",i); } } ================================================================================== void main() { } //compile and executed successfully ================================================================...
C
#include <stdio.h> #include <stdlib.h> #include "fila.h" Fila *criaFila() { Fila *fila = malloc(sizeof(Fila)); fila->inicio = fila->fim = NULL; return fila; } void inserir(Fila *f, float valor) { No *no = malloc(sizeof(No)); no->valor = valor; no->proximo = NULL; if (estaVazia(f)) ...
C
#include <stdio.h> #include <stdlib.h> /*strtod 함수가 정의된 헤더파일*/ int main() { char *pt; /*소수점 형태의 문자열 "1.23"은 dlubld형 실수로 변환한 겂을 반환 */ printf("%g\n", strtod("1.12", NULL)); /*지수 형태의 문자열 0.12E12"를 실수로 변환한 값을 반환*/ printf("%g\n", strtod("0.12E12", NULL)); /*부호 지정 가능하고 실수 형태의 문자 '-367.177'까지만 처리하고 pt는 종료 지점인 'a'를...
C
#pragma once #pragma once #ifndef FISH_H #define FISH_H #include <windows.h> #include "LinkLIst.h" typedef enum status { _ERROR, _OK }Status; typedef enum _bool { _FALSE, _TRUE }BOOL; // typedef struct _fish_coord { int _x; int _y; }_COORD; //ƶ typedef enum fish_move_dir { _UP, _DOWN, _LEFT, _RIGHT }FISH_...
C
#include <stdio.h> #include <stdlib.h> #define MAX_NAME 100 typedef struct file { char *name; struct file *next; } file; typedef struct dir { char *name; int n_files; file *files; struct dir *next; } dir; typedef struct maindir { char *name; int n_dir; dir *dir; struct maindi...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* write_border.c :+: :+: :+: ...
C
#include "holberton.h" #include <stdio.h> /** * _strpbrk - Function that searches a string for any of a set of bytes * @s: Pointer type char * @accept: Pointer type char * Return: A pointer s */ char *_strpbrk(char *s, char *accept) { int i, x; for (i = 0; s[i] != '\0'; i++) { for (x = 0; accept[x] != '\0'; ...
C
//二进制中1的个数,其中负数用补码表示 int NumberOf1(int n) { int i = 31; int count = 0; for (; i >= 0; i--) { if (n&(1 << i)) count++; } return count; } void Testnum() { NumberOf1(-1); }
C
#include <stdio.h> #include "scanner.h" enum yytokentype { BAI=899, SEMI=901, COMMA=902, PLUS=904, MINUS=905, STAR=906, DIV=907, LP=908, RP=909, LB=910, RB=911, LC=912, RC=913, NUMBER = 258, EOL = 259, ID = 112, WHILE = 113, ELSE = 114, RETURN...
C
#include <stdio.h> #include <string.h> #define TRUE (1) #define FALSE (0) typedef struct Employe{ char Name[50]; char Address[50]; char Phone_Number[50]; }Employee; void main() { int Exit_Flag = TRUE; int counter = 0; int Name_Count=0; int Address_Count=0; int Phone_Count=0; // char Name[4]; // char Addres...
C
#include <Stdio.h> void main(void){ int h=0,l=1000,a,counter1=0,counter2=0; int class1[10] , class2[10],class3[10]; //class 1 grades for(int i=0;i<10;i++){ printf("Please enter the grades of students for class'1' student %d= ",i+1); scanf("%d",&class1[i]); } //class 2 grades for(in...
C
#ifndef _DEBUG_SPI_H #define _DEBUG_SPI_H #include <spi4teensy3.h> #include <SPI.h> #include "DebugSerial.h" /* * Debug print SPI pins */ void debug_print_SPI_pins() { // Teensy 3.2: // PIN_SPI_SCK=13 // PIN_SPI_MOSI=11 // PIN_SPI_MISO=12 // PIN_SPI_SS=10 DEBUG_PRINT("PIN_SPI_SCK="); DEBUG_PRINTLN(PIN_SPI_S...
C
#include <stdio.h> int main() { int z, x; printf("%i + %i = %i\n", z, c, z + c); return 0; }
C
#include "VM.h" void runPM0(FILE* fn1, FILE* fo2) { //void runPM0(FILE* fn1) { // When running the VM, make a stack and an instruction array int stack[MAX_STACK_HEIGHT]; instructionData code[MAX_CODE_LENGTH]; regFile registers; int instructionCount = 0, i; // Initialize registers r...
C
#include<stdio.h> #include<conio.h> #include<string.h> void main() { int bt[20],at[10],n,i,j,temp,p[10],st[10],ct[10],wt[10],tat[10]; int totalwt=0,totaltat=0; float avgwt,avgtat; char pn[10][10],t[10]; printf("Enter the number of process:"); scanf("%d",&n); printf("\n"); f...
C
#include <stdio.h> /* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ int main(){ int matris[3][5]; int i,j; for (i=0; i<3; i++){ for (j=0; j<5; j++){ scanf("%d",&matris[i][j]); } } for (i=0; i<3; i++){ for (j=0; j<5; j++){ printf("%d",matris[i][j]); } ...
C
// ---- Definitions for glib/gslist examples ---- #include <vcc.h> #include <stdlib.h> typedef /*D_tag node */ struct node { int key; struct node * next; } Node; /*D_defs define pred list^(x): ( ((x l= nil) & emp) | ((x |-> loc next: nxt; int key: ky) * list^(nxt)) ) ; define set-fun keys^(...
C
/******************************************************************** //DM430-Lϵͳƴֿ12864ҺģʾԳʾ2ͼƬ //עⰲװλãַ˵Ϊ1602ӿڵ1X20 //עѡҺĵԴλڵλѡ5V3.3VҺѹѡĬ5V //ԻEW430 V5.30 //ߣwww.avrgcc.com //ʱ䣺2014.03.01 ********************************************************************/ #include <msp430x14x.h> #include "Config.h" #inclu...
C
#ifndef KERNEL_TIMER_H #define KERNEL_TIMER_H #include <kernel/stdint.h> #define TIMER_FREQ 1000 #define SWITCH_TASK_FREQ 50 /* Install the timer handler && setup the system clock */ void timer_init(void); /* Set the timer phase in hz */ void timer_phase(uint32_t frequency); /* Loop until the given time has been ...
C
#include <stdio.h> //function prototypes void naturalNumber(int num, int userInput); void naturalNumber(int num, int userInput){ if(num <= userInput){ printf("%d ", num); num++; //calling function itself naturalNumber(num, userInput); } } int main(){ int unserInput; ...
C
#include <stdio.h> int main(){ // Reverse of a value int value,reverse; printf("Enter a value "); scanf("%d",&value); while(value>0) { reverse = reverse*10; reverse = reverse + value%10; value = value/10; } printf("Reversed value is %d",reverse); printf("\...
C
/*===============================================================*\ LINEDRAW \*===============================================================*/ //for create mode - adding new vertex and deleting last added vertex i defined color black //for edit mode - select vertex or edge and delete move or insert i defined ...
C
#include <stdio.h> int count=0; int count_prime(int l,int u,int i); int main(){ int l,u,k; scanf("%d%d",&l,&u); k=count_prime(l+1,u,(l+1)/2); printf("%d",k); return 0; } int count_prime(int l,int u,int i) { if(l>=u) { return count; } else if (i==1) { ...
C
#include "details.h" #include <stdio.h> #include <stdbool.h> #include <stdlib.h> #include <ctype.h> #define RATEARTI 2.05 #define RATEBEET 1.15 #define RATECARR 1.09 #define DISC 0.05 #define SLAB$ 100 #define SHIP1 6.5 #define SLAB1 5 #define SHIP2 14 #define SLAB2 20 #define SHIP3 0.50 int main(void) { { printf("Th...
C
#include "../HEADER/header.h" struct data_node *create_data(int data) { struct data_node *temp = NULL; temp = (struct data_node *) malloc(sizeof (struct data_node) ); temp -> data = data; temp -> prev = temp; temp -> next = temp; return temp; }
C
/* * main.c (C) * * Objetivo: Estudo algoritmo eliminação de gauss em C * * Site: https://dirack.github.io * * Versão 1.0 * * Programador: Rodolfo A C Neves 27/06/2021 * * Email: rodolfo_profissional@hotmail.com * * Licença: GPL-3.0 <https://www.gnu.org/licenses/gpl-3.0.txt>. */ #include<stdio.h> #include<stdlib...
C
#include "election.h" #include <ctype.h> #include <stdio.h> #include <stdlib.h> //include any other headers you need here... //test for ':' and '\0': in case no input before ':' or '\0' void testinput(const char * line, int i, char t) { if (line[i] == t) { printf("Invalid input!\n"); exit(EXIT_FAILURE); } ...
C
#define LIBRARY_TESTING true #include <stdio.h> #include <stdbool.h> #define STRINGMAX 10 // used in snprint functions #define real float // can be changed to suit application #include "../../cCompiler/mattCompiler.h" #include "../../cCompiler/mattCompiler_library.c" int x1x_f ( int , int ); int x1x_f ( int a0, int...
C
/* ///////////////////////////////////////////////////////////////////////// */ /* ///////////////////////////////////////////////////////////////////////// */ /* */ /* Author: Jarret Shook */ ...
C
/* ============================================================================ Name : Siddharth Pathak UvicID : V00876495 Date : 2016/10/24 Assignment : A4 File name : V00876495A4P3.c ============================================================================ */ #include <stdio.h> #inclu...
C
/* * @Author: linfeng * @Date: 2017-01-04 10:05:59 * @Last Modified by: linfeng * @Last Modified time: 2017-07-04 16:51:57 */ #include <unistd.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdbool.h> //bool type #define FAIL(format,arg...) \ do \ { \ char fbuf[1024] = {0}; \ snprintf(f...
C
#include<stdio.h> #define N 800 void main(){ int a[N][N]; int b[N][N]; int c[N][N]; int i,j,k; for(i = 0;i < N;i++){ for(j = 0;j < N;j++){ a[i][j] = 1; b[i][j] = 2; } } for(i = 0; i < N;i++){ for(j = 0;j < N;j++){ c[i][j] = 0; for(k = 0;k != N;k++){ c[i][j] += a[i][k] * b[k][j]; } ...
C
#include <stdio.h> #define ERR_NO 0 #define ERR_NO_FILE 1 #define ERR_NOT_ENOUGH_ELEMENTS 2 int process(FILE *f, float *max1, float *max2); int main(void) { int status; float max1, max2; status = process(stdin, &max1, &max2); switch (status) { case ERR_NO: printf("%f %f\n", max1,...
C
/* ** NAME ** _cold_content -- calculates cold content for a layer ** ** SYNOPSIS ** #include "_snobal.h" ** ** double ** _cold_content( ** double temp, |* temperature of layer *| ** double mass) |* specific mass of layer *| ** ** DESCRIPTION ** This routine calculates the cold content f...
C
#include <arpa/inet.h> #include <poll.h> #include <netinet/in.h> #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <unistd.h> #include <string.h> #include "lib.h" struct sockaddr_in addr_local, addr_remote; int s; struct pollfd fds[1]; void set_local_port(int port) { mem...
C
#ifndef _PACKET_H_ #define _PACKET_H_ #include <stdint.h> #include <arpa/inet.h> /* struct _packet should be packed */ struct __attribute__((__packed__)) _packet { uint32_t type; /* packet type - to identify the type of data being sent within the body */ uint16_t src_id; /* sender’s id in network order */ uint...
C
#include <corelib/fmt.h> #include "caldate.h" #include "caltime.h" unsigned int caltime_fmt(char *str, const struct caltime *ct) { unsigned int len = 0; unsigned int pos = 0; pos = caldate_fmt(str, &ct->date); len += pos; if (str) str += pos; pos = fmt_str(str, " "); len += pos; if (str) str += pos; ...
C
#include<stdlib.h> #include<stdio.h> #include<string.h> #include "hash.h" #define LEN 8000 int main(int argc, char *argv[]) { if(argc < 2 ) { printf("Usage: ./hash-test <list-of-input-files>\n"); return -1; } int debug; FILE * f[260]; int count = 1; while(count < argc && count < 259) { f[co...
C
#ifndef _SWAYBAR_TRAY_ICON_H #define _SWAYBAR_TRAY_ICON_H #include "list.h" struct icon_theme_subdir { char *name; int size; enum { THRESHOLD, SCALABLE, FIXED } type; int max_size; int min_size; int threshold; }; struct icon_theme { char *name; char *comment; list_t *inherits; // char * list_t *di...
C
/*Non-Canonical Input Processing*/ #include "macros.h" static int STOP=FALSE; static int fd; int recieveMessage(int fd, unsigned char msg) { int part=0; unsigned char rcv_msg; printf("Reading...\n"); while (part!=5) { read(fd,&rcv_msg,1); switch (part) { case 0: if(rcv_msg==FLAG){ ...
C
#include <stdio.h> #include <stdlib.h> typedef struct NO { int key; struct NO *prox; }NO; typedef struct PILHA { NO *topo; }PILHA; void iniciarPilha(PILHA *p){ p -> topo = NULL; } void empilhar(int x, PILHA *p){ NO *novo_no = (NO*) malloc(sizeof(NO)); if(novo_no == NULL){ pr...
C
#include <REG52.H> typedef unsigned char u8; typedef unsigned int u16; //dynamic 8-seg LED display BIT select sbit LSA = P2 ^ 2; sbit LSB = P2 ^ 3; sbit LSC = P2 ^ 4; #define GPIO_SEGCODE P0 //dynamic 8-seg LED display DECODE select GPIO u8 code NsegCode[16] = // '0' '1' '2' '3' '4' '5' '6' '7' '8' ...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <pthread.h> #include <unistd.h> #include <fcntl.h> #include "common.h" #include "runtime.h" DECLARE_THREAD_LOCAL(rx_, uint32_t); DECLARE_THREAD_LOCAL(ry_, uint32_t); DECLARE_THREAD_LOCAL(rz_, uint32_t); DECLARE_THREAD_LOCAL(rc_, uint32_t); void rnd_...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* onset.c :+: :+: :+: ...
C
// Uses POSIX functions to send and receive data from the virtual serial // port of a Pololu Simple Motor Controller. // NOTE: The Simple Motor Controller's Input Mode must be set to Serial/USB. // NOTE: You must change the 'const char * device' line below. #include <fcntl.h> #include <stdio.h> #include <unistd.h> #i...
C
/************************************************************************* > File Name: my_chown.c > Author: > Mail: > Created Time: Tue 21 Jul 2015 03:57:54 PM CST ************************************************************************/ /*此程序需要用root用户来执行*/ #include<stdio.h> #include<sys/types.h> #include<sys/s...
C
#include<stdio.h> // Program untuk konversi satuan suhu dari C, R, F, dan K float suhu,c,r,f,k; char satuan; void dapatkanSuhu(); void cariCelcius(); void cariLainnya(); void printHasil(); int main() { dapatkanSuhu(); cariCelcius(); cariLainnya(); printHasil(); '\r'; } void dapatkanSuhu() { ...
C
// vim: set tabstop=2 shiftwidth=2 textwidth=79 expandtab: // gcc -O2 -g -Wall -Wextra -pedantic -fno-strict-aliasing // assets/code/lisp/compiling-if.c // In general: https://course.ccs.neu.edu/cs4410sp20/#%28part._lectures%29 // https://course.ccs.neu.edu/cs4410sp20/lec_let-and-stack_notes.html#%28part._let._.Grow...
C
/*Replace all occurrences of string AB with C without using extra space*/ #include <stdio.h> #include <stdlib.h> void patterntranslate(char* str) { int i,j; if(str[0] == '\0') {return;} for(i=1; str[i] != '\0'; i++) { if(str[i-1] == 'A' && str[i] == 'B') { str[i-1] = 'C'; for(j=i; str[j] != '\0'; j...
C
#include<stdio.h> #include<string.h> #include<stdlib.h> void replacetab() { char ch; printf("opening filename.txt file\n"); FILE* fp=NULL; FILE* fp2=NULL; fp = fopen("filename.txt", "r"); fp2= fopen("newfile.txt","w"); // If file opened successfully, then write the string to file if (fp && fp2) { printf("...
C
#include <sys/stat.h> #include <fcntl.h> #include "../include/tlpi_hdr.h" #ifndef BUF_SIZE #define BUF_SIZE 1024 #endif int main(int argc , char *argv[]) { int inputFd , outputFd , openFlags; mode_t filePerms; ssize_t numRead; char buf[BUF_SIZE]; if(argc != 3 || strcmp(argv[1] , "--help") == 0) ...
C
// // Created by wyz on 16-6-21. // #include "header.h" static char *lineRead = NULL; //终端输入字符串 static char *stripLine = NULL; //剔除前端空格的输入字符串 static char *cmd[10000]; static int cmdNum; static char shell_prompt[1024]; static char *StripWhite(char *pszOrig) { if(NULL == pszOrig) return "NUL"; ...
C
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <semaphore.h> #include <unistd.h> #include <assert.h> typedef int buffer_item; #define BUFFER_SIZE 10 #define RAND_DIVISOR 1000000 #define TRUE 1 pthread_mutex_t mutex; sem_t full, empty; buffer_item buffer[BUFFER_SIZE]; int counter; pthread_t ...
C
#include "Queue.h" #include "Queue_r.h" #include "Class.h" #include "Object.h" #include "LinkList.h" #include "LinkList_r.h" #include <stdarg.h> #include <assert.h> void * enqueue(void * _self, void * _element) { struct QueueClass * class = classOf(_self); assert(class); return class->enqueue(_self, _element)...
C
// // Created by me_touch on 20-11-11. // #include <stdio.h> #include <stdlib.h> #include <stdbool.h> /** * 给定两个二叉树,编写一个函数来检验它们是否相同。 如果两个树在结构上相同,并且节点具有相同的值,则认为它们是相同的。 示例 1: 输入: 1 1 / \ / \ 2 3 2 3 [1,2,3], [1,2,3] 输出: true 示例 2: ...
C
#include <stdio.h> #include <stdlib.h> #define MAX_SIZE 50 #define MALLOC(p, s) \ if(!((p) = malloc(s))) {\ fprintf(stderr, "Insufficient memory");\ exit(EXIT_FAILURE);\ } #define SWAP(x, y, t) ((t) = (x), (x) = (y), (y) = (t)) #define COMPARE(x, y) (((x) > (y)) ? (1) : ((x) == (y)) ? (0) : (-1)...
C
/* * ===================================================================================== * * Filename: employee.h * * Description: * * Version: 1.0 * Created: 03/12/2019 10:09:05 AM * Revision: none * Compiler: gcc * * Author: Brenton Ray (), brentonray@m...
C
/** * Informacja o pliku * a) Zapoznaj się z programem fileinfo.c z pliku lab3.tar.gz. Uzupełnij program o podawanie nazwy pliku i wszystkich czasów związanych z plikiem. * b) Zmodyfikuj program tak, aby informacja podawana była w bardziej przyjazny sposób: * File Name: * File Type: (np. zwykły, katalog, ......
C
#include "sock.h" #include <signal.h> #include <sys/wait.h> void sig_child_handler(int signo){ if(SIGCHLD == signo){ waitpid(-1,NULL,WNOHANG); } } void client_data_handle(void*fd){ // #define SERV_RESP_STR "Server" int newfd = *(int*)fd; printf("Handler process : newfd = %d\n",newfd); int ret = -1; char resp...
C
#ifndef _SEMAPHORE_H #define _SEMAPHORE_H #include <stdint.h> #include <sys/types.h> /* * sem_t - Semaphore type * * A semaphore is a way to control access to a common resource by multiple * threads. Such resource has an internal count, meaning that it can only be * shared a certain number of times. When a threa...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> #include <sys/types.h> #include <sys/mman.h> #include <math.h> #include "bmp.h" /** * 初始化lcd设备 * @Author yHuan * @Date 2019-11-26 * @param device 设备名 * @param x_size...
C
/*--------------------------------------*/ /* */ /* Mizar - Winboard Chess Engine */ /* */ /* 2006 (c) Nicola Rizzuti - Italy */ /* */ /*--------------------------------------*/ #include <mizar.h>...
C
int removeElement(int* nums, int numsSize, int val) { int i = -1; for(int j = 0; j < numsSize; ++j) { if(val != nums[j]) { ++i; nums[i] = nums[j]; } } return i + 1; }
C
#include <stdio.h> #include <sys/time.h> #define NTESTS 102400 #if defined(WINDOWS) #include <Windows.h> // From github.com/open-quantum-safe/liboqs // (under MIT License) int gettimeofday(struct timeval *tp, struct timezone *tzp) { // Note: some broken versions only have 8 trailing zero's, the correct epoch //...
C
/* ******************************************************************************* \file cmd_main.c \brief Command-line interface to Bee2: main \project bee2/cmd \created 2022.06.07 \version 2023.06.08 \copyright The Bee2 authors \license Licensed under the Apache License, Version 2.0 (see LICENSE.txt). ***************...
C
#include <stdio.h> typedef struct { int cod; char depto, nome[30]; float sal; } tabela; int main() { FILE *fp, *fp2; int i = 0, cont; tabela funcionario; char str[] = "funcionarios.bin", str2[] = "funcionariosatualizado.bin", resposta; fp = fopen(str, "r+b"); fp2 = fopen(str2, "wb"); while(fre...
C
/************************************************************************ * * copyright(c)2012-20xx Newland Co. Ltd. All rights reserved * module : appģ * file name : * Author : * version : * DATE : * directory : * description : NDK_AppStartChildProcessƵӦ,ʹúNDK_AppGetDatafromParentProcess,NDK_AppCh...
C
#include <stdio.h> int main(){ char word[51]; char swap; int i=0,j=0,n=0; int counter=0; int x=0, y=0; scanf("%s", word); while(word[n] != '\0') n++; for(j=0;j<n;j++){ for(i=0;i<n;i++){ if(word[i]>word[i+1]){ swap = word[i]; word[i] = word[i+1]; word[i+1] = swap; } } } i...
C
#include<stdio.h> #include<string.h> int main() { int i=1,a,fact=1; printf(" Enter the number"); scanf(" %d",&a); while(i<=a) { fact=fact*i; i++; } printf("%d ",fact); return 0; }
C
#include <stdio.h> void print_array(int rows, int cols, int dest[][cols]) { for(int i = 0; i < rows; i++){ for(int j = 0; j < cols;j++){ printf("%d ", dest[i][j]); } printf("\n"); } } void transpose_matrix (int rows, int cols, int src[][cols], int dest[][rows]){ ...
C
#include "channels.h" #include "io.h" #include "elevDriver.h" #include "orderManager.h" #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <pthread.h> static const int lampMatrix[N_FLOORS][N_BUTTONS] = { {LIGHT_UP1, LIGHT_DOWN1, LIGHT_COMMAND1}, {LIGHT_UP2, LIGHT_DOWN2, LIGHT_COMMAND2}, {LIGHT_UP3...
C
/** \file server/client.c * Define all the client data and actions. */ /* This file is part of LCDd, the lcdproc server. * * This file is released under the GNU General Public License. * Refer to the COPYING file distributed with this package. * * Copyright (c) 1999, William Ferrell, Selene Scriven * ...
C
#ifndef METRICS_H #define METRICS_H #include <stdint.h> #include "counter.h" #include "timer.h" #include "hashmap.h" typedef enum { UNKNOWN, KEY_VAL, COUNTER, TIMER } metric_type; typedef struct key_val { char *name; double val; struct key_val *next; } key_val; typedef struct { hashma...
C
#include <stdio.h> #include <stdlib.h> /*6. Dichiarare un vettore A ed inizializzarlo in maniera casuale. Trovare lelemento tra quelli presenti pi vicino ad un numero inserito dall'utente */ #include <time.h> #include <math.h> #define N 10 #define MIN 1 #define MAX 100 int main() { int array[N]; int i,...
C
#include <stdio.h> int num_of_proc; void FCFS(int arrival_time[], int burst_time[]){ int waiting_time[num_of_proc], turn_around_time[num_of_proc], buff[num_of_proc]; int total_waiting = 0, total_TAT = 0; buff[0] = 0; waiting_time[0] = 0; for(int i = 1; i < num_of_proc; i++){ buff[i] = buff[...
C
#include <stdio.h> int isdigit(char c) { return (c >= '0' && c <= '9'); } int islower(char c) { return (c >= 'a' && c <= 'z'); } int isupper(char c) { return (c >= 'A' && c <= 'Z'); } void expand(char s1[], char s2[]) { int i, j, k; for (i = 0, j = 0; s1[i] != '\0'; ++i) { if (s1[i + 1] == '-' && s1[i + 2]...
C
#include <stdio.h> #include <string.h> #include <time.h> /* 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? */ int main() { clock_t tStart, tEnd; double...
C
#include<stdio.h> #include<conio.h> #define size 5 void readarraya(int a[],int ); void readarrayb(int b[],int ); void addarray(int a[],int b[],int add[], int ); void subarray(int a[], int b[], int sub[], int ); void printarrayadd(int add[], int ); void printarraysub(int sub[], int ); int main() { int i,n; ...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include "lists.h" /** *add_node_end - adds a new node at the end of a list_t list. *@str: string to add in new nodo *@head: data in list_t. *Return: return a pointer to new nodo. */ list_t *add_node_end(list_t **head, const char *str) { list_t *nodo; li...
C
/*4.3.3Դ*/ #include <graphics.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> #include <dos.h> #define N 20/*ԹĴСɸı*/ int oldmap[N][N];/*ݹõ,ȫֱԼʱ*/ int yes=0;/*yesжǷҵ·ı־,1ҵ0ûҵ*/ int way[100][2],wayn=0;/*wayʾ·õ,waynͳ˼*/ void Init(void);/*ͼγʼ*/ void Close(void);/*ͼιر*/ void DrawPeople(int *x,int...
C
#include <stdio.h> void main () { int a, b, c, g; printf ("Enter three numbers: "); scanf ("%d %d %d", &a, &b, &c); if (a > b) g = a; else g = b; if (g < c) g = c; else g = g; printf ("The greatest no: is %d", g); }
C
#ifndef __GPIO_RW_H__ #define __GPIO_RW_H__ #define GPIO_IN 0 #define GPIO_OUT 1 #define GPIO_LOW 0 #define GPIO_HIGH 1 #define BUFFER_MAX 3 #define VALUE_MAX 30 #define DIRECTION_MAX 35 /** * @brief: export a GPIO port * * @param[in] pin bcm number of the pin * * @returns \-1 failded or \0 successful */ in...
C
#include <unistd.h> static void mx_printchar(char c) { write(1, &c, 1); } static void mx_printstr(const char *s) { int j = 0; char i = s[0]; while(i != '\0') { j++; i = s[j]; } write(1, s, j); } int main(int argc, char *argv[]) { if(argc > 1) { int i; ...
C
#include <stdio.h> #include <sys/syscall.h> #include <linux/unistd.h> #define __NR_os_syscall_32 349 //For 32 bit systems #define __NR_os_syscall_64 312 //For 64 bit systems int main(int argc, char *argv()) { long int a = syscall(__NR_os_syscall_64, 2013); //syscall calls the function os_syscall() and passes 2013 as...
C
/* A program using functions to display Hello */ #include<stdio.h> void display(); /* FUNCTION DECLERATION OR FUNCTION PROTOTYPE*/ void main() { display(); /* FUNCTION CALL*/ printf("Test\n"); } void display() /* FUNCTION DEFINITION */ { printf("Hello\n"); }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { FILE *fp; char filename[15], ch, hello[5]; int i = 0; printf("Enter the name of the file\n"); scanf("%s", filename); fp = fopen(filename, "r+"); if (fp == NULL) { printf("An error was encountered while accessing file!\n"); return 1; }...
C
#ifndef POKEMON_POKEMON_H_ #define POKEMON_POKEMON_H_ #include <stdbool.h> #include <stdio.h> typedef struct pokemon_t* Pokemon; typedef enum{ POKEMON_OUT_OF_MEMORY, POKEMON_NULL_ARGUMENT, POKEMON_INVALID_ARGUMENT, POKEMON_HP_IS_AT_MAX, POKEMON_SUCCESS }PokemonResult; /* creates a new pokem...
C
#https://www.hackerrank.com/challenges/punctuation-corrector-its/submissions/code/10581163 #include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> #include <sstream> #include <iterator> #include <map> using namespace std; char str[4000010]; vector<string> tokens; in...
C
#include <stdio.h> #include <stdlib.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char *argv[]) { int idade, maior; float contf=0, cont_intervalo=0; float perc_f_intervalo=0; char sexo; //quantidade de caracteres (char) ...
C
/* COSC242 Assignment * Group 15 * 2017 *flexarray.h */ #ifndef FLEXARRAY_H_ #define FLEXARRAY_H_ /* The flexarray holds an array of strings, and when full will double in size in * order to accomodate for dynamic addition of strings. flexarray_append is for * appending strings to the array, flexarray_free is fo...
C
#include <stdio.h> #define DIVISION_BY_ZERO 1 // Программа которая вычисляет остаток от // деления и результат целочисленного деления // Функция которая высичляет результат целочисленного деления числа a на b void division(int a, int b,int *zel_del,int *ost_del) { *zel_del = 0; while(a>=b) ...
C
#include "test_util.h" static void test_concat(void **state) { char *s1 = malloc(sizeof(char)); strcpy(s1, "abcdefg"); char *s2 = malloc(sizeof(char)); strcpy(s2, "hijklmn"); assert_true(strcmp(concat(s1,s2),"abcdefghijklmn") == 0); } static void test_get_StringFromSysFile(void **state) { c...
C
//Name: Kevin Hom //Date: 4/22/19 //Title: Lab 3 - UDP client file sending //Description: This program acts as a UDP client and sends data to the server. #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <netdb.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <unist...
C
//C program to read a one dimensional array, //print sum of all elements along with inputted array //elements using Dynamic Memory Allocation #include <stdio.h> #include <stdlib.h> int main() { int *arr; int limit,i; int sum=0; printf("Enter total number of elements: "); scanf("%d",&limit...