language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include "libimap.h" #define ORIG_EXT(type) \ ORIG(&e, \ E_PARAM, \ "%x extension for IMAP is not available", \ FD(extension_token(type)) \ ) static const extension_state_e *const_extension_find( const extensions_t *exts, extension_e type ){ switch(type){ case EXT_UIDPL...
C
#include <stdio.h> #include <string.h> int main() { int i; char name[20], password[20], ch; printf("Enter your username"); scanf("%s", &name); printf("Enter your password"); for (i = 0; i < 8; i++) { ch = getchar(); password[i+1] = ch; ch = '*' ; printf(...
C
#include "c101_Total.h" #include "c101_Subunit.h" #include "c101_Visit.h" static int totalVisitor(enum c101_VisitorType type, void* unit, void* out) { if (type == C101_EMPLOYEE) *(double*) out += ((struct c101_Employee*) unit)->salary; return 0; } double c101_total(struct c101_Company* c) { double...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_list_clear.c :+: :+: :+: */ /...
C
/*************************************************** > Copyright (C) 2017 ==HEBOWEN== All rights reserved. > File Name: charu.c > Author: hebowen > Mail:982034166@qq.com > Created Time: 2017年06月29日 星期四 19时14分44秒 ***************************************************/ #include <stdio.h> #define MAX sizeof(a)/sizeof(a[0])...
C
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> int main() { float ph; scanf("%f", &ph); if((ph >=0) && (ph <=14)){ if(ph == 7){ printf("Neutra"); } else if(ph < 7){ printf("Acida"); } else { printf("Basica"); } } retu...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* map_parcing.c :+: :+: :+: ...
C
/* * opens a file in the current directoy by name * and returns its contents as an unsigned char * */ int server::get_file_128(char filename[], char * contents, int offset) { // check if there are 16bytes left in file int filesize = get_filesize(filename); if(filesize < 0) return -1; int rema...
C
/** * OS Assignment #1 **/ #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <signal.h> #include <ctype.h> #include <errno.h> #include <sys/wait.h> #include <sys/signalfd.h> #define MSG(x...) fprintf (stderr, x) #define STRERROR strerror (errno) #define ID_MIN 2 #define ID_MA...
C
#include "stdio.h" # define MAXSIZE 10 typedef struct{ int * base; int length; }sqlist ; reverseSQ(sqlist *l){ int low = 0 , high = l->length - 1; int buf , i; for(i=0;i<l->length/2;i++) { buf = l->base[low] ; l->base[low] = l->base[high]; l->base[high] = b...
C
#include <stdio.h> #include <stdlib.h> struct frame { int reference, lifespan, pagenumber; struct frame *next; } frame; int main(void) { FILE *f = fopen("input.txt", "r"); int *arr = NULL, i, j, size = 0, fsize = 0, hitrate = 0, missrate = 0; while ((i = fgetc(f)) != EOF) { if (i == ' ') { ...
C
/*$Id$*/ /** \file * This is the implementation of the reading in of the input string from file or * directly from memory. * * \todo Deal correctly with the path. */ #include "inputStringBuilder.h" #include "inputString-api.h" #include <aterm1.h> #include <string.h> #include <stdlib.h> #include <assert.h> #inc...
C
/* Questão1 #include <stdio.h> main() { int numero, quadrado; printf("\nEntre com um numero inteiros nao-nulo: "); scanf("%d", &numero); quadrado = numero * numero; printf("O quadrado do numero %d e %d\n", numero, quadrado); } */ #include <stdio.h> int quadrado(int numero) { return (numero*numero);...
C
#include <unistd.h> #include <string.h> #include "./ft_strcpy.c" void ft_putchar(char c) { write(1, &c, 1); } void ft_putstr(char *str) { int i; i = 0; while (str[i] != '\0') { ft_putchar(str[i]); i++; } } int main() { char src[] = "Hello"; char dest[] = "wossdsdsd"; char des[] = "wosdsdsdssd"; ft_...
C
/** * @file policy.c * @author Bilal Mohamad (bmohama) * * This component is responsible for functionality pertaining to the policy and firewall rules. * It contains features used by the top-level component, fwsim.c, but it should never make * calls to code in fwsim.c. */ #include <stdio.h> #include <stdlib.h> ...
C
#include <stdio.h> void qsort(int[], int, int); void swap(int[], int, int); int main(void) { /* test quicksort here */ int test1[10] = {9, 1, 3, 4, 2, 5, 8, 7, 0, 6}; qsort(test1, 0, 9); for(int i = 0; i < 10; i++) printf(" %d ", test1[i]); return 0; } /* qsort: sort v[left]...v[right] into...
C
#include <stdio.h> int main() { int n, a, b; int contador = 0; int resposta = 0; scanf("%d", &n); while (contador < n) { scanf("%d %d", &a, &b); resposta += a*b; contador++; } printf("%d\n", resposta); return 0; }
C
/* * list.c * ASA 2018 * Gabriel Figueira, Rafael Andrade * P1 (Sr. Joao Caracol) */ #include <stdio.h> #include <stdlib.h> #include "adj.h" typedef struct node { struct node * next; int id; } * Node; struct graph { Node * adjList; int n_vertexes; int n_connections; } ; static Node * adjListAuxPoin...
C
#include "board.h" void init_board(struct game_data * game_data) { for (int i = 0; i < BOARD_SIZE; i++) { for (int j = 0; j < BOARD_SIZE; j++) { game_data->board[i][j] = 0; } } for (int i = 0; i < game_data->n_players; i++) { int x; int y; do { x = randint(0, BOARD_SIZE); y...
C
/**************************************************************************** * * C F I L E C R E A T E R O U T I N E * ----------------------------------------- * * The "creat" routine opens a new "C" file and returns a file id. * * Calling Sequence: * * fid = creat(fname,prot,type); * * Where: * * fn...
C
#include <stdio.h> #include <ctype.h> #include <string.h> static void expand(char s1[], char s2[]); int main(void){ char a[] = "1-6"; char buff[1000] = ""; expand(a, buff); printf("%s\n", buff); return 0; } /* expands shorthand * a-z -> abc...xyz CHECK * a-b-c -> abc CHECK * a-z0-9 -> abc..xy...
C
/** * In order to provide fast and flexible logging, this project uses Cocoa Lumberjack. * * The Google Code page has a wealth of documentation if you have any questions. * https://github.com/robbiehanson/CocoaLumberjack * * Here's what you need to know concerning how logging is setup for CocoaHTTPServer: * ...
C
#include <stdio.h> #include <stdlib.h> #include <errno.h> #include <sys/types.h> #include <dirent.h> #include <sys/stat.h> /* see chapter4/readdir_r-v1.c for extra comments */ int main(int argc, char **argv) { /* Always list the current directory */ char *d_to_open = "."; DIR *dstream = opendir(d_to_open); if (...
C
/* * Ben Dumais, 250669195 * 3305b, Spring 2016 * Assignment 1 */ //Includes #include <stdio.h> #include <string.h> #include <unistd.h> #include <stdlib.h> #include <fcntl.h> #include <signal.h> //Definitions #define MAX_SIZE 256 //Max size of a str #define MAX_CMD 10 //Maximum amount of commands in a line #def...
C
#include <stdio.h> //#include <libc.h> //Linux Only #include "bmp.h" int get_short(FILE *fp) { int c = getc(fp); return ((getc(fp) << 8) | c); } long get_long(FILE *fp) { long c = get_short(fp); return ((get_short(fp) << 16) | c); } bmpHeader *loadBmpHeader(FILE *fp, int *errcode) /* ե뤫إåɤࡣ 顼 NULL֤ꡢerrco...
C
#include <stdio.h> //========================================================================= // ļ main.c // ѧƽɼͲ // ά¼: 2008-4-17 v1.0 by xdw //========================================================================= struct stu { int num; char *name; char sex; float score; }temp,boy[5]={ {...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <signal.h> static int alarm_fired = 0; void ding (int sig) { alarm_fired = 1; } int main () { pid_t pid; printf ("Alarm app start.\n"); pid = fork (); switch (pid) { case -1: // failure perror ("Fork failed"); ...
C
//job_arraylist.c #include "job_arraylist.h" #include "sfbuiltin.h" int job_cnt = 0; int addJob(struct job* newJob){ if(newJob->inJob) newJob->jid = ++job_cnt; if (job_start == NULL && job_end == NULL){ // empty list job_start = newJob; job_end = newJob; } else{ job_end->next = newJob; newJob->prev =...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> int is_in_sentence(char* wrd,char* sntnce) { char* result = strstr(sntnce, wrd); int position = result - sntnce; if(strstr(sntnce,wrd) != NULL){ return position; } else { return 0; } } int main() { // Create a function ...
C
#include<stdio.h> #include<fcntl.h> #include<errno.h> #include<unistd.h> #include<sys/time.h> #include<string.h> extern int errno; int main(int argc, char * argv[]){ int fd = open("myfifo",O_RDONLY); int timeout=10; //TimeOut For 10 seconds struct timeval tv; tv.tv_sec = timeout; tv.tv_usec...
C
#include <stdio.h> #define DIM 4 int main(){ int a[DIM][DIM], b[DIM][DIM], m[DIM][DIM], i, j, k; for(i = 0; i < DIM; i++){ for(j = 0; j < DIM; j++){ scanf("%d", &a[i][j]); } } for(i = 0; i < DIM; i++){ for(j = 0; j < DIM; j++){ scanf("%d", &b[i][j]); } } for(i = 0; i < DIM; i++){ for(j = 0; j...
C
#include <stdio.h> #include <gsl/gsl_rng.h> #include <math.h> // #include <stdlib.h> // #include <time.h> double circle_overlap(double *rA, double radiiA, double *rB, double radiiB) { double rAB[2]; rAB[0] = rB[0] - rA[0]; rAB[1] = rB[1] - rA[1]; double F; F = (pow(rAB[0], 2) + pow(rAB[1], 2))...
C
/* * rgb_component_video.c * by Nick Camp and Darby Huye * Assignment 4; 3/8/2018 * * * This file contains functions used for compression from rgb to * component video. The file also contains functions for decompression * from component video to rbg. Compression takes a ppm image a...
C
/* * project 1 (shell) main.c template * * project partner names and other information up here, please * */ /* you probably won't need any other header files for this project */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <string.h> #include <ctype.h> #include <sys/reso...
C
#include <stdio.h> int main() { int p,q,i,j,k,count=0; scanf("%d %d",&p,&q); for(i=p;i<=q;i++) { for(j=1;j<=i;j++) { k=j*j; if(k==i) { count=count+1; break; } } } printf("%d",count); return 0; }
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #include <time.h> #include <unistd.h> #define textin "A.txt" void printall(char text[], char* theword); void mywait(double seconds); int main(int argc, char* argv[]) { char* theword; if (argv[1] == '\0') theword = "a"; ...
C
/* * DoublyLinkedList.c * * Created on: 2018. 5. 11. * Author: sha */ #include<stdio.h> typedef struct DLLNode{ int data; struct DLLNode *next; struct DLLNode *prev; }DLLNode; //߿ḮƮ ϿḮƮ q ʿ. void DLLInsert(struct DLLNode **head, int data, int position){ int k = 1; struct DLLNode *temp, *newNode; new...
C
#include "../../includes/verify.h" #include "../../includes/math_functions_double.h" #include "double_acos.h" int main() { /* REQ-BL-0480: * The acos and acosf procedures shall return NAN , if the argument x is +-inf */ double x = 1.0/0.0; // INF __VERIFIER_precond_reach(); double res = __ieee754_acos(...
C
/* * l_psensor.c * * Created on: 23 ago. 2019 * Author: pablo * * El sensor mide presion diferencial. * Por lo tanto retorna PRESION de acuerdo a la funcion de transferencia * con la pMax la de la hoja de datos. * De acuerdo a la hoja de datos, la funcion de transferencia es: * p(psi) = (pmax - pmi...
C
#include <stdio.h> #include <stdlib.h> #include "funcoes_vetor.h" #include "funcoes_visao.h" int le_tamanho_vetor(){ int tamanho_vetor; system("clear"); printf("Digite a quantidade de inteiros para serem armazenados: "); scanf("%d", &tamanho_vetor); return tamanho_vetor; } void le_inteiros_vetor...
C
#include <stdio.h> int main() { //If checking on the value of a single variable, it is better to use switch statement than if else char operator; double firstNum, secondNum; printf("enter an operator: "); scanf("%c", &operator); printf("enter two operands: "); scanf("%lf %lf", &firstNum, &secondNum); switch(opera...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define SZ(n) ((2 * n + 1) * (sizeof(char))) char * count(char *s, int n, char *pc) { // printf(" %d \n", n ); int i = 0; int count = 1; int j = 0; for (; i < n; i++) { if (i + 1 != n && s[i] == s[i + 1]) { count++; } else { snprin...
C
//Zachary Gill //CGS 3269 Spring 2017 //Program 3 //04-17-17 #include "P.h" #include "instruction.h" #include "stack.h" #include "IO.h" //Variables struct registers r; //Functions /* Runs the pMachine simulation. */ void pMachine() { initializeRegisters(); initializeLog(); do { fetch(); logFetch...
C
/* tpifArray1.c: If-statement and subscripted var. */ main( ) { int i; int s, q, a[100]; i=0;s=1,a[0]=2; /* SF030620 */ if (s>0) a[i]=a[i]*s; printf("s=%d a[%d]=%d\n",s,i,a[i]); /* SF030620 */ }
C
#include <stdio.h> int main(void) { int arr[3][9]={0}; int i=2, j; for( ; i<5; i++) { for(j=1; j<10; j++) { arr[i-2][j-1] = i*j; } } for( i=2; i<5; i++) { for(j=1; j<10; j++) { printf("%d ", arr[i-2][j-1]); } printf("\n"); } return 0; }
C
# include <stdio.h> # include <math.h> int main() { // 600851475143 long long i,j,k,l,num = 600851475143; _Bool flag = 1; for (i = 2,j = num /i;flag != 0;i++,j = num/i , flag = 1) { if (i * j == num) { k = sqrt((double)j); for (l = 2;l <= k;l++) { if(j % l == 0) { flag = 0; ...
C
#include<GL/freeglut.h> #include<math.h> #include <graphics.h> void init(){ glClearColor(0.986,1.0,1.0,0.0); glMatrixMode (GL_PROJECTION); gluOrtho2D (0.0, 200.0, 0.0, 150.0); } void boundaryfill(int x,int y,int f_color,int b_color) { if(getpixel(x,y)!=b_color && getpixel(x,y)!=f_color) { putpixel(x,y,f_color);...
C
#include <stdio.h> int main(int argc, char *argv[]) { int i,a,b,c,n,s; c=0; s=0; for (i=0;i<3;i++) { scanf("%d",&a); s+=a; } c+=(s+4)/5; s=0; for (i=0;i<3;i++) { scanf("%d",&b); s+=b; } c+=(s+9)/10; if (c>n) printf("NO"); else printf("YES"); return 0; }
C
/* * AppendPoint.cpp * * Created on: Nov 9, 2018 * Author: jludwig */ #include "kv_append_point.h" #include "kv_block_allocator.h" #include <errno.h> struct kv_append_point { struct kv_block_allocator *block_allocator; uint32_t current_append_point; uint64_t last_scanned_sequence_number; }; i...
C
#include <stdio.h> #include <math.h> int main() { double a, b, c, disc, x1, x2, p, q; scanf("%lf %lf %lf", &a, &b, &c); disc = b * b - 4 * a * c; p = -b / (2 * a); q = sqrt(disc) / 2 * a; x1 = p + q; x2 = p - q; printf("\nx1=%5.2f\nx2=%5.2f\n", x1, x2); return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include "circularList.h" // Double link struct Link { TYPE value; struct Link * next; struct Link * prev; }; struct CircularList { int size; struct Link* sentinel; }; /** * Allocates the list's sentinel and sets the size to 0. * ...
C
#include <stdio.h> #include <stdlib.h> #include "scanner.h" #include "nodes.h" Node * newEmptyNode(void) { Node *p = malloc(sizeof(Node)); //check for malloc failure omitted p->value = 0; //set to empty p->next = 0; //set to the null pointer return p...
C
#define COL_LIMIT 5 typedef struct message { int timestamp; /*10 digitos*/ int id; /*5*/ int x, y; /*2 digitos cada*/ int vel, dir, sent, tam; /*2, 1, 1, 2*/ } message; typedef struct car { int id; /*5*/ int x, y; /*2 digitos cada*/ int vel, dir, sent, tam; /*2, 1, 1, 2*/ } car; message strtomsg (char...
C
#ifndef __HALF_EDGE_STRUCTURE__ #define __HALF_EDGE_STRUCTURE__ #include <stdlib.h> struct Solid; struct Face; struct Loop; struct HalfEdge; struct Vertex; struct Edge; struct Solid { int id; Face *faces; Edge *edges; Solid *next; Solid *pre; int vnum; int fnum; int lnum; Solid() : id(0), faces(NULL), ...
C
#include <stdio.h> #include <string.h> #include "canserial.h" #include "uart.h" #ifdef CAN_TIMESTAMP #include "timer.h" #endif /* handles a received message, does logging */ int canserial_handle_recv_message(struct can_serial* dev, const can_msg_t* msg) { if(dev->can_log_recv_message) dev->can_log_recv_message(msg...
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 <physic.h> #include <stdio.h> #include <logsystem.h> CID pos_comp_id; CID mass_comp_id; void gravity(Component * _comp) { //a = a - b * deltatime; a-psition, b-massa, deltatime-can I use glfw gettime Mass_comp * mass = (Mass_comp*) _comp; Entity * ent = get_entity(mass->_comp.related_id); Posit...
C
/*Считать с клавиатуры целые чисал min и max. Вывести в строку квадраты всех четных чисел в промежутке от min до max включительно. В указаном промежутке гарантировано существует минимум 1 парное число. Пример ввода 0 7 Пример вывода 0 4 16 36 */ #include <stdio.h> int main() { int min, max; ...
C
/*---------------------------------------------------------------- * @Author: Su * @Description: * @Creath Date: ----------------------------------------------------------------*/ #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { /*const int a = 425; a = 450; //error int b = 450; c...
C
/*--------------------------------------------------------------------------- * filename - creat.c * * function(s) * creat - creates a new file or rewrites an existing one *--------------------------------------------------------------------------*/ /* * C/C++ Run Time Library - Version 10.0 * * ...
C
#include<stdio.h> static long int A[10000000000]; int main() { int t,k; long long int n; long long int f(long long int, int); scanf("%d",&t); while(t--) { scanf("%lld%d",&n,&k); printf("%lld\n",(f(n,k)%1000000007)); } return 0; } long long int f(long long i...
C
/* #include <stdio.h> int main(void) { int a,b,c; scanf("%i %i %i",&a,&b,&c); if (a==b || b==c || a==c){ if (a==1 & b==1 || c==1 & b==1 || a==1 & c==1){ printf("APROVADO COM A\n"); }else{ if (a==2 & b==2 || c==2 & b==2 || a==2 & c==2){ printf("APROVADO COM B\n"); }else{ ...
C
// // Created by q7 on 2019/11/27. // #ifndef C__TEST_REFERENCE_H #define C__TEST_REFERENCE_H int& test(int *p11, int a)//从函数中返回引用 { return p11[a]; } void Reference() { cout << setfill('*') << setw(50) << "Reference:C++引用->从函数中返回引用" << setfill('*') << setw(5) << "*" << endl; int i11[5] = {0, 1, 2, 3, 4}...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* handle_integer.c :+: :+: :+: ...
C
#include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <string.h> void* thread_func(void* thread_params){ printf("i'm thread #%lu\n", pthread_self()); printf("I've got %s\n", (char*)thread_params); pthread_exit((void*)5); } int main(int argc, char* argv[]){ printf("main thread #%lu\n", ...
C
#include <stdint.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char** argv) { uint8_t c1, c2; c1 = getc(stdin); c2 = getc(stdin); uint16_t numblk = c2 << 8 | c1; c1 = getc(stdin); c2 = getc(stdin); uint16_t datalen = c2 << 8 | c1; uint16_t* blk = calloc(numblk, sizeof(uint16_t)); in...
C
#pragma once #include "klib.h" // // A general purpose unicode string object. Storage is UTF-16. // Exposes methods to convert to and from ascii, and // could be extended to support UTF-8 // struct UnicodeString { unsigned short* wcharBuffer; unsigned int wcharBufferLength; unsigned int stringLength; unsign...
C
#define _GNU_SOURCE #include <errno.h> #include <getopt.h> #include <gmp.h> #include <pthread.h> #include <sched.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include "pi-calc.h" #define DEFAULT_DIGITS 1000 #define LAST_DIGITS_PRINT 50 /* Digits per iteration (where is it from?) *...
C
// ******************************************************************* //1) Write a macro for each of the following: // //a) Area of a Circle //b) Area of a Square //c) Area of a Rectangle //d) Area of a Triangle // //You can find formulas and detailed explanations at: http://www.mathisfun.com // ********************...
C
/* ** event.c for wolf3d in /home/benji_epitech/C_Graph_Prog/wolf3d/src ** ** Made by Benjamin Viguier ** Login <benjamin.viguier@epitech.eu> ** ** Started on Mon Dec 26 15:54:58 2016 Benjamin Viguier ** Last update Fri Jan 6 17:17:20 2017 Benjamin Viguier */ #include "wolf.h" const t_event_fct const fct_tab[] ...
C
//########################################################################### // // FILE: can_loopback_interrupts.c // // TITLE: Example to demonstrate basic CAN setup and use. // //! \addtogroup cpu01_example_list //! <h1>CAN External Loopback with Interrupts (can_loopback_interrupts)</h1> //! //! This example, usi...
C
#include <stdio.h> #include <stdlib.h> #include <sys/socket.h> #include <unistd.h> #include <sys/wait.h> #include <sys/select.h> #include <sys/wait.h> #include <sys/time.h> #include <limits.h> #include "model.h" #define PIPE(fd) socketpair(AF_UNIX, SOCK_STREAM, PF_UNIX, fd) char **theMap; int mapWidth, mapHeight; vo...
C
#include <stdio.h>//Biblioteca de funo #include <stdlib.h>//Biblioteca de funo #include <locale.h>//Biblioteca para adicionar acentuao da lngua portuguesa int main() { float litros, valor1, valorf;//declarao de variveis setlocale(LC_ALL, "Portuguese");//comando para adicionar acentuao da lngua portuguesa sy...
C
#include <stdio.h> int main(){ int a,b,c; int cnt=0; scanf("%d %d %d",&a,&b,&c); for(int i = a; i <= b; i++){ int ans; ans = c % i; if(ans == 0){ cnt++; } } printf("%d\n",cnt); }
C
#ifndef KCODE_THREAD_QUEUE_H #define KCODE_THREAD_QUEUE_H #include <sys/types.h> // size_t #include <pthread.h> struct thr_queue_s; typedef struct thr_queue_s *thr_queue_t; int thr_queue_create(thr_queue_t *q, size_t max_size); // 0, ok; -1, fail void thr_queue_destroy(thr_queue_t *q...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* free.c :+: :+: :+: ...
C
//https://leetcode.com/problems/queue-reconstruction-by-height/ /* Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person and k is the number of people in front of this person who have a height greater than or equal to h. ...
C
#include <stdlib.h> #include <stdio.h> /** * main - prints combinations of two different digits, not equal * * Return: Returns 0 */ int main(void) { int i = 48; int a; while (i < 57) { a = i; while (a <= 57) { if (i != a) { putchar(i); putchar(a); if (i != 56) { putchar(44); putchar(32); } ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "foldl.h" int read1(char s[]) { return s[0] - '0'; } int main(int argc, char *argv[]) { char c = '\0'; Op op = NULL; int x0 = 0; int n = argc - 2; int xs[100]; int i = 0; if (n < 0) exit(1); if (!strcmp(argv[1], "sum")) { x0 = 0; c = '+'; op = ...
C
#include<stdio.h> int main() { int n,m,a[100],i; while(~scanf("%d",&n)) { m=0; for(i=0;i<n;i++) { scanf("%d",&a[i]); } for(i=1;i<n-1;i++) { if(a[i]>a[i-1]&&a[i]>a[i+1]) m++; } printf("%d\n",m); } }
C
/* vi:set ts=8 sts=4 sw=4 noet: * * state_machine */ /* * Manage current input state */ #include "vim.h" sm_T *sm_get_current() { return state_current; } int sm_get_current_mode() { return state_current->mode; } int no_pending_operator(void *ctx, pendingOp_T *cmdarg) { return FALSE; } subMode_T sm_get_curr...
C
/* * ex0416.c * Verify the limitation of Unix/Linux about depths of the directories. * We create a directory with long name and then chdir into that * directory and create a long-name directory and enter that again, and so * forth. * Then we use some tools to retrieve the full path: getcwd, tar and cpio. * The ...
C
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> typedef struct { int chave; } REGISTRO; typedef struct { REGISTRO A[10]; int nelem; } LISTA; void inicl(LISTA* l){ l->nelem = 0; } void exibirL(LISTA l){ for(int i = 0; i<l.nelem;i++){ printf("%i \n", l....
C
//############################################################################# //! \file reference/C/source/$FILENAME$ //! \brief Division: signed (64-bit) / signed (64-bit) //! \author Vishal Coelho (adapted from original by Prasanth V.) //! \date 12-Apr-2016 //! // // Group: C2000 // Target Family...
C
#include "btree.h" /* word frequency count */ main() { struct tnode *root; char word[MAXWORD]; struct outarray O[MAXWORD]; int len = 0, i; root = NULL; while (getword(word, MAXWORD) != EOF) if (isalpha(word[0])) root = addtree(root, word); getcounts(root, O, &len); sort(O, len); for (i = 0...
C
#include<stdio.h> int main() { int n1,n2,n3,n; scanf("%d %d %d",&n1,&n2,&n3); if(n1 > n2) n = n1; else n = n2; if(n > n3) printf("%d",n); else printf("%d",n3); }
C
#include <stdio.h> int WordLen(void); int Inverse(void); int MaxASCII(void); int main(void){ int opt=0; printf("1.length of word \n2.word inverse \n3.max ASCIInum \nenter a number : "); scanf("%d", &opt); switch(opt){ case 1 : WordLen(); break; case 2 : Inverse(); break; case 3...
C
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <unistd.h> #include <time.h> #include <sys/time.h> #include <math.h> #define TRUE 1 #define FALSE 0 #define EMPTY 0 #define PIRATE 1 #define NINJA 2 int room_state; // current state of the room, one of the three values above int num_pirates_waiti...
C
/* * --- Module Description --------------------------------------------------- * */ /** * \file os.c * \author Artem Yushev * \date $Date$ * \version $Version$ * * \brief WIN implementation for os.h functions. */ /* * --- Includes ------------------------------------------------------------- * */ ...
C
#include "Sorter.h" #include "mergesort.c" /* global variable to keep track of IP addresses */ List *IPList; /* global variable to keep track of process ID */ int processID; List *newList() { List *list = malloc(sizeof(List)); if (list == NULL) { printf("Unable to allocate mem...
C
#include <stdio.h> #include <string.h> #define MAX_STACK 100 typedef enum { false, true } bool; typedef struct { char palin[MAX_STACK]; int top; } Stack; void initStack(Stack* pstack); bool isFull(Stack* pstack); bool isEmpty(Stack* pstack); char Peek(Stack* pstack); void Push(Stack* pstack, char c); void Pop(S...
C
/* * Copyright (c) 2016 Sugizaki Yukimasa * All rights reserved. * * This software is licensed under a Modified (3-Clause) BSD License. * You should have received a copy of this license along with this * software. If not, contact the copyright holder above. */ #include <stdio.h> #include <stdlib.h> #include <st...
C
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <time.h> // Number of vertices in the graph #define N 6 // Structure to define Graph struct Graph { struct Node* head[N]; }; // Structure to define vertices struct Node { int destination; struct Node* next; }; // Structure to define t...
C
int findLengthOfLCIS(int* nums, int numsSize){ if (numsSize <= 1) return numsSize; int cnt = INT_MIN; int tmp = 1; for (int i = 0; i < (numsSize-1); i++) { if (nums[i+1] <= nums[i]) { tmp = 1; } else { tmp++; } cnt = (cnt > tmp) ? cnt : tmp;...
C
#include <stdio.h> int main() { int first, second, third, eq_result; scanf("%d%d%d", &first, &second, &third); eq_result = Mathpower(first, second); if(eq_result == third) printf("1"); else printf("0"); return 0; } int Mathpower(int firstp, int secondp) ...
C
/* * string::find_last_of requires memchr and it's implemented in libc. * libc is too big to be loaded in ESP RAM thus one of solutions is to just * copypaste it here. * * More details here: * https://github.com/pfalcon/esp-open-sdk/issues/213 */ void* memchr(const void* s, unsigned char c, int n) { ...
C
// server program for udp connection #include <stdio.h> #include <strings.h> #include <sys/types.h> #include <arpa/inet.h> #include <sys/socket.h> #include<netinet/in.h> #define PORT 5000 #define MAXLINE 1000 char *rev(char *s) { int size = strlen(s); char* out = malloc(size); int x = size-1; //Will rever...
C
#include <stdio.h> #include <string.h> #include <errno.h> #include <stdlib.h> #include <unistd.h> #include <signal.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/ip.h> #include <arpa/inet.h> #define DEFAULT_PORT 8888 #define BACKLOG 5 #define BUF_SIZE 128 static int send_str(int sock, const char ...
C
#include "common.h" static apr_pool_t *test_pool; static gla_store_t *test_store; static gla_entityreg_t *test_self; /********************************** TEST 1 ************************************/ #include "src/regex.h" static int test1_init() { int ret; ret = apr_pool_create(&test_pool, NULL); if(ret != APR_S...
C
/* * lock_file.c * 对文件上锁,用于测试server中接受client发送的文件时,重改名的问题 * 若文件上锁,则server接受到文件并保存为临时文件(rsa_key.conf.tm),并等待文件解锁;当文件解锁后,将临时文件重命名为所需的文件名(rsa_key.conf) * Created on: 2014-8-29 * Author: wzb */ #include <sys/file.h> #include <stdio.h> #include <stdlib.h> int main() { FILE *f = fopen("rsa_key.conf", "r"); i...