language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
/* This file is part of lsf_watchdog. * * (C) 2014 Alexander Haase <alexander.haase@rwth-aachen.de> */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <dirent.h> #include <sys/stat.h> #include "check_scripts.h" #include "config.h" /* script_list_push * * function to add a new filename to sc...
C
/********************************************************************************** ļ: WS2811drive.c : WillJason 汾V1.0 ڣ2016530 עļṩ˻WS2811оƬȫLEDƴĻ ***********************************************************************************/ #include "STC12C5A60S2.h" #include "WS2811drive.h" #include "io_config.h" #i...
C
#include <stdio.h> #include "SRQueue.h" int main(void) { int i; QElemType outelem[2]; SRQueue srq; SRQueuePtr QP = &srq; InitSRQueue(QP); printf("after initialed:\n"); SRQDisplay(srq); printf("\nafter inserted:\n"); for(i=1;i<=4;i++) if(InSRQueue(QP,i)==ERROR) p...
C
#include<stdio.h> #include<stdlib.h> #include"defs.h" void guarda_datos(float datos[]) { FILE *ap_arch; register int n; ap_arch=fopen("seno.dat","w"); if(!ap_arch) { perror("Error al abrir Archivo"); exit(EXIT_FAILURE); } for(n=0;n<MUESTRAS;n++) { fprintf(ap_arch, "%d %f \n",n,datos[n]); } fclose(...
C
/*******************************************************************/ /* TX-1CƬʵʵ */ /* 20078µڶѵκϰ */ /* ߣ */ /* 䣺txmcu@163.com */ /* վwww.txmcu.com() */ /*ȨCopyright(C) www.txmcu.com All Rights Reserved */ /*˳ѧϰοעȨϢ */ /* ...
C
#include <stdio.h> #include <stdlib.h> #include <limits.h> #include <opencv2/imgproc/imgproc_c.h> #include <opencv2/highgui/highgui_c.h> static void print_usage(char **argv) { printf("Usage: %s <path> [outfile]\n", argv[0]); exit(1); } static IplImage* resize(IplImage *img, CvSize sz) { IplImage *ret = c...
C
#include "holberton.h" /** * putstring - prints a string * @str: pointer to string to print * @c: count the string size * @i: moves the main string counter one position */ int f_s(va_list arg_string) { int a, contador_fs = 0; char *string; string = va_arg(arg_string, char *); for (a = 0; string[a]; a++) { ...
C
#include "helpers.h" #include<math.h> #include<stdlib.h> #include<stdio.h> int i,j,avg; RGBTRIPLE tmp; // Convert image to grayscale void grayscale(int height, int width, RGBTRIPLE image[height][width]) { for(i=0;i<height;i++){ for(j=0;j<width;j++){ avg=((image[i][j].rgbtBlue+image[i][j].rgbtRed...
C
#include<stdio.h> #include<stdlib.h> #define MAX_QUEUE_SIZE 20 typedef int element; typedef struct { //ť Ÿ element data[MAX_QUEUE_SIZE]; int front, rear; } DequeType; //Լ; void error (char *message){ fprintf(stderr, "%s\n", message); exit(1); } //ʱȭ; void init_deque(DequeType *q){ q->front = q->rear = 0; } /...
C
#include "qdbmp.h" #include <stdio.h> #include <math.h> int main(void) { BMP* bmp; UCHAR r,r1,r2,r3,r4,r5,r6,r7,r8,r9,g,g1,g2,g3,g4,g5,g6,g7,g8,g9,b,b1,b2,b3,b4,b5,b6,b7,b8,b9; UINT width, height; UINT x, y; bmp = BMP_ReadFile( "/home/argo/Desktop/For-PenzGTU/S-E-M-E-S-T-R-O-V-I-E/semes...
C
#include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <stdio.h> #include <linux/types.h> #include <fcntl.h> #include <unistd.h> #include <stdlib.h> #include <sys/types.h> #include <sys/ioctl.h> #include <errno.h> #include <assert.h> #include <strin...
C
#include <stdio.h> #include <stdlib.h> #include "darray_int.h" static void swap(int *, int *); struct darray{ int _index; int _capacity; int _initial_capacity; int *_arrNum; }; AdtStatus darrayCreate(darray **dArr, size_t initial_capacity) { *dArr=malloc(sizeof(darray)); if(dArr==NULL) ...
C
#include "head.h" //buf1为绝对路径,buf2为带有..的路径 //拼接结果为绝对路径 int path_dot(char* buf1,char* buf2) { int i,j; if('.'==buf2[0] && '.'==buf2[1] && '/'==buf2[2]) { for(i=0;i<100;i++) { if('\0'==buf1[i]) { break; } } for(;i>0;i--) { if('/'==buf1[i]) { break; } buf1[i]='\0'; } for(j=...
C
#include <stdlib.h> #include <stdio.h> #include "mpi.h" #include <math.h> int main(int argc, char *argv[]) { int rank, x = 2; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); int ans = pow(x,rank); printf("%d ^ %d = %d\n", x, rank, ans); MPI_Finalize(); return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <math.h> DblyList insertBeg(DblyList list, int x) { DblyNode * t = (DblyNode*)malloc(sizeof(DblyNode)); t->prev = NULL; t->data = x; if(list.start == NULL) { t->next = NULL; list.start = list.end = t; } else { t->next = list.start; list.start->p...
C
#include "holberton.h" /** * _isdigit - Checks if a character is a digit * @c: the character to be tested * * Return: 1 if `c` is a digit, 0 if not */ int _isdigit(int c) { int check; for (check = '0'; check <= '9'; check++) { if (c == check) return (1); } return (0); }
C
#include <unistd.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <termios.h> int main(int argc, char** argv) { int pid; printf("trois.......deux.....un..\n"); fflush(stdout); if((pid = fork()) == -1) { perror("Fork Failed\n"); exit(43); } if(pid == 0) { printf("partez\n"); } }
C
void toAnotherNumberSystem(int decimalNumber, int numberSystem) { int anotherSystemNumber, indicator = 1; while (indicator <= decimalNumber) { indicator *= numberSystem; } indicator /= numberSystem; while (indicator != 0) { anotherSystemNumber = decimalNumber / indicator; ...
C
#include<stdio.h> int main() { int a,b,sum; a=10; b=39; sum=a+b; printf("sum is %d",sum); return 0; getchar(); }
C
#include <stdio.h> void main(){ int n, b; printf("Dimmi un numero e una base: "); scanf("%d%d", &n, &b); printf("Leggere al contrario: "); while (n > 0){ printf("%d", n%b); n = n / b; } printf("\n"); }
C
#include <strings.h> #include "..\..\Comm\CommDef.h" #define STACK_INIT_SIZE 100 //洢ռʼ #define STACKINCREMENT 10 //洢ռ typedef struct { _Bool Forward, Down, Backward, Up; } Way; typedef struct { short i; //ͨԹеλX,Y short j; Way w; //Ӵͨһͨķ } MoveMazeElemType; typedef struct { MoveMazeElemType *base; //ջ֮ǰ֮base...
C
#ifndef MATRIX_H #define MATRIX_H #include <stdio.h> #define N 5 #define M 5 typedef struct { int rows; int cols; int **data; } Matrix; void print_matrix(int (* arr)[N], size_t); void print_row(int (* arr)[N], size_t, size_t); void print_column(int (* arr)[N], size_t); void create_identity_matrix(int (...
C
#include <hshell.h> #include "utils/hlib.h" #include <unistd.h> #include <sys/types.h> #include <pwd.h> /** * util_get_user - Retrieve the user's name * * Return: User name */ const char *util_get_user(void) { const char *user = NULL; struct passwd *pws; pws = getpwuid(geteuid()); if (pws) { user = pws->p...
C
/* ** 2249a - read out the 12 pedestals of a LeCroy LRS2249A ADC after ** generating a test pulse with the test module function. ** Uses Q-Stop or single word readout mode. ** ** 11may99 das ** 23may02 das removed unused variables sec, status; added stdlib.h include ** for exit ** *...
C
#include <stdio.h> #include <stdlib.h> #include "ml6.h" #include "display.h" #include "draw.h" #include "matrix.h" /*======== void add_point() ========== Inputs: struct matrix * points int x int y int z Returns: adds point (x, y, z) to points and increment points.lastcol if points is fu...
C
#include "type.h" BDType *bd_type(BDTypeKind kind) { BDType *t = malloc(sizeof(BDType)); t->kind = kind; return t; } void bd_type_destroy(BDType *t) { return; if(t == NULL){ return; } switch(t->kind){ case T_UNIT: case T_BOOL: case T_CHAR: case T_I...
C
/* * @Author: Pratyush Kar (2013A7PS029P), * Ayush Kataria (2013A7PS028P) * @Email: f2013029@pilani.bits-pilani.ac.in, * f2013028@pilani.bits-pilani.ac.in * @Gp Number: 52 * @File Name: lexer.c * @Date: 2016-02-18 12:26:23 */ //#include "lexer.h" #include <stdio.h> #include <stdlib....
C
/* RHS-type of assignment not compatible with LHS-type */ int x[10], y, z; int foo(void) { x[1] = "abcde"; return y; }
C
#define NULL ((void*)0) typedef unsigned long size_t; // Customize by platform. typedef long intptr_t; typedef unsigned long uintptr_t; typedef long scalar_t__; // Either arithmetic or pointer type. /* By default, we understand bool (as a convenience). */ typedef int bool; #define false 0 #define true 1 /* Forward d...
C
#include "header.h" int redirect(char *token, int *job_pid, char **job_name) { int r = 0, is_inp = 0, is_out = 0, is_app = 0; char* input[20]={NULL}; int size=0,status,i,flag = 0; token = strtok(token," \t\n"); while(token!=NULL){ input[size++]=token; token = strtok(NULL, " \n\t"); } // if(strcmp(input[size...
C
/***************************************************************** Titulo: arbol.c Descripcion: Contiene la definicion de las funciones declaradas en el archivo arbol.h. Fecha: 11-sep-17 Versión: 2.0 Autor: Los chilakillers *****************************************************************/ #include "arbol.h" // Recibe...
C
#include<stdio.h> void Check1 () { union check { int a; char b; }test; test.a = 1; if ( test.b ) { printf ("是小端字节序\n"); return ; } printf ("是大端字节序\n"); return; } void Check () { int a = 1; if ( *((char*)&a) ) { printf ("是小端字节序\n"); return; } printf ("是大端字节序\n"); r...
C
/**********************************************************************\ * Copyright (C) Michael Kerrisk, 2010. * * * * This program is free software. You may use, modify, and redistribute * * it under the terms of the ...
C
#include <stdio.h> #include <stdlib.h> void categNadador(); void main(){ int idade, i; char* ctg = (char*) malloc(sizeof(char)*10); printf("Digite a Idade: "); scanf("%d", &idade); categNadador(idade, ctg); for(i=0 ;i < 10; i++){ printf("%c", ctg[i]); if(i == 9) printf(...
C
#include <stdio.h> #include <cs50.h> #include <string.h> // Library to deal with string int main() { string name = get_string("enter your name: "); // name inputed by user long n = strlen(name); // strlen() is function in <string.h> for know length of string for (int i = 0; i < n; i++) // for loop { ...
C
// Cambio optimo de monedas #include <stdio.h> #define LIM 8 int monedas[LIM]={500, 200, 100, 50, 52,10, 5, 1}; main(){ int num, cantidad,numonedas; printf("Introduzca el importe exacto:"); scanf("%d", &cantidad); printf("El cambio optimo es el siguiente: \n"); for (num=0; num< LIM; num++){ numonedas=cantida...
C
#include <stdio.h> int c, cAnterior; enum caracteres { APOSTROFE = 39, COMILLAS = 34, LF = 10, CONTRABARRA=92 }; void codigoSinComentarios(void); void barra1(void); void barra2(void); void cadena(void); void escapeCadena(void); void asterisco(void); void asteriscosPalabras(void); void caracter(void...
C
#include "sort.h" /** *counting_sort - sorts an array using counting sort algorithm *@array:array to sort *@size:size of array */ void counting_sort(int *array, size_t size) { int *output, *count, i, max; if (array == NULL || size < 2) return; output = malloc(sizeof(int) * size); if (output == NULL) return...
C
#pragma once #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> #include "bintree.h" #define DataType char #define QueueDataType BinTreeNode* typedef struct SeqCyQueue { QueueDataType* base; size_t capacity; int front; int tail; }SeqCyQueue; void SeqCyQueueInit(SeqCyQueue* Q); voi...
C
/**************************************************************** * @file main.c * * @author Nikolaos <batsaras@csd.uoc.gr> * * * * @brief Header function for the needs of cs-240b proje...
C
/* * Find the largest base^exponent value of all base,exponent pairs read from stdin * The stdin format should be one comma-separated pair per line * The program prints out the line number containing the largest value */ #include <stdio.h> #include <math.h> int main (void) { int base = 0; int exponent = 0; int...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <openssl/md5.h> const char *string = "The quick brown fox jumped over the lazy dog's back"; const char *characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*():;"; int main() { int i; int *chars[8]; char password[...
C
#include<stdio.h> #include<string.h> int main() { char str1[15] = "pratham"; printf("length of string is %d",strlen(str1)); return 0 ; }
C
#include <stdio.h> #include <stdlib.h> void main() { float monto; float mu=0 ; float mp=0 ; float mt=0; printf ("Ingresar presupuesto anual:$"); scanf ("%f",&monto); printf("Presupuesto anual de Urgencias:$%f \nPresupuesto anual de Traumatologia:$%f \nPresupúesto anual de Pediatria:...
C
// // Created by alexwang on 4/20/16. // #include "sphere.h" #include <memory.h> #include <stdio.h> #include <math.h> #include "object.h" #include "algebra.h" int sphere_intersection(const Object *object, const Ray *ray, Ray *reflect, Vector *inter, Vector *n) { Sphere *sphere = (Sphere*) object->priv; // ray....
C
void push(int data) { struct mystack *temp; temp=(struct mystack *)malloc(sizeof(struct mystack)); if(temp==NULL) printf("Out of space\n"); temp->sol=data; temp->next=top; top=temp; } void ansstack(){ sol1 = fopen("sol1.txt","r"); if(sol1 == NULL){ printf("ERROR...C...
C
#include <stdio.h> int main() { int COD1,COD2,QTD1,QTD2; double VALOR1,VALOR2,TOTAL; scanf("%d",&COD1); scanf("%d",&QTD1); scanf("%lf",&VALOR1); scanf("%d",&COD2); scanf("%d",&QTD2); scanf("%lf",&VALOR2); TOTAL = (QTD1*VALOR1)+(QTD2*VALOR2); printf("VALOR A...
C
#include"pipe.h" struct Block* init(struct Request* req){ if(req==NULL) return NULL; struct BasicResponse* br = NULL; struct AdditionalResponse* ar =NULL; struct Block* rst = NULL; rst = (struct Block*)malloc(sizeof(struct Block)); memset(rst,0,sizeof(struct Block)); rst->respons...
C
#include <stdio.h> int fun(int); void main(void) { int n,r; printf("\nEnter the value of n:"); scanf("%d",&n); r=fun(n); printf("\nFactorial %d is : %d",n,r); } int fun(int a) { int i,fact=1; for(i=1;i<=a;i++) fact=fact*i; return(fact); }
C
/* * Collaborators: * Deepak */ struct symrec { char *name; /* name of symbol */ int addr; /* location of top of variable in memory */ char *type; char *code; struct symrec *next; /* link field */ }; typedef struct symrec symrec; struct nody { char *code; char *addr_code; char *find_value; int is...
C
#include <stdio.h> #include <stdlib.h> typedef enum espectral_t { O,B,A,F,G,K,M }clase; clase tipo_espectro (int temperatura); int main (void){ char t [10]; int temperatura; printf("Introduzca una temperatura estelar entre 1700-50000 kelvins:\n"); temperatura=atoi(fgets(t,10,stdin)); switch(tipo_espectro(temp...
C
#define _BSD_SOURCE #define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <unistd.h> #include <assert.h> #include <sys/wait.h> #include <sys/types.h> #include <sys/stat.h> #include <dirent.h> #include <fcntl.h> #include "mftp.h" /* This is the client side to a mi...
C
#include <stdio.h> #include <math.h> #include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> #include <gsl/gsl_sf.h> #include <time.h> #include <unistd.h> #define ALLOC(p,n) (p)=malloc( (n) * sizeof(*(p))); if( (p) == NULL){printf("Allocation of '%s' failed. Terminate. \n", #p); exit(2); } #define CALLOC(p,n) (p)=cal...
C
/****************** Modify this file at specified place ***********************/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "hw12.h" /****************** DO NOT Modify this file above this line *******************/ #ifdef TEST_MAIN int main(int argc, char **argv) { // If argc != 4 then retur...
C
#include <stdio.h> #include <stdlib.h> ///Nama : Tri Waluyo ///Nim : A11.2017.10097 ///Kelas: 4103 int main() { int angka1; /// variabel angka1 tipe data int int angka2; /// variabel angka2 tipe data int for(angka1=1;angka1<=7;angka1+=1) ///looping variabel angka1 dari 1 sampai batas kurang dari sama d...
C
#include<stdio.h> int main() { freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); int h,m,t; char ara[6]; scanf("%d",&t); while(t--) { scanf("%s",ara); h=(ara[0]-'0')*10+ara[1]-'0'; m=(ara[3]-'0')*10+ara[4]-'0'; if(m!=0) {h=12-h-1;if(h<=0)h+=12; ...
C
#include <stdio.h> #define _CRT_SECURE_NO_WARNINGS float Fact2 (int N) { int d=1; for (;N>0;N=N-2) d=d*N; return d; } int main(void) { int i,N; for (i=1; i<=2;i++) //выполнить функцию два раза для чёт и нечёт значения N { printf ("N= "); scanf ("%d", &N); printf("двойной факториал...
C
/* Exit code Main 0 Init 1 Sockets, bind, accept, listen 2 recicieve/sendto 3 Write/read 4 fork 5 */ //fd socket udp si, fd1 socket udp client, fd2 socket tcp s.m. #include...
C
/* * File name:StackByArray.c * Description: ʵջ * Author: yzwall * Data: 2016/9/1 14:46 */ #include <stdio.h> #include <stdlib.h> #define MIN_STACK_SIZE 3 #define EMPTY_TOP -1 //////////////////////////////////////////////////// typedef int ElementType; // һȷջᱻ̬ȷ typedef struct Stack { int capacity; // ջ int t...
C
/* file velocity_calc.c */ // c code for velocity_calc subroutines #include <math.h> #include "velocity_calc.h" void velocity_calc(int nAtoms, int iter, int deltaWrite, double Ar_m, double Ar_mmass, double delta_t, double kB, double *int_temp, double *Tot_kinetic_en, double **atomVelocities, double **atomForces, doub...
C
#include <stddef.h> #include <unistd.h> /* This is a bogus implementation of UNIX descriptor tables, which describe to the system what resources a process has open. In order for dup() and friends to operate normally, we need a descriptor table to map resource IDs to system handles. These functions handle that mapping...
C
#include "core.h" #include "main_menu.h" int main_menu(int number_of_items, char *choices[]){ int item_i, ch, value; WINDOW *main_menu_win; MENU *menu; ITEM *current; ITEM **items = (ITEM**) malloc(sizeof(**items) * number_of_items); if(items == NULL){ perror("Error on allocation of main menu items"); exit(...
C
#include<stdio.h> #include<math.h> int main() { double r,n; while(1) { double ans; scanf("%lf %lf",&r,&n); if(r==0 && n==0) break; ans=r/sin(acos(-1)*0.5/n); printf("%.2lf\n",ans); } return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define input "00101000101111010" #define disc_size 35651584 void dragonize(char *str) { int i,l=strlen(str); char *temp=malloc(disc_size); char buf; strcpy(temp, str); for(i=0;i<l-i;i++) { buf=temp[i]; temp[i]=abs((temp...
C
#include "bst.h" #define downcast(p, type, member) ((p) ? ((type *)(((char *)(p)) - offsetof(type, member))) : NULL) typedef struct bst_avl_node bst_avl_node_t; struct bst_avl_node { bst_node_t node; int height; /**< used to keep avl tree balanced in O(log(n)) operations */ }; #define bst_max(a, b) ((a) ...
C
#include <avr/io.h> #include <avr/interrupt.h> #include <util/delay.h> #include <stdio.h> #include <string.h> #define RESET 1 #define OP_SIZE 2 #define STOP 3 #define SHOT 4 #define CALL_SIZE 5 #define CALL_IMG 6 static int Putchar(char c, FILE *stream); static int Getchar(FILE *stream); unsigned buff[9]; int cn...
C
#include <stdio.h> #include <stdlib.h> //c 有分区,四区模型,栈,堆 // 栈 : 占用内存空间最大值为2M ,开辟内存的方式为静态内存开辟 int arr[10*1024*1024] ,方法结束会自动回收 // 堆 : 占用内存空间最大值 80% , 开辟内存的方式时动态开辟内存 ,不会自动回收,必须手动回收 (内存不再使用的时候一定要手动回收) //1. 静态内存开辟 /* void staticlloc() { int arr[5]; int i = 0; for (; i < 5; i++) { arr[i] = i*2; ...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #define MAXCOUNT 45 struct students{ int fstdID; char name [50]; int yearofbirth; float gpa; }; struct stack_s{ int count; struct students data[MAXCOUNT]; }; void init_stack(struct stack_s *s); int give_count(struct stack_s *s); struct...
C
#include "bsp.h" BOOL TimerB_1S_Flag=FALSE; BOOL TimerB_125mS_Flag=FALSE; /* TAģ飬CCR0PWMֻģʽá ǵ͵ƽģʽΪߵƽģʽ 1.ʼʱMode=P 2.TimerA_PwmStartStop,ֹͣʱΪ͵ƽ */ BOOL TimerA_PwmInit(char Clk,char Div,char Mode) { TACTL = 0; //ǰ TACTL |= MC_1; //ʱ TA Ϊģʽ switch(Clk) //ѡʱԴ { case'A': case'a': TACTL|=TASSEL_1; break; //ACLK...
C
/* * spi.c * * Created on: 24-Jan-2009 * Author: Neil MacMillan * * Functions for using the AT90 as an SPI master. */ #include "spi.h" #include <avr/io.h> #include <avr/interrupt.h> #define SPI_DDR DDRB // DDR of SPI port #define SPI_PORT PORTB // SPI port #define SPI_MOSI PORTB2 // MOS...
C
// A very simple UDP client that reads a line of user input // and sends it (message) to a UDP server. The client then // waits for the server to acknowledge the receipt of the // message and terminates. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sy...
C
#include <lcom/lcf.h> #include <stdint.h> #include <../headers/timer.h> static int hook_id; uint32_t timer_counter = 0; int (timer_set_frequency)(uint8_t timer, uint32_t freq) { uint8_t st, lsb, msb; uint16_t auxFreq = TIMER_FREQ/freq; timer_get_conf(timer, &st); //coloca em st a configuração do timer st ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <arpa/inet.h> #include <sys/socket.h> #include <netinet/in.h> #define PORT 9999 #define BUFFER_SIZE 1024 int main(int argc,char const *argv[]) { int sd; struct sockaddr_in addr; int port = atoi(argv[1]); printf("port is %...
C
#include <stdio.h> #include <string.h> #include <ctype.h> int main() { int testCase, i = 0; char a[10001]; scanf("%d", &testCase); while (testCase--) { int count = 0; scanf(" %[^\n]", a); for (i = 0; i < strlen(a); i++) { if (a[i] == ' ') { ...
C
#include <unistd.h> /*Included for dup(2) and write(2)*/ #include <stdlib.h> /*Included for exit(3)*/ #define MESSAGE "Hey! Who redirected me?\r\n\0" int main() { int newfd = dup(STDIN_FILENO); /* tutto quello che si fa su newfd avra' effetto su stdout */ char buff[] = MESSAGE; if (newfd < 0) { /* a...
C
#include "normal_queue.h" #include "syslog.h" #include "mem_tool.h" status_t normal_queue_init_basic(struct normal_queue *self) { self->head = 0; self->tail = 0; self->data = NULL; self->size = 0; self->is_full = 0; return OK; } status_t normal_queue_init(struct normal_queue *self,int size) { int...
C
#include <stdio.h> float media(int *p_vetor) { int i, *p_i; float soma, *p_soma; p_soma = &soma; p_i = &i; for (*p_i=0;*p_i<30;(*p_i)++) *p_soma += *(p_vetor+*p_i); return (*p_soma)/30; } int main() { int vetor[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26...
C
/******************************************************************************* * Program: detect.c * Purpose: This program segments a filtered mammogram into regions. Some of * the regions may be selected as being abnormal. Any such region will be written * out in a "detection" file. The segmentation of the file ...
C
/* * Copyright (c) 2019 Guillaume Outters * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, ...
C
#include<stdio.h> #include<unistd.h> #include<signal.h> void handar(int); int main() { int i; signal(SIGINT, handar); for(i=0; i<5; i++) { printf("main(): %d\n", i); sleep(1); } return 0; } void handar(int signum) { printf("handar(): ctrl+c\n"); for(int i=0; i<5; i++) { printf("handar(): %d\n", i); ...
C
#include <avr/io.h> #include <stdbool.h> int main(void) { DDRC=0xFF; // θέτουμε τη θύρα C ως έξοδο DDRA=0x00; // θέτουμε τη θύρα Α ως είσοδο int f0,f1,f2,a,b,c,d,e,inp ; while(1) { inp=PINA; // ανάγνωση εισόδου a=inp&0b00000001 ; // PA0 b=inp&0b00000010 ; // PA1 c=inp&0b00000100 ; // PA2 d=inp&0b00001000 ; // PA3 e=inp...
C
#define NULL ((void*)0) typedef unsigned long size_t; // Customize by platform. typedef long intptr_t; typedef unsigned long uintptr_t; typedef long scalar_t__; // Either arithmetic or pointer type. /* By default, we understand bool (as a convenience). */ typedef int bool; #define false 0 #define true 1 /* Forward d...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char **argv) { int a = 0; char arr_one[8]; char arr_two[8]; char *p = (char *)malloc(100 * sizeof(char)); strcpy(arr_one, "one"); strcpy(arr_two, "two"); printf("a value: %d\n", a); printf("arr address: %p\n", arr_one); printf...
C
/* This function marks the start of the farm */ int start_farm() { return 1; } void setval_220(unsigned *p) { *p = 2425393368U; } unsigned getval_460() { return 3284633672U; } unsigned addval_499(unsigned x) { return x + 3284633928U; } unsigned addval_393(unsigned x) { return x + 3277376466U; } ...
C
#include<stdio.h> int main() { int queue[100],n,head,i,j,k,seek=0,diff; float avg; printf("\tFCFS Disk Scheduling Algorithm\n"); printf("Enter the size of Queue\t"); scanf("%d",&n); printf("Enter the Queue\t"); for(i=1;i<=n;i++) { scanf("%d",&queue[i]); } printf("Enter the initial head position\t"); scanf("%...
C
#include <mpi.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <time.h> // #define PRINT_MATRIX #define MATRIX_SIZE (long int) 5192 int main(int argc, char** argv) { MPI_Init(&argc, &argv); srand(time(NULL)); int myrank, w_size, flag; float etime; struct timespec t_start, t_end; MPI_...
C
#include<stdio.h> int main () { int nisit[5],score[5],max,min,agv,sum=0,i; for(i=0;i<5;i++) { printf("ID : "); scanf("%d",&nisit[i]); printf("Score : "); scanf("%d",&score[i]); if(i==0) { max=min=score[i]; }//if i==1 if(score[i]>max){ max=score[i]; ...
C
#include <stdio.h> #include <stdlib.h> void maopao(int *a,int n){ int i,j,temp; for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) if(a[i]>a[j]) { temp=a[i]; a[i]=a[j]; a[j]=temp; } } } int main() { int i,n=100; int a[100]={0}; for(i=0;i<n;i++) ...
C
#ifndef __HASH_TABLE_H__ #define __HASH_TABLE_H__ #include <stddef.h> unsigned long hash_str(const void *v); int equal_str(const void *v1, const void *v2); typedef struct ht_entry { // key/val const void *key; void *val; // flags int taken; int deleted; } ht_entry_t; typedef struct ht { ht_entry_t *ht...
C
#include "if02shell12.h" /* mengeksekusi external program pada child process itu sendiri Argument: - argv: arguments */ void extprog(char *argv[]) { pid_t pid; /* child process ID */ int stat_loc; /* me-return nilai dari forking child */ FILE *infile...
C
#include <stdio.h> int strncmp(char*, char*, int); int main(){ char s[256] = "Hello!"; char t[256] = "Herring"; if(strncmp(s,t,2)==0){ printf("Good comparison\n"); } return 0; } int strncmp(char* s, char* t, int n){ for(int i = 0; i < n; i++,s++,t++){ if(*s < *t || *s > *...
C
#include <string.h> #include <stdio.h> void numero_vogais(char texto[]){ int a = 0 , e = 0, I = 0, o = 0, u = 0; for(int i=0; i<strlen(texto); i++){ if(texto[i]=='a' || texto[i]=='A'){ a++; } if(texto[i]=='e' || texto[i]=='E'){ e++; } ...
C
#include "dht.h" #include <avr/io.h> #include <stdio.h> #include <util/delay.h> void dht_init(void) { DHT_PIN_OUTPUT(); DHT_PIN_HIGH(); _delay_ms(100); } void dht_reset(void) { DHT_PIN_OUTPUT(); DHT_PIN_LOW(); _delay_ms(100); } int8_t dht_read(int8_t *temperature, int8_t *humidity) { ui...
C
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* * File: utils.h * Author: treys * * Created on 25 de maio de 2020, 06:15 */ #ifndef UTILS_H #define UTILS_H ...
C
#include<stdio.h> #define _CRT_SECURE_NO_WARNNINGS int main() { int i; for (i = 60; i > 0; i--) { printf(" %d", i); } printf("lunch!\n"); return 0; }
C
#include <stdio.h> #include <stdlib.h> #ifndef FLT_MAX #define FLT_MAX 3.40282347e+38 #endif #define N_OBJ 5 #define N_ATTR 2 #define K 2 #define N_THREADS 1 /** * multi-dimensional spatial Euclid distance square */ float euclid_dist_2(float *pt1, float *pt2, int numdims) ; ...
C
#include <stdio.h> #include <stdlib.h> #include "utils.h" void pressAnyKeyToContinue() { printf("\n\n\nPressione enter para continuar...\n"); fflush(stdin); getchar(); } int getIntUserInput(char* message) { int value = 0; printf("%s\n", message); scanf("%d", &value); return value; }
C
#include <stdio.h> #include <wiringPi.h> #include <unistd.h> #include <stdint.h> #include <softPwm.h> #define LEFT_MOTOR_FWD 6 #define LEFT_MOTOR_RVRS 13 #define RIGHT_MOTOR_FWD 19 #define RIGHT_MOTOR_RVRS 26 int main(int argc,char*argv[]) { wiringPiSetupGpio(); pinMode(LEFT_MOTOR_FWD, OUTPUT); pinMode(LEFT_MOTO...
C
#include <stdio.h> #include <stdlib.h> #include <stdarg.h> void show_array(const double ar[], int n); double * new_d_array(int n, ...); int main() { double * p1; double * p2; p1 = new_d_array(5, 1.2, 2.3, 3.4, 4.5, 5.6); p2 = new_d_array(4, 100.0, 20.00, 8.08, -1890.0); show_array(p1, 5); show_a...
C
/******************************************************************** * bnt_util.c : Utility functions * * Copyright (c) 2018 TheFrons, Inc. * Copyright (c) 2018 Joon Kim <joon@thefrons.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General ...