language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* parser_tests.c :+: :+: :+: ...
C
/* ** params.h for tetris in /home/raphael.goulmot/rendu/PSU_2016_tetris ** ** Made by Raphaël Goulmot ** Login <raphael.goulmot@epitech.eu> ** ** Started on Thu Mar 2 09:54:34 2017 Raphaël Goulmot ** Last update Sun Mar 19 18:45:40 2017 Raphaël Goulmot */ #include <stdlib.h> #include <stdio.h> #include <getopt.h>...
C
#include <stdio.h> #include <wiringPi.h> #include<unistd.h> #define GPIO 12 //gpio 15 orange pi zero int main() { int speed = 1500; //MINIMO 1000 MAXIMO 2000 wiringPiSetup(); pinMode (GPIO, OUTPUT); //INICIO CONTROLADOR ESC /* Pulsos de 2000us durante 2.5 segundos ...
C
#include <assert.h> #include <errno.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/stat.h> /* int dup2(int oldfd, int newfd); dup2() The dup2() system call performs the same task as dup(), but instead of using the lowest-numbered unused file descri...
C
//*H29年度/dsp2-1/5J06*// #include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #define MAX_SIZE 16384 //#define M_PI 3.14159265359 typedef struct { double re; //実部 double im; //虚部 } complex_t; FILE * openFile(); FILE * openFile_2(); complex_t comp_add(complex_t in1, complex_t in2); compl...
C
#include <stdio.h> #include <stdlib.h> #define BITS_PER_BYTE 8 void dec_to_bin(const unsigned char value) { char i = (BITS_PER_BYTE * sizeof(unsigned char)); char bit; for (i -= 1; i >= 0; i--) { bit = value >> i; if (bit & 1) { printf("1"); } else { printf("0"); } } printf("\n"); } int main(void)...
C
#include "holberton.h" /** *add - two integers *@x: number *@z: number * *Return: return the sum */ int add(int x, int z) { return (x + z); }
C
// // Who to blame: Geoff Chesshire and Bill Henshaw // #include "MappedGrid.h" #include "LineMapping.h" #include "SquareMapping.h" #include "BoxMapping.h" #include "ReparameterizationTransform.h" #include "UnstructuredMapping.h" #include <algorithm> #include "ParallelUtility.h" #include "App.h" #ifdef USE_STL #incl...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_exit.c :+: :+: :+: ...
C
#include "keyboard.h" #include "ports.h" #include "../cpu/isr.h" #include "display.h" #include "../kernel/util.h" void print_letter(uint8_t scancode) { switch (scancode) { case 0x0: print_string("ERROR"); break; case 0x1: print_string("ESC"); break; case 0x2: ...
C
#include <unistd.h> int ft_atoi(char *s) { int i; int sign; int res; sign = 1; i = 0; while (s[i] != 0 && ((s[i] >= 9 && s[i] <= 13) || s[i] == ' ')) i++; if (s[i] == '-') sign = -1; if (s[i] == '-' || s[i] == '+') i++; if (s[i] == 0) return (0); ...
C
#include <stdio.h> #include <inttypes.h> int read_int(); float read_float(); void print_int(int out); void print_float(float out); int read_int() { int ret = 0; printf("Enter an integer: "); scanf("%d", &ret); return ret; } float read_float() { float ret = 0.0f; printf("Enter a floating point number: "); scan...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_itoa_base.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #define SIZE 20 int main() { int number[ SIZE ]; size_t i, a; srand( time( NULL ) ); number[ 0 ] = rand() % 20 + 1; for( i = 1; i < SIZE; i++ ){ a = i; number[ i ] = rand() % 20 + 1; while( a > 0){ if( ...
C
/* ** malloc.h for malloc in /home/pennam_a/Systeme_unix/PSU_2015_malloc ** ** Made by antoine pennamen ** Login <pennam_a@epitech.net> ** ** Started on Wed Jan 27 14:36:05 2016 antoine pennamen ** Last update Sun Feb 14 22:31:26 2016 antoine pennamen */ #ifndef MALLOC_H_ # define MALLOC_H_ # include <unistd.h> # ...
C
// string_maker.c #include "play.h" #include <stdlib.h> char *string_maker (char **board,int size) { char *str ; int i,j ; str=malloc(((size*size)+1)*sizeof(char)); for ( i = 0 ; i < size ; i++ ) { for ( j = 0 ; j < size ; j++ ) { str[i*size+j]=board[i][j] ; // dimiourgise ena string gia kathe kat...
C
#include <stdlib.h> #include <stdio.h> #include "image.h" struct image_struct { int dim; int depth; int *data; }; struct image_struct *image_alloc(int dim, int depth) { int len; struct image_struct *res; len = dim * dim * depth; res = malloc(sizeof(struct image_struct)); res -> dim...
C
/* cs50 2015 Scott Linne pset2 Caesar cipher encrypt a text string by k characters */ #include <cs50.h> #include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> int main(int argc, char* argv[]) { if(argc !=2 || atoi(argv[1]) < 0 ) { printf("Enter a non-negative integer: Usage ./caesar k\n...
C
#include<stdio.h> void fun() { int a[5], int i; for(i = 0; i < 5; i++) printf("%d ",a[i]); } int main() { int a[5],i; for(i = 0; i < 5; i++){ a[i] = i; } fun(); return 0; }
C
#include "ponto.h" int main() { setlocale(LC_ALL, ""); int escolha; char continuidade; printf("O que você quer fazer?\n"); do{ printf("-digite 1 para criar tabela\n-digite 2 para listar tabelas\n-digite 3 para criar nova linha na tabela\n-digite 4 para listar todos os dados de uma tabela\n-digite 5 par...
C
#include <stdio.h> int main(){ double width,length; scanf("%ls",&width); scanf("%lf",&length); double ans1 = width*2; double ans2 = length*2; double ans = ans1+ans2 printf("%f %f", ans1, ans2); //printf("Perimeter of rectangle = %.4f units",ans); return 0; }
C
#include <stdio.h> #include <locale.h> #include <wctype.h> #include <wchar.h> int main() { const wchar_t *orig = L"BAÑO"; wchar_t xfrm[64]; setlocale(LC_ALL, ""); // enable environment locale int i = 0; while (i < wcslen(orig)) { xfrm[i] = towlower(orig[i]); i++; } xf...
C
#include "monty.h" /** * add - function to add the two * @head: header of the file * @line_number: line of the file */ void add(stack_t **head, unsigned int line_number) { stack_t *temp; char *msg = "can't add, stack too short"; if (!head || !*head) { fprintf(stderr, "L%i: %s\n", line_number, msg); free_...
C
struct ColorRGB { unsigned char r; unsigned char g; unsigned char b; }; unsigned char clamp(double a){ if(a >= 255.0){ return 255; } else if(a <= 0.0){ return 0; } return (unsigned char)a; } struct ColorRGB * filterImage(struct ColorRGB pixels[],struct ColorRGB result[],int w, int h, int filterWidth, int...
C
/* * Sample skeleton source file. */ #include <avr/io.h> #include <util/delay.h> #include <stdlib.h> #include "lib/serial/serial.h" int main (void){ serial_init_b(BAUD); uint8_t i = 0; char c; DDRB |= _BV(PINB0); //Main program loop while (1){ uint8_t b = serial_read_c(&c); if (i != b){ PORTB |= _...
C
#include <stdio.h> #include <math.h> #define G 9.81 int main(){ float speedBeforeBounce;// ask it to the user float speedAfterBounce; float startHeight; float endHeight; float eps; // ask it to the user float *heightPtr = NULL; int nbrOfBouncing; // ask it to the user int i; do...
C
#include<stdio.h> float c,k,f; int main() { printf("introduce una temperatura en °C: "); scanf("%f",&c); k = c+273.15; f = (c*1.8)+32; c = (f-32)/1.8; printf("la temperatura en °k es: %f\n",k); printf("la temperatura en °F es: %f\n",f); printf("la temperatura en °C es: %f\n",c); }
C
#include <stdio.h> #include <stdlib.h> #include <assert.h> typedef int ElemType; int is_even(int n){ return (n % 2 == 0) ? 1 : 0; } int isBadserial(ElemType arr[],int start){ if(arr[start] == arr[start+1] && arr[start] == arr[start+2]){ return 1; }else{ return 0; } } void getKey(ElemType arr[],int start,int ...
C
#include<stdio.h> struct Martial { int id; char name[30]; int type; int count; }; struct Hero { int id; char name[30]; struct Martial martial; char sex[20]; }; int main(int argc, char *argv[]) { struct Hero hero = {1, "孙建春", {1, "少林", .count=10}, "男"}; printf("-------英雄属性---...
C
/* ** EPITECH PROJECT, 2019 ** bootstrap_world ** File description: ** array_len.c */ #include <stdlib.h> size_t array_len(void *array) { size_t len = 0; void **ari_array = (void **)array; if (!ari_array) return (0); while (ari_array[len]) len++; return (len); }
C
#define SUCCESS 0 #define INVALID_NULL_POINTER -1 #define OUT_OF_RANGE -2 typedef struct TStack TStack; TStack *stack_create(int max); //Cria a pilha int stack_free(TStack *st); //Libera a pilha int stack_push(TStack *st, char a); //Insere na pilha (por ser um vetor, insere na ultima posição) int stack_pop(TStack *s...
C
#include "uls.h" static void parse_year(time_t time,t_time *parsed_time, char *date) { parsed_time->year = mx_strnew(4); for (int i = 0; i < 4; i++) parsed_time->year[i] = date[i + 20]; parsed_time->r_time = time; } t_time *mx_parse_ctime(time_t time, t_flags *flags) { t_time *parsed_time = (t...
C
/* Checks if type is 'c'/string , 'i'/integer or 'f'/float and if the length is compatible with the given type */ int checkTypeLength( char type, int length ){ switch( type ){ case 'i': case 'f': if ( length != 4 ){ return -1; /* incompatible length */ } break; case 'c': if ( l...
C
/* $ g++ server.c -o server $ ./server */ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <errno.h> #include <string.h> #include <arpa/inet.h> #include <unistd.h> struct item { int id; char n[100]; int p; int q; }; int main(int arg...
C
/* * Queue.c * * Created on: Feb 4, 2016 * Author: Paras */ # include <stdio.h> int Q[5]; int front = -1; int rear = -1; int N = sizeof(Q)/sizeof(int); int isEmpty(){ if (front == -1 && rear == -1) return 1; else return 0; } int isFull(){ if ((rear+1)%N == front) return 1; else return 0; } void enque...
C
#include <stdio.h> #include <stdlib.h> #include "quicksort.h" #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> #include <string.h> #include <sys/time.h> void imprimeArreglo(int*,int); int* crearArregloAleatorio(int); int main(int argc, char **argv) { int i; int* arr; //...
C
/* Autor : Alex Alves Programa para calculo em arvore */ #include <stdio.h> #include <string.h> #include <mpi.h> int main(void) { int size; // quantidade maxima de processos int rank; // numero do processo atual int valor[8],local,divisor=2,difference=1,soma; MPI_Status stat; // guarda o stat...
C
#include "ccv.h" #include <sys/time.h> unsigned int get_current_time() { struct timeval tv; gettimeofday(&tv, 0); return tv.tv_sec * 1000 + tv.tv_usec / 1000; } float __ccv_mod_2pi(float x) { while (x > 2 * CCV_PI) x -= 2 * CCV_PI; while (x < 0) x += 2 * CCV_PI; return x; } int main(int argc, char** argv) ...
C
#include<stdio.h> #include<stdlib.h> int main() { int n, *arr,i,j,k; printf("Enter the number of element in the array-"); scanf("%d",&n); arr=(int *)malloc(sizeof(n)); printf("Enter the array element-"); for(i=0;i<n;i++) { scanf("%d",&arr[i]); } for(i=0;i<n-...
C
#include <stdio.h> int is_legal(int net[4][4],int n, int pos){ int x,y; int i; x = pos/n; y = pos%n; if(net[x][y]>0) return 0; i=x; while(i>0){ i--; if(net[i][y]==2) return 0; if(net[i][y]==1) break; } i=x; while(i<(n-1)){ i++; if(net[i][y]==2) return 0; ...
C
/* File: effects.c */ /* * The lingering spell effects code. * * Copyright (c) 2007 * Leon Marrick, Ben Harrison, James E. Wilson, Robert A. Koeneke * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free ...
C
/* Name: <your name here> Date: April 5, 2021 Desc: <fill me in> */ #include <stdio.h> #include <stdlib.h> #include <time.h> // Enables use of time() #define MAX_SIZE 100 int getValuesFromUser(int array[]){ printf("Enter values with enter, with -99 as the ending signal.\n"); for(int i = 0; i ...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <sys/time.h> #define SIZE (512 * 1024 * 1024) int main() { struct timeval begin, now; double f0, f1, f2; double sum; char *buf; int i; gettimeofday(&begin, NULL); f0 = begin.tv_sec * 1000000 + begin.tv_usec; printf("BEGIN:\t%lu:%lu\n", begin...
C
#include <stdio.h> // Will test if an integer is even or odd. // Returns 1 if odd and 0 if even. Will also print result to screen. int is_odd(int num){ // Odd, not divisible by two if(num % 2) { printf("%d is odd\n", num); return 1; } // Even, divisible by two else { pr...
C
/* ** echo.c for 42sh in /u/all/bereng_p/cu/rendu/SVN/svn/current/builtins ** ** Made by philippe berenguel ** Login <bereng_p@epitech.net> ** ** Started on Sat Mar 20 21:56:13 2010 philippe berenguel ** Last update Sat Mar 20 22:12:17 2010 philippe berenguel */ #include <stdlib.h> #include <unistd.h> #include "p...
C
#include <stdlib.h> #include <stdio.h> #include<string.h> #include <unistd.h> #include <fcntl.h> #include <string.h> #include <pthread.h> #include <errno.h> #include <time.h> #include <getopt.h> char coins[21] = "0000000000XXXXXXXXX\0"; pthread_mutex_t lockArr = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t lockAr...
C
#include<stdio.h> #include<stdlib.h> struct node { int data; struct node *link; }; typedef struct node *NODE; NODE getnode() { NODE x; x=(NODE)malloc(sizeof(NODE)); if(x==NULL) printf("no memory space left\n"); return x; } NODE ifront(NODE root,int ele) { NODE temp; temp=getnode()...
C
#if ! defined( INPUT_STRING_PARSER_ ) #define INPUT_STRING_PARSER_ /*************************************************************************** * * Mdulo de definio: ISP Input String Parser * * Arquivo gerado: input_string_parser.h * Letras identificadoras: ISP * * Autores: * - hg: H...
C
#include<stdio.h> int ispallindrome (int num); int main() { int num, result; printf("\nEnter the number: "); scanf("%d", &num); printf("%d \n" , num); result=ispallindrome (num ); if(result==1) printf("%d is pallindrome number", num); else printf(" %d is not pallindrome number", num); return 0; } int ispallindrome (int...
C
/**************************************************************************//** * @file sim900.c * @brief SimCom SIM900 driver File * @version V1.1 * @date 20.04.2014 * * @note * Copyright (C) 2014 Serg Sizov * ******************************************************************************/ #includ...
C
#include<stdio.h> void main() { int b[10],ct[10],at[10]={0},t[10],i,j,n,w[10],atat=0,awt=0; printf("\nEnter n value:"); scanf("%d",&n); printf("\nEnter burst time:"); for(i=0;i<n;i++) { printf("\nP[%d]:",i+1); scanf("%d",&b[i]); } printf("\nEnter arrival time:"); for(i=0;i<n;i++) { printf("\nP[%d]:",i+1...
C
/* Take a list of positions and velocities for the two 10 Msun black holes. Using this, compute a and e for the motion of the center of mass around the 10^4 Msun black holes, a and e for the binary, and the relative inclination of the binary to its superorbital plane. Units are AU, yr, and Msun*/ #include <stdio.h> ...
C
#include "ds18b20.h" #include "misc.h" #include "intrins.h" bit ds_init() { bit i; DS = 1; _nop_(); DS = 0; delay_ticks(75); //499.45us ҽϵ18B20ȫλ DS = 1; //ͷ delay_ticks(4); //ʱ37.95us ȴ18B20شź i = DS; delay_ticks(20); //141.95us DS = 1; _nop_(); return (i); } void write_byte(u8 da...
C
// using unsigned integer #include <stdio.h> #define SPEED_OF_LIGHT 299792458 int main(){ double travel_distance; unsigned int cpu_freq, travel_distance2; printf("Frequency of the CPU (Hz): "); scanf("%d", &cpu_freq); travel_distance = 1000.0 * SPEED_OF_LIGHT / cpu_freq; printf("Electricity ...
C
#include <stdio.h> void selectionSort(int length, int *data); void printArray(int length, int *data); int main(void) { int data[] = { 4, 51, 31, 8, 20, 16, 37, 34, 3, 11, 7, 13, 21, 27, 1 }; int length = sizeof(data) / sizeof(data[0]); printArray(length, data); selectionSort(length, data); } void selectionSort(in...
C
/* HEADER: CUG000.01; TITLE: NearNeighbor, CheapArc; DATE: Mar 89; DESCRIPTION: Nearest Neighbor Tour Building Algorithm; VERSION: 2.0; FILENAME: NN.C; SEE-ALSO: TSP.C, POPT.C, 2OPT.C, HYBRID.C, 3OPT.C, FN.C,...
C
#include <assert.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include "tokenize.h" char** tokenize_malloc(const char* str, const char* delim) { char** result; char* token; char* str_malloc; char* str_copy; char* delim_copy; size_t temp_str_len = 0; size_t token_count = 0; ...
C
#include "lists.h" /** * insert_node - Inserts a new node * @head: head of the linked list * @number: number to be inserted * Return: new inserted linked list */ listint_t *insert_node(listint_t **head, int number) { listint_t *temp, *temp2, *new_node; new_node = malloc(sizeof(listint_t)); if (!new_node) re...
C
#include "head.h" #include "work_que.h" #include "factory.h" //发送文件 int sendFile(int sendFd,char *fileName) { Train_t dataTrain; int fileFd; fileFd=open(fileName,O_RDONLY|O_CREAT); ERROR_CHECK(fileFd,-1,"open"); //发送文件名 dataTrain.dataLen=strlen(fileName); strcpy(dataTrain.data,fileName);//???用strcpy还是用别的 send(...
C
#ifndef InstructionList_H #define InstructionList_H /** @struct InstructionList List of disassembled instructions from Static Analise */ struct InstructionList{ char* instruction; /// disassembled instruction in INTEL format int number; ///offset of instruction from text section int length; ///length of instruct...
C
#include<stdio.h> void main() { int integer, i, max, min, sum; max = 32767; /*先假设当前的最大值max为C语言整型数的最小值*/ min = -32768; /*先假设当前的最小值min为C语言整型数的最大值*/ sum = 0; /*将求累加和变量的初值置为0*/ for (i = 1; i <= 10; i++) { printf("Input number %d=", i); ...
C
//Program to display the number entered the base and the converted number. #include<stdio.h> void main() { unsigned int num,num2,base,no_dig=0,p; int i; printf("Enter any positive integer and base: "); scanf("%d %d",&num,&base); printf("number=%d, base=%d, converted number= ",num,base)...
C
#include <stdio.h> /* * 6.6#10 * The semantic rules for the evaluation of a constant expression are the same as for * nonconstant expressions. */ int i0 = 2 || 1/0; int i1 = 0 && 1/0; int i2 = 2 ? 1 : 1/0; int i3 = 0 ? 1/0 : 1; /* address of object: true or false? */ int *p0 = 0 && &i0; int *p1 = &i0 && 0; int *...
C
#include <stdlib.h> #include <time.h> #include <stdio.h> #include "deck.h" #define MAGIC 4459897 struct Deck{ CARD *m_deckArray; size_t m_cardsNum; int m_magicNum; }; /* HELPER */ void SwapCards(CARD *_deck, size_t _a, size_t _b); /* HELPER_END */ Deck *DeckCreate(size_t _numOfDecks) { Deck *_de...
C
#include<stdio.h> #include<string.h> int main() { int i,n; long long int a,b; char str1[101],str2[6],str3[101],str4[6]; scanf("%d",&n); for(i = 0;i < n;i++){ scanf("%s %s %s %s",str1,str2,str3,str4); scanf("%lld %lld",&a,&b); a += b; if(str2[0]=='I'){ if(a...
C
/* * File: symtest.c * --------------- * This program tests the symbol table abstraction. The user * types in command lines, which are assumed to be in one of * the following forms: * * key Display the current value of key * key = value Enter new value for key * quit ...
C
#include <stdio.h> #include <stdlib.h> int main() { /*O comando while: permite executar, repetidamente, um conjunto de comandos de acordo com uma condicao //Forma geral: while(condicao) { conjunto de comandos } */ int a, b; printf("Digite dois valores inteiros: "); sc...
C
#include<stdio.h> #include<string.h> #define N 200 #define M 4 #define NAME 20 struct User { char account[NAME]; int password; struct User *next; }; struct info { char name[NAME]; int toInode; struct info *next; }; struct Block { int blockIsUsed; struct info *p; }; struct Inode { int inodeIsUse...
C
/* * Tutorial 4 Jeopardy Project for SOFE 3950U / CSCI 3020U: Operating Systems * * Copyright (C) 2015, <GROUP MEMBERS> * All rights reserved. * */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "questions.h" // Initializes the array of questions for the game void initialize_game(void) { ...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <unistd.h> #define c 2 //numero di centri di cluster #define n 4 //numero di punti totale in input double m = 2.0; //fuzzification #define d 2 //dimensioni spaziali double epsilon = 0.001; //minima distanza per arrestare double x[n][d]; doubl...
C
#include"init.h" void print_word(pMod pmod_head) { int i,j; char print_word[20]={'\0'}; printf("输入要查找的单词\n"); scanf("%s",print_word); pCh palit; if(print_word[0]<='z'&&print_word[0]>='a') { i=(print_word[0]-'a'); } if(print_word[0]<='Z'&&print_word[0]>='A') { i=(print_word[0...
C
/* CoreGraphics - CGPDFScanner.h * Copyright (c) 2004-2008 Apple Inc. * All rights reserved. */ #ifndef CGPDFSCANNER_H_ #define CGPDFSCANNER_H_ typedef struct CGPDFScanner *CGPDFScannerRef; #include <CoreGraphics/CGPDFContentStream.h> #include <CoreGraphics/CGPDFOperatorTable.h> /* Create a scanner. */ CG_EXTERN...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <signal.h> #include <sys/shm.h> #include <time.h> #include <sys/wait.h> #include <sys/sem.h> #include <sys/types.h> #include "my_library.h" #include "errExit.h" char FifoSer...
C
#include<stdio.h> int main(){ char str[3]; int n,p,m; scanf("%d",&n); int i,j; int plus=0,min=0; for(i=1;i<=n;i++){ scanf("%s",str); for(j=0;j<3;j++){ switch(str[j]){ case '+': plus++; ...
C
int main() { int i; double mid; double height; double width; double sum = 0.0; double area; double t1; double t2; t1 = gettimeofday_sec(); width = 1.0 / ((double) 100000000); #pragma omp parallel for reduction(+:sum) for (i = 0; i < 100000000; i++) { mid = (i + 0.5) * width; height = 4...
C
// Project: Manhattan Massacre // University of Lethbridge - CPSC3710 // Project Deadline: April 1, 2019 // Gideon Richter, Brett Dziedzic, Michelle Le, Sean Herridge-Berry #include <stdlib.h> #include <stdio.h> #include <GL/glut.h> // Struct building // Defined to store characteristics of the building objects in the...
C
#include <stdio.h> #include <stdlib.h> int main() { char **s; s = malloc(sizeof(char *)); char foo[] = "Hello World"; *s = foo; /* printf("s is %s\n", s); // We could leave it like this, and it would not cause a segmentation fault. // However, in that case s is a pointer and ...
C
#include "gpio.h" #include "uart.h" #include <stdio.h> #include <unistd.h> ssize_t _write(int fd, const void *buf, size_t count) { char *letter = (char *)(buf); for (int i = 0; i < count; i++) { uart_send(*letter); letter++; } return count; } int main() { uart_init(); // Configure LED Matrix for (int i =...
C
// This program sets the rounding mode and so must set this pragma to tell the // compiler we will be using/modifying the floating point environment. // Otherwise the program would be undefined (See 7.6.1 The FENV_ACCESS pragama // - C11 specification). #pragma STDC FENV_ACCESS ON #ifdef KLEE #include "klee/klee.h" #en...
C
#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <uv.h> #ifdef _WIN32 #include <windows.h> bool owns_tty(void) { HWND consoleWnd = GetConsoleWindow(); DWORD dwProcessId; GetWindowThreadProcessId(consoleWnd, &dwProcessId); return GetCurrentProcessId() == dwProcessId; } #else bool owns_tty(vo...
C
// // pr_pset04_04: // // Write a program that requests your height in inches and your name, and then // displays the information in the following form: // // Dabney, you are 6.208 feet tall // // Use type float, and use / for division. If you prefer, request the height // in centimeters and display it in meters. ...
C
#include <stdio.h> #include <stdlib.h> struct node { int key; struct node *left, *right; }; int c=0; // A utility function to create a new BST node struct node* newNode(int item) { struct node* temp = (struct node*)malloc(sizeof(struct node)); temp->key = item; temp->left = tem...
C
#include <sys/utsname.h> #include "g_unix.h" /** struct utsname { char sysname[65]; char nodename[65]; char release[65]; char version[65]; char machine[65]; char __domainname[65]; }; **/ int main(int argc ,char** argv) { struct utsname un; if ( 0 > uname(&un) ) { err_quit(...
C
#include<stdio.h> #include<conio.h> void main() { int n,s=0,d,x; printf("Enter a Number"); scanf("%d",&n); x=n; while(n!=0) { d=n%10; s=s+(d*d*d); n=n/10; } if(s==x) printf("%d is an armstrong number",x); else printf("%d is not an Armstrong Number",x); getch(); }
C
/** Module Header **/ #include "system_timers.h" /** Std C Headers **/ #include <string.h> /** BBMC Headers **/ #include "uartStdio.h" #include "cmdline.h" /** Internal Data Types * */ //TODO: add a timer state data type /** Internal Data * */ //TODO: add an internal static state for each timer /** Syst...
C
#ifndef buf_HEADER #define buf_HEADER /** * buf creates a basic, generic buffer object for binary translator. If ownership * of a buffer is going to be passed, it is best to pass it in a buf object. */ #include "object.h" #include <stdint.h> #include <stdlib.h> struct buf { struct object_header oh...
C
/* QT؂ɑ΂MEMBER, INSERT, MIN, DELETẼvO iPȃASYj */ #include <stdio.h> #include <stdlib.h> enum yn {yes, no}; /* 񋓌^f[^yn̒` */ enum LR {LEFT, RIGHT}; struct node /* \node̐錾 */ { int element; struct node *left; struct node *right; }; /* ֐̐錾 */ enum yn member(int x, struct node *init); struct nod...
C
#include <fcgi_stdio.h> #include <stdlib.h> #include <string.h> #include <dirent.h> #include <sys/stat.h> #include <sys/dir.h> #include "lib/paranoia/paranoia.h" #include "cfg.h" const char* css = "#page{" "background:rgba(137,232,148,.1);" "padding:3px;" "}" "#path{" "margin:3px;" "}" ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.c :+: :+: :+: ...
C
int mystrlen(char *str) { int counter = 0; char *p = str; while (*p) { p++; counter++; } return counter; } char *mystrncpy(char *dest, char *source, int n) { int i; char *p = dest; for (i = 0; i < n; i++) { *dest = *source; dest++; source+...
C
#include "../inc/down_task.h" #include <pthread.h> #include <curl/curl.h> /* * 为了达到能同时创建多个下载任务,采用多线程的方法进行 * 线程上限目前先约定为50 * */ int now_down_task_count = 0; //设计到数据同步访问 int prepare_down_task() { curl_global_init(CURL_GLOBAL_ALL); return 0; } static size_t write_data(void *ptr, size_t size, size_t nmemb, void *st...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <time.h> #include "utils.h" #include "buildtext.h" void print_usage(char *name) { printf("Usage: %s [-u | -l | -r | -R | -a POSTFIX | -p PREFIX | -m COUNT]...\n", name); } void print_options() { puts("Available options:"); puts(" -u Uppercase th...
C
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright 2013 Joshua C. Klontz * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * y...
C
#include<stdio.h> int prince[1<<16]; int princess[1<<16]; int mapping[1<<16]; int LIS[1<<16]; void solve(int testcaseNum){ // Scan in input int n, p, q; scanf("%d %d %d", &n, &p, &q); // Reset the mapping and LIS array for (int i = 0; i <= n*n; ++i){ mapping[i] = 0; LIS[i] = 1<<30...
C
#include<stdio.h> main() { int a,b; //by user scanf("%d %d",&a,&b); a = a * b; // a = 10 * 5 = 50 b = a / b; // b = 50 / 5 = 10 a = a / b; // a = 50 / 10 = 5 printf("%d\n%d",a,b); } #include<stdio.h> main() { int a,b; //by user scanf("%d %d",&a,&b); a = a + b; // a =...
C
#include <stdio.h> #include <conio.h> #include <stdlib.h> #include <string.h> #define MAX(a,b) (a>b? a:b) int longestCommonSubsequence(char *a, char lenA, char *b, char lenB) { char i,j; char **LCS = malloc(sizeof(char*) * lenA); for(i=0; i<lenB;i++) { LCS[i] = malloc(sizeof(char) * lenB); } for(i=0; i<le...
C
#include <stdio.h> int pobierz_calkowita(void){ return 0; } float x; double pobierz_rzeczywista(void){ printf("Podaj liczbe rzeczywista: "); scanf("%f", &x); return x; }
C
#include <stdio.h> #define M 4 #define N 6 void StampaColonne(int matrice[M][N]); void StampaRighe(int matrice[M][N]); int main() { int matrice[M][N] = {{11,12,13,14,15,16},{21,22,23,24,25,26},{31,32,33,34,35,36},{41,42,43,44,45,46}}; StampaRighe(matrice); StampaColonne(matrice); return 0; } void ...
C
#include "common.h" int tsocket(int type, const struct sockaddr_in *baddr) { int fd = socket(AF_INET, type | SOCK_NONBLOCK, 0); if(fd < 0) goto onfail; // Enable transparent & recvorigdstaddr. int enable = 1; if(setsockopt(fd, IPPROTO_IP, IP_TRANSPARENT, &enable, sizeof(int)) < 0 || setsockopt(fd, IPP...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<sys/types.h> #include<unistd.h> #include<sys/socket.h> #include<arpa/inet.h> #include<malloc.h> #include<sys/uio.h> #include<signal.h> #include<netinet/in.h> #define PORT 4401 static struct iovec* vr=NULL; void sig_proccess(int signo); void sig_pipe...