language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
//sourcecode #include<stdio.h> #include<stdlib.h> main() { int a,o,e,i,p,q; o=e=p=q=0; while(scanf("%d",&a)==1) { if(a%2) { o+=a; p++; } else if(a!=0) { e+=a; q++; } } if(q) printf("%d",e); else printf("-1"); if(p) printf("\n%.1f",(float)o/p); else printf("\n-1");...
C
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=// // Table for the vector field as a function of distance // //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=// #include "myHist.C" void TableA() { // Input file TFile* file = new TFile("test.root"); // Z positions vector<int> zpts; zpt...
C
#include <stdio.h> #include <stdlib.h> #include "address_book.h" #define CSV "data.csv" phone_book get_data_from_file(FILE *fp, int size); void print_addrr_book(phone_book book); int count_line(FILE *fp); int main(){ FILE *fin = fopen(CSV, "r"); if(fin == NULL){ fprintf(stderr, "can't open fil...
C
/* FILE: ADIS16354A.c AUTHOR(s): Caleb Chamberlain DESCRIPTION: Implements functions for interfacing with the Analog Devices ADIS16354A IMU. DEPENDENCIES: Communication with the IMU is done over the Gumstix SPI port. This code therefore includes SPI.h, and must be built with SPI.c. REVISION LOG: ...
C
#include <stdio.h> #include <elf.h> #include <stdlib.h> #include <string.h> char *parseShType(Elf64_Word type) { if (type == SHT_NULL) return "SHT_NULL"; else if (type == SHT_PROGBITS) return "SHT_PROGBITS"; else if (type == SHT_SYMTAB) return "SHT_SYMTAB"; else if (type == SHT_STRTAB) return "SHT_STRTAB";...
C
#include "mysql.h" #include "symbol.h" #include "onebar.h" #include <iostream> #include <iomanip> #include <chrono> #include <numeric> #include <cmath> MySQL::MySQL() { open(); } MySQL::~MySQL() { close(); } void MySQL::open() { /* Create a connection */ driver = get_driver_instance(); con = dri...
C
#include <netdb.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/socket.h> #include <unistd.h> #include <arpa/inet.h> #include <time.h> #include <netinet/in.h> #include <netinet/tcp.h> #include <arpa/inet.h> #define SIZE 1024 #define PORT 8080 #define SA struct sockaddr void func(FILE *...
C
#include <math.h> #include <stdlib.h> #include <float.h> typedef unsigned char BOOL; #define TRUE 1 #define FALSE 0 // BLAS - dmin, smin + step 1; // F90 - MINVAL; void MinWholeVec( int n, double x[n], double *z ) { int i, ix; double val = DBL_MAX; for( i= 0; i<n; i++ ) { val = fmin(val, x[i]...
C
#include "stdio.h" #include "unistd.h" #include "stdlib.h" #include "pthread.h" #define SERVIDORES 6 #define ESTAGIARIOS 3 #define N 20 #define FALSE 0 int VAGAS = 4; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t baia = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t chefe_mutex = PTHREAD_MUTEX_INITI...
C
#include "stack.h" #include <stdlib.h> #include <stdio.h> Stack *initiateStackWithType(int type){ Stack *stack = (Stack *)malloc(sizeof(Stack)); stack->prox = NULL; stack->firstWeight = 0; stack->totalWeight = 0; stack->type = type; //stack->stackCapacity = 0; return stack; } Stack *initia...
C
#include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <signal.h> #define BUF 128 int curf = 0, n, wf; char* wrf, *buf; int* rf; void corr_exit(int m) { free(buf); for (int i = 0; i < m; ++i) { close(rf...
C
#include "CORDIC/fixed.h" #include "CORDIC/cordic.h" #include <stdio.h> #include <stdlib.h> #define INPUT_LEN 100 #define OUTPUT_LEN INPUT_LEN #define PRECISION 13 extern double I_phase[INPUT_LEN]; extern double Q_phase[INPUT_LEN]; void cal_dpd(double amp, double phase, double *ret_amp, double *ret_phase) { } ...
C
#include <stdio.h> #include <stdlib.h> #define max_size 1000 //0-999 typedef struct ArcNode{ int adjvex; struct ArcNode* nextarc; int info; }ArcNode; typedef struct VNode{ char name; int count; ArcNode* firstarc; }VNode; typedef struct AGraph{ VNode adjlist[max_size]; int n,e; }AGrap...
C
#include <stdlib.h> /* atoi = 整数値の文字列型データをint型に変換する関数 */ #include <stdio.h> /* printf */ int main (int argc, char *argv []) { int i, sum = 0; for (i = 1; i < argc; i++) { sum += atoi (argv[i]); } printf ("%d\n", sum); }
C
#include <stdio.h> #include <stdlib.h> int **malloc2dr(int *nc,int *nr); void malloc2dp(int ***mat,int *nc,int *nr); void separa(int **mat, int nr, int nc, int **black, int **white,int dimBlack,int dimWhite ); void freeAll (int ***mat, int **black, int **white, int nr, int nc); void printVector(int *vector, int dim){...
C
#include <stdio.h> #include <stdlib.h> void cubeByReference( int *nPtr ); int main (void){ int number = 5; printf("The original value of number is %d", number); cubeByReference( &number ); printf("\nThe new value of number is %d\n", number); system("pause"); return 0; } void cubeByReference( int *nPtr ) { *nP...
C
#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> #include <string.h> char * fun(char * p1, char * p2) { int i = 0; i = strcmp(p1, p2); if (0 == i) { return p1; } else { return p2; } } int main() { char * (*pf)(char * p1, char * p2); pf = &fun; (*pf) ("aa", "bb"); return 0; }
C
#include "dado.h" #include <stdio.h> #include <stdlib.h> #include <time.h> #define RANDOM_MAX 21 /** * @brief Rola um dado com um valor de até 20 * * @return int Retorna o valor do dado rolado */ int RolarDado() { int dado; srand(time(NULL)); printf("O resultado foi: %d\n", rand() % RANDOM_MAX); ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* buf.c :+: :+: :+: ...
C
inherit "obj/clean"; int num_pop; reset(arg) { if(arg) return; num_pop = 5; } id(str) { return str == "sheet" || str == "tension sheet"; } short () { return "A tension sheet"; } long () { write("A red, one foot square piece of plastic with\n"+ "numerous air bubbles. Written in bold letters\n"+ "...
C
// #include<stdio.h> // int main() // { // int natural_no = 0; // while (natural_no<=20) // { // if(natural_no>=10){ // printf("The natural no. are %d\n", natural_no); // } // natural_no ++; // } // return 0; // } #include<stdio.h> int main(){ int...
C
/* * TODO: Insert a copyright notice. * * iddqd - Input Device Description Query Daemon * */ #define LOG_TAG "iddqd" #define SOCKET_NAME "inputdevinfo_socket" // NB that MAX_TOKEN_LENGTH and MAX_TOKEN_LENGTH macros are supposed // to take into account string termination characher. #define MAX_TOKEN_LENGTH 23 #de...
C
/* Disciplina: SCC0250 - Computacao Grafica Projeto 1 - Cena com Catavento Alunos: Fabio Alves Martins Pereira 7987435 Mateus Abrahao Cardoso 8658332 */ #include "scene-drawing.h" #include <OpenGL/gl.h> #include <OpenGL/glu.h> #include <GLUT/glut.h> #include <math.h> /* Draw Initi...
C
#include "../common/pe_utility2.h" #include <math.h> // EX4 int is_prime(int n) { if (n == 2) return 1; if (n % 2 == 0) return 0; int i; for (i = 3; i <= sqrt(n); i += 2) { if (n % i == 0) return 0; } return 1; } void change_number(int *v, int n) { if (n == 0) return; change_number(v,...
C
/* Leaders in an array Write a program to print all the LEADERS in the array. An element is leader if it is greater than all the elements to its right side. And the rightmost element is always a leader. For example int the array {16, 17, 4, 3, 5, 2, 0}, leaders are 17, 5 and 2. ALGO: Start from the right. rightmost el...
C
#include <video.h> #include <asm.h> #include <types.h> int pit_setup(){ /* setting counter 1, 1ms = 0x4a9 ticks */ outb((1 << 6) | (3 << 4) | (2 << 1), 0x43); outb(0xa9, 0x41); outb(0x04, 0x41); return 0; } void pit_delay(uint32 ms){ uint16 prev, diff; uint8 low, high; outb((1 ...
C
#include <stdio.h> int main(void) { double a[8], b[8]; int i; printf("Enter 8 number: "); for (i = 0; i < 8; i++) scanf("%lf", &a[i]); b[0] = a[0]; for (i = 0; i < 7; i++) b[i+1] = b[i] + a[i+1]; for (i = 0; i < 8; i++) printf("%5.1f", a[i]); printf("\n"); f...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(){ // -----------------------write of work file------------------------- FILE *fp_out = fopen("file1.txt","w"); int i = 5; float f = 9.98; fprintf (fp_out, "%d %f\n", i, f); // this variables writing on file ...
C
//============================================================================================================================== // Project: WiiTanks // File: SearchCell.h // Author: Daniel McCluskey // Date Created: 07/01/17 // Brief: This header file contains the struct that the path uses to store details about ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* eval_expr.c :+: :+: :+: ...
C
#pragma once // 定义结构体 typedef struct _point { double x; double y; } point; // 创建 `point` 结构体变量 point create_point(double x, double y); // 计算两个 `point` 变量表示的点之间的距离 double distance(const point *p1, const point *p2);
C
inherit "inherit/room2"; object woman; int going; reset (arg) { if(!woman) { woman = clone_object("/d/tempus/w/serepion/mon/woman.c"); move_object(woman, this_object()); going = 0; } if(arg) return; set_short("Old house"); set_long("This is one of the older buildings of the city, belonging t...
C
/* File Name: buffer.c * Compiler: MS Visual Studio 2013 * Author: Mark Kaganovsky, 040789903 * Course: CST 8152 - Compilers, Lab Section 012 * Assignment: 1 * Date: March 8 2016 * Professor: Sv. Ranev * Purpose: Implementation of buffer.h * * Function List: b_crea...
C
#include "lists.h" /** *listint_len - print the size *@h: pointer to the struct * *Return: size_t */ size_t listint_len(const listint_t *h) { size_t num; for (num = 0; h != NULL; num++) { h = h->next; } return (num); }
C
/*Your runtime beats 52.46% of csubmissions.*/ bool isPowerOfTwo(int n) { while (n >= 2 && (n%2 == 0) ){ n = n/2; } if (n == 1) return true; else return false; } /*Your runtime beats 4.93% of csubmissions.*/ bool isPowerOfTwo(int n) { if (n>2 && n%2 != 0) return false; while (n >= 2 && (n%2 == 0) ){ ...
C
// 두 개의 참 또는 거짓이 입력될 때, 모두 참일 때에만 참을 출력하는 프로그램을 작성해보자. #include <stdio.h> int main() { int a, b; scanf ("%d %d", &a, &b); printf ("%d", a&&b); // AND 연산 사용 return 0; }
C
#include "ucode.c" int parent(int console) { while(1) { printf("INIT: wait for ZOMBIE child\n"); int status; pid = wait(&status); getc(); if(pid == console) { printf("INIT: forks a new console login\n"); console = fork(); if (console) ...
C
#include "../pack.c" #include "../util.c" #include "../list.c" #include "../queue.c" #include "../platform.c" // case TCP_PORT: // TCP_CONNECT // TCP_ACCEPT // TCP_CLOSED // TCP_TIMEOUT TcpPort *client, *server; int established (void *conn, int event) { char buffer[1]; net_read (conn, buffer, 1); switch...
C
#include "main.h" volatile uint32_t ticks_delay = 0; uint8_t Rh_byte1, Rh_byte2, Temp_byte1, Temp_byte2; uint16_t RH, TEMP; int main(void) { mcu_init(); RCC->APB2ENR |= RCC_APB2ENR_IOPBEN; while(1) { DHT11_start(); DHT11_Response(); Rh_byte1 = DHT11_Read(); Rh_byte2 = DHT11_Read(); Temp_byte1 = D...
C
/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ int h(struct TreeNode* root) { int a, b; if (!root) return 0; a = h(root->left); if (a < 0) return -1; b = h(root->right); if (b < 0) return -1; if (abs(a ...
C
#include<stdio.h> #include<stdlib.h> #include"TLSE.h" TLSE * reverter_pares(TLSE * l){ if (l == NULL || l->prox == NULL){ return l;} trocar(&l->info, &l->prox->info); reverter_pares(l->prox->prox); return l; } void trocar(int *a, int *b){ int temp; temp = *a; *a = *b; *b = temp; } v...
C
/* C socket server example */ #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <time.h> #include "constants.h" void start_socket_server() { int socket_desc , ...
C
#include <iostream> using namespace std; void func (int & n); int main() { int num; num = 2; cout << num << endl; func(num); cout << num << endl; return 0; } void func (int & n) { n = n * 2; }
C
/* * Copyright (c) 2002, Intel Corporation. All rights reserved. * This file is licensed under the GPL license. For the full content * of this license, see the COPYING file at the top level of this * source tree. * * pthread_barrierattr_destroy() * * The pthread_barrierattr_destroy( ) function shall destro...
C
/* ** init_string.c for lib in /home/Neferett/LIB/lib/string_lib ** ** Made by Bonaldi Jordan ** Login <Neferett@epitech.net> ** ** Started on Thu Jan 26 15:04:23 2017 Bonaldi Jordan ** Last update Sun Feb 12 12:07:38 2017 Jordan Bonaldi */ # include "lib.h" void init_string_part(t_string *str) { str->toStrin...
C
#include <stdint.h> void *malloc(__ssize_t size) { return (void*)0xdaedbeef; } void free(void* ptr) { printf("Freeing ptr at: %p\n", ptr); }
C
inherit "/obj/treasure.c"; #define REPLICANT_PATH "/players/mokri/cybers/obj/template.c" #define COST 1000 reset(int arg) { if(arg) return; set_id("replicator"); set_short("A replicator"); set_long("\nA rectangular, metallic machine. It stands six feet tall.\n"+ "There is a square hole halfway up the ...
C
#include<stdio.h> #include<stdlib.h> struct Node { int data; int hd; struct Node *left,*right; }; typedef struct Node node; node *createNode(int d,int h) { node *nn=(node*)malloc(sizeof(node)); nn->data=d; nn->hd=h; nn->left=nn->right=NULL; return nn; } node* createTree(node* head,int d,int h) { ...
C
/** Fichiers d'inclusion **/ #include "libgraph.h" /** Variables globales **/ static int fenetre_x = -1, fenetre_y = -1; static const couleur couleurs[] = { { 255, 255, 255 }, { 0, 0, 0 }, { 255, 0, 0 }, { 0, 255, 0 }, { 0, 0, 255 }, { 255, 105, 180 }, { -1, -1, -1 } }; static SDL_Window* fenetre; static S...
C
#include <stdio.h> #include <signal.h> #include <sys/types.h> #include <sys/stat.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <string.h> #include <errno.h> static int set_signal_handler(int sig,void (*handler)(int)) { struct sigaction sa; struct sigaction old_sa; memset(&sa,0...
C
/********** Copyright 1990 Regents of the University of California. All rights reserved. Author: 1986 Thomas L. Quarles **********/ #ifndef IFSIMULATOR #define IFSIMULATOR /* * We don't always have access to an ANSI C compiler yet, so we * make the following convenient definition */ /* using an ...
C
/* ** draw_fdf.c for fdf in /home/dupard_e/rendus/MUL_2014_fdf ** ** Made by Erwan Dupard ** Login <dupard_e@epitech.net> ** ** Started on Tue Nov 11 12:57:57 2014 Erwan Dupard ** Last update Fri Dec 5 00:16:22 2014 Erwan Dupard */ #include <mlx.h> #include <unistd.h> #include <stdlib.h> #include "./draw_fdf.h" ...
C
#define _GNU_SOURCE 1 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <getopt.h> #include <wordexp.h> #include <assert.h> #include "list.h" const int BUFFER_SIZE=1024; const char *program_name; const char *version="1.0.1"; void print_usage(FILE *stream, int exit_b, int exit_code) { fprintf(stre...
C
#include <stdint.h> #include <assert.h> #include "heap.h" #include<stdio.h> //#include<conio.h> #include<stdlib.h> void test_sort( int32_t data[], uint32_t len) { uint32_t idx; for (idx = 1; idx <= len; ++idx) { assert (data[idx] <= data[idx+1]); } } void test_heap() { int32_t datatm[] = { 630, 700, 730, 800...
C
#ifndef STACK_H #define STACK_H #include <stdint.h> #include <time.h> #include <semaphore.h> #include "my_bool.h" #define ZCH_MAXTAGSIZE 16 typedef struct { uint32_t id; char tag[ZCH_MAXTAGSIZE]; uint8_t priority; uint16_t size; long timestamp; uint8_t *data; } packet_t; typedef struct stack_n...
C
/* * C Program to Display the ATM Transaction */ #include <stdio.h> #include <string.h> char pin[16]; int checkPIN =0; double balance=1000,withdraw,deposit; int choice; void showMenue(){ printf("\n1. Check Balance\n"); printf("2. Withdraw Money\n"); printf("3. Deposit Money\n"); printf("4. Ex...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* opc_utils.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <dns_comdef.h> #include "Main.h" /* Takes a filename and * reads pairs of 'key value' or 'key = value'. */ extern char *g_mgr_ip; extern char *g_core_ip; int dns_read_config(const char *fname) { FILE *f; char buf[1024]; char *...
C
#ifndef _LINEAR_LIST_H_ #define _LINEAR_LIST_H_ #define IS_EMPTY 0 #define NOT_EMPTY 1 #define MAX_SIZE 50 #define FAILED 0 #define SUCCESS 1 typedef int ElemType; typedef struct SqList { ElemType data[MAX_SIZE]; int length; }SqList,*pSqList; SqList* CreateList(ElemType a[], int n); Sq...
C
#include "stdio.h" #define L 18 #define D 9 #define MAX1 (L*D) #define MAX2 (L*D*D) int prime[MAX2+1]; long long power[L+1], cnt[L+1][MAX1+1][MAX2+1]; long long ways( long long n, int i, int j, int k ) { if( i < 0 ) return 0; int d = n / power[i]; long long ans = ways( n - d * power[i], i - 1, j + d, k + d * d );...
C
#include "I2C.h" #include <stdbool.h> /******************************************************************************* * Function Name : I2C_DevInit * Description : Initializes peripherals used by the I2C Device driver. * Input : None * Output : None * Return : None ***********************...
C
/* ݺ : while , do while, for while : Ϲ ݺ (ѹݺ, ݺ) do while : ó 1 ȸ Ǵؼ ݺ for : Ƚ ݺ for (ʱ ; ǽ ; ) {๮} ݺ index ʿ ex : i j k l m .... ǹ : ǿ α׷ ٸ if switch ׽ ִ if : if(ǽ) {๮}, (true : 0 ƴ ) ϸ . Ҹ ׳ Ѿ . else if , ۿ ǵ ǥ else if() else if() else() ׽ : 3 ׽ ǥ : (ǽ) ? ๮1 : ๮2; ǽ ()Ǹ ๮ 1 ǰ Ҹ(...
C
int minPathSum(int** grid, int gridSize, int* gridColSize){ int **arr = (int **)malloc(sizeof(int *) * gridSize); int i, j, re = 0; for(i = 0; i < gridSize; i++){ arr[i] = (int *)malloc(sizeof(int) * gridColSize[i]); //printf("%d\n", gridColSize[i]); } arr[0][0] = grid[0][0]; for(i = 1; i < gridSize; i...
C
#ifndef __UTILS #define __UTILS #include "stm8.h" #define LED_PORT PA #define LED_PIN PIN3 // returns the most significant byte // of the given 16 bit integer uint8_t msb(uint16_t value){ return (value >> 8) & 0xff; } // returns the least significant byte // of the given 16 bit integer uint8_t lsb(uint16_t ...
C
#include<stdio.h> #include<string.h> #include "io.h" #include "err.h" #include "str.h" #define MAX_STR_LEN 128 #define MAX_WORDS_NUMBER MAX_STR_LEN/2 int main(int argc, char **argv) { int rc = OK; if (argc != 3) { puts("WRONT INPUT FILES IN CMD"); puts("Usage: app f_in f_o...
C
#include <stdlib.h> #include <string.h> #include <stdio.h> #include <fcntl.h> #include <sys/socket.h> #include <netdb.h> #include <arpa/inet.h> #include <netinet/in.h> #include <unistd.h> #include <errno.h> #include "network.h" #include "util.h" typedef struct _client{ int socket; my_ssl *ssl; struct sockaddr...
C
#include<stdio.h> #include<stdlib.h> struct node { int data; struct node*link; }*root,*temp,*ptr; int main() { root=(struct node*)malloc(sizeof(struct node*)); root->data=NULL; root->link=NULL; char ch; while(ch != 'n' || ch =='N') { int item; printf("\nenter a data:"); ...
C
#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int i, j, n, m; scanf("%d%d", &n, &m); for(i=1; i<=n; i++){ for(j=1; j<=m; j++){ printf("%d*%d=%2d ", i, j, i*j); } printf("\n"); } return 0; }
C
#include <linux/kernel.h> #include <linux/sched.h> #include <asm/page.h> #include <asm/pgtable.h> #include <linux/mm_types.h> asmlinkage int sys_vma_props(unsigned long mem, int pid) { struct task_struct *task; struct task_struct *ptask = current; // getting global current pointer task =pid_task(find_v...
C
/* A8_07 : Program which is used to pring home directory and login user name. */ #include<stdio.h> #include<string.h> // global declaration //extern char **pEnviron; int main(int argc, char *argv[], char **environ) { char **pEnv = environ; int iCount = 0; printf("[INFO] Enviornment variab...
C
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<unistd.h> #include<ctype.h> #include<assert.h> #include "quiz4.h" /* * author: Isaac Attuah * date: 9/16/2020 * pledge: this is my own work, unless otherwise noted * */ #define USAGE_MESSAGE "usage: quiz4 _word1_ _word2_ ... " int main(int argc...
C
/* * Copyright (C) 2017 by Benedict Paten (benedictpaten@gmail.com) * * Released under the MIT license, see LICENSE.txt */ #include "CuTest.h" #include "margin.h" int64_t genotypingTest2(char *paramsFile, char *bamFile, char *outputBase, char *referenceFile, char *vcfReference, char* singl...
C
#include <stdio.h> sal(){ float sal,aum; scanf("%f",&sal); aum=sal*0.25; sal=sal+aum; printf("%f",sal); } main(){ sal(); }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* print_int.c :+: :+: :+: ...
C
#include<stdio.h> #include<stdlib.h> #include "pds.h" #include "contact.h" main( int argc, char *argv[] ) { char *datafile; char *repo_name; int status, rec_size; if( argc != 3 ){ fprintf(stderr, "Usage: %s <repo-name> <dump-file-name>\n", argv[0]); exit(1); } repo_name = argv[1]; datafile = argv[2];...
C
#include <sys/types.h> #include <sys/stat.h> #include <sys/socket.h> #include <stdio.h> #include <netinet/in.h> #include <arpa/inet.h> #include <unistd.h> #include <stdlib.h> #include <pthread.h> #include <string.h> #define THREAD_NUM 1 #define BLOCK_SIZE 1024 pthread_mutex_t mymutex = PTHREAD_MUTEX_INITIALIZE...
C
#include <stdio.h> #include <stdlib.h> struct node { int num; struct node *next; }; typedef struct node NODE; void josef(int m, int n); void exchange(int a[]); void main() { int m,n; printf("请输入总人数:"); scanf("%d",&m); printf("请输入第几个人受到惩罚:"); scanf("%d",&n); josef(m,n); } void josef(i...
C
/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ struct TreeNode* sortedArrayToBST(int* nums, int numsSize){ if(numsSize == 0) return NULL; struct TreeNode *leftTree = sortedArrayToBST(nums, numsS...
C
// 1. 指定头文件 #include <linux/init.h> #include <linux/module.h> // 定义全局变量 static int irq; static char* pstr; static int fish[10]; static int nr_fish; // 模块参数声明,加载模块或模块运行时可以修改变量内容 module_param(irq, int, 0664); module_param(pstr, charp, 0); module_param_array(fish, int, &nr_fish, 0664); // 2. 指定入口函数 insmod/modprobe sta...
C
#include "reef.h" void test_str() { MSTR astr; mstr_init(&astr); MTEST_ASSERT(astr.buf == NULL); mstr_append(&astr, "string"); MTEST_ASSERT_STR_EQ(astr.buf, "string"); mstr_appendn(&astr, " appendn", 3); MTEST_ASSERT_STR_EQ(astr.buf, "string ap"); mstr_appendc(&astr, 'x'); MTES...
C
/* generator.h // název projektu: Implementace překladače imperativního jazyka IFJ19 // tým: 040 // varianta: II (implementace pomocí tabulky s rozptýlenými položkami) // autoři: Boris Burkalo, xburka00, 2BIT // Jiří Herrgott, xherrg00, 2BIT // Jan Klusáček, xklu...
C
#include<stdio.h> #include<stdlib.h> int solve(int arr[],int n,int size) { int i,ans1; if(n==0) { for(i=0;i<size;i++) { if(i==size-1) { printf("%d\n",arr[i]); } else { printf("%d,",arr[i]); } } return 1; } if(n<0) { return 0;...
C
#include"cheaders.h" #define FLOAT #define INTEGER #ifdef INTEGER #define swap(t,x,y) t temp;\ temp=x;\ x=y;\ y=temp #endif int main() { #ifdef INTEGER int i1=10,i2=20; puts("Before swapping"); printf("i1 = %d i2 = %d\n",i1,i2); swap(int,i1,i2); puts("After swapping"); printf("i1 = %d i2 = %d\n",i1,i2); ...
C
#include <stdlib.h> #include <assert.h> #include <string.h> #include "sprite.h" #include "sprite_matrix.h" void generateLiu(struct sprite* s) { // s->width = 73; // s->height = 73; // int data_size = s->width * s->height / 8 + 1; // s->data = (unsigned char*) malloc(data_size * sizeof(unsigned char)); // ...
C
#include<stdio.h> #include<stdlib.h> int main(void){ void* p; p=malloc(1024); printf("The length mem is %d\n",sizeof(p)); // int a[10]={0}; // printf("The length is %d\n",sizeof(a)); return 0; }
C
#include <stdio.h> #include <mem.h> #include <stdlib.h> #include "input.h" void get_input_discard_overflow(char *input, short input_size) { fgets(input, input_size, stdin); if (strchr(input, '\n') == NULL) { int ch; while ((ch = fgetc(stdin)) != '\n' && ch != EOF); } } void require_input(...
C
#include <stdio.h> #include "genlib.h" #include "stdlib.h" #include "simpio.h" #define BUF_SIZE 100 #define LEVEL 100 int introduction(); int award(); int statistics_inquire_delete(); int show(); int a[LEVEL]; int main() { introduction(); award(); statistics_inquire_delete(); return 0; } int introduction() { ...
C
#include "main.h" /** * swap_int - swap the arguments * @a: pointer parameter * @b: pointer parameter two */ void swap_int(int *a, int *b) { int temp = *a; *a = *b; *b = temp; }
C
#include "../include/libft.h" void ft_printf_get_flag(char *s, va_list args, t_flags ***lst) { int i; i = 0; while (s[i]) { (**lst)->just = (s[i] == '-') ? 1 : (**lst)->just; (**lst)->prec = (s[i] == '.') ? 0 : (**lst)->prec; if (s[i] == '*' && (**lst)->prec >= 0) (**lst)->prec = va_arg(args, int); els...
C
/** * @file fatura.c * @brief Funções relativas a uma fatura. */ #include <stdlib.h> #include <string.h> #include "fatura.h" #include "mytree.h" struct fatura { char *produto; /**<O código do produto*/ int numVendas[2][12][3]; /**<Numero de vendas de um produto organizado por tipo, mês e filial*/ double fa...
C
#include <stdio.h> #include <stdlib.h> void log_wrapper(FILE *logFD, char *str, char *filename) { char *buff; strcpy(buff, str); snprintf(buff + strlen(buff), 254 - strlen(buff), filename); buff[strcspn(buff, "\n")] = "\0"; fprintf(logFD, "LOG: %s\n", buff); } int main(int argc, char **argv) { ...
C
/* ** my_putchar.c for my_putchar in /home/saumon/sommer_j/my_putchar ** ** Made by SOMMER Julien ** Login <sommer_j@etna-alternance.net> ** ** Started on Mon Oct 17 12:23:07 2016 SOMMER Julien ** Last update Mon Oct 17 16:54:28 2016 SOMMER Julien */ #include <unistd.h> void my_putchar(char c) { write(1, &c, 1...
C
#include <fcntl.h> #include <stdio.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> int main(int argc, char const *argv[]) { int fd; unsigned char buff[128]; fd = open("dacfifo", O_RDONLY); read(fd, buff, 128); printf("Read: %s\n", buff); return 0; }
C
/* ** unsetenv.c for in /home/antoin_l/Travail/PSU_2014_42sh/builtins ** ** Made by ** Login <@epitech.net> ** ** Started on Sat May 23 14:25:38 2015 Léo Antoine ** Last update Sun May 24 22:13:30 2015 Léo Antoine */ #include "include.h" int clear_env(char **env, char *s) { int j; j = -1; while (env[++j...
C
#include <stdio.h> #include <stdlib.h> void remove_red(); void convert_to_black_and_white(); void instagram_square(); int main(int argc, char *argv[]) { if((!(argv[1][0]=='1'||argv[1][0]=='2'||argv[1][0]=='3'))&&argc==2){ printf("Error: Expecting one command-line argument, which needs to be ei...
C
/* File: pcolor.c */ /* pcolor.h implemetation */ #include <stdio.h> #include <string.h> #include "pcolor.h" // Prints a red character void print_red(char c) { printf("%s%c", RED, c); printf("%s", NORMAL); } // Prints a green character void print_green(char c) { printf("%s%c", GREEN, c); printf("%s",...
C
#include "main.h" int main(int argc, char *argv[]) { GtkWidget *main_window; gtk_init(&argc, &argv); // make main window and connect destroy signal main_window = make_window(); g_signal_connect_swapped(G_OBJECT(main_window), "destroy", G_CALLBACK(gtk_main_quit), NULL); // fire it up! gtk_main(); ...
C
/* referece ----- https://www.kernel.org/doc/Documentation/i2c/dev-interface ioctl(file, I2C_RDWR, struct i2c_rdwr_ioctl_data *msgset) Do combined read/write transaction without stop in between. Only valid if the adapter has I2C_FUNC_I2C. The argument is a pointer to a ----- http://bunniestudios.com/blog/ima...
C
/* ** Purpose: Implement the scheduler. Uses scheduler & message tables. ** ** Notes: ** 1. Orginally based on NASA Goddard's SCH_LAB app ** 2. This design intentionally decouples the scheduler table from ** application specific processing such as command callback ** functions and file processing. ** ...
C
#define TRUE 1 #define FALSE 0 void handleFunction(char *input); int stringEqual(char* cmd, char *input); void parseCommand(char *input, char args[][10]); /* Start shell commands */ void type(char * file); void execute(char * file); /* End shell commands */ void main() { char input[80]; while(1) { interrup...