language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
// Patrick Musau // 09-2020 // Header file for safety checking of wall points #ifndef BICYCLE_SAFETY_H_ #define BICYCLE_SAFETY_H_ #include <stdio.h> #include <stdbool.h> #include <string.h> #include <stdlib.h> #include <sys/time.h> #include "geometry.h" // array that will store the points describing the wall // nu...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> struct tsk_node_s{ int task_num; //starting from 0 and increase one by one int task_type; // insert:0, delete:1, search:2 int value; struct tsk_node_s* next; }; struct lst_node_s { int data; struct lst_node_s* next; }; // Two glboal variables to sto...
C
#pragma once typedef enum { CS_PQ_LOWEST_PRIORITY, /* lowest key have highest priorit */ CS_PQ_HIGHEST_PRIORITY /* highest key have highest priorit */ } cs_pqueue_mode_t; typedef struct cs_pqnode cs_pqnode_t; typedef struct cs_pqueue cs_pqueue_t; struct cs_pqnode { int priority; char* value; cs_pqnode_t* pare...
C
/* hw13_13.c */ #include <stdio.h> #include <stdlib.h> #include "c:\prog\volume2.h" #include "c:\prog\area2.h" int main(void) { printf("CIRCLE(1.0)=%5.2f\n",CIRCLE(1.0)); printf("SPHERE(1.0)=%5.2f\n",SPHERE(1.0)); system("pause"); return 0; } /* output---------- CIRCLE(1.0)= 3.14 SPHERE(1.0)= 4.19 ...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> #include<limits.h> int min(int a,int b){return a<b?a:b;} int max(int a,int b){return a>b?a:b;} int cmp (const void * a, const void * b) { return ( *(int*)a - *(int*)b ); } int main() { int N; scanf("%d", &N); int v[N]; for...
C
/* Copyright 2013-2014 Dietrich Epp. This file is part of SGLib. SGLib is licensed under the terms of the 2-clause BSD license. For more information, see LICENSE.txt. */ #include "sg/defs.h" /* A note about timestamps: The input timestamps are floating point seconds, and the output timestamps are signed int...
C
#include <stdio.h> #include <stdlib.h> double saving_plan(double initial, double payments, double debit_ann_rate, double credit_ann_rate, int years); int main(int argc, char **argv){ double initial, payments, debit_ann_rate, credit_ann_rate, balance; int years; printf("Enter initial balance :"); scanf("%...
C
#include <stdio.h> #include <stdlib.h> #include "chaine.h" void init_chaine (struct chaine* c) { init_liste_caractere (&c->L); } void clear_chaine (struct chaine* c) { clear_liste_caractere (&c->L); } /* * Affecte à *c la chaîne de caractères s, qui est au format f */ void set_chaine_string (struct chaine...
C
#include "test.h" #include "widget.h" extern int _mgos_timers; static void test_widget_default_ev(int ev, struct widget_t *w, void *ev_data) { char evname[15]; if (!w) return; widget_ev_to_str(ev, evname, sizeof(evname)-1); LOG(LL_INFO, ("Event %s received for widget '%s'", evname, w->name)); switch...
C
#include <stdio.h> #include <stdlib.h> int la_somme(int a, int b); int main() { int nombre_1,nombre_2; printf(" BONJOUR LES ZOZOS COMMENT VOUS ALLEZ!\n"); printf("entrer le premier nombre : "); scanf("%d",&nombre_1); printf("entrer le deuxieme nombre : "); scanf("%d",&nombre_2); printf(" la ...
C
/******************************************************************************* * Course: C Intermediate Programming * * * * Program Name: Assignment7A.c ...
C
#include <string.h> //文字列中の語の数をcountする関数 //「語」の定義は空白で区切られていること int count_word(char str[]){ int i; int whitespace_count = 0; for(i = 0; i < strlen(str); i++){ if(str[i] == ' ') whitespace_count++; } return whitespace_count + 1; }
C
/* range.h - ranges of integer or float values */ #ifndef _RANGE_H #define _RANGE_H /* We'll allow multiple ranges and/or individual values. */ typedef struct _range { int min, max; } Range; typedef struct _rangelist { int nranges; Range ranges[0]; } Rangelist; /* For the sake of definiteness, have some sort of ...
C
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <semaphore.h> #include <unistd.h> #define MAXWORKERS 64 void *parentBird(void *); void *babyBird(void *); sem_t busy, empty; int W = 5; int dish; int main(int argc, char *argv[]) { pthread_t pid, bid[MAXWORKERS]; int numBirds; numBirds = (...
C
#include <stdio.h> int main(){ int lista[100002]; int turma, i, valor, aux=1, j; int total=0; scanf("%d", &turma); for(i=0; i<turma; i++){ scanf("%d", &valor); lista[i] = valor; for(aux=1, j=i-1; j>=0; j--){ if(valor == lista[j]){ au...
C
#ifndef LASER_UTILS #define LASER_UTILS static void hsbToRgb(GLfloat *hsb, GLfloat *rgb) { if ( hsb[1] == 0.0 ) { rgb[0] = hsb[2]; rgb[1] = hsb[2]; rgb[2] = hsb[2]; } else { float var_h = hsb[0] * 6; float var_i = floor( var_h ) ; //O...
C
#include<stdio.h> int n1, n2, p1, p2; int i, j, k; int x[100]; int h[100]; int y[100]; int xo[100]; int ho[100]; int yo[100]; void restarts() { int i = 0; for (; i < 100; i++) { x[i] = xo[i]; y[i] = 0; h[i] = ho[i]; } } void linearcircular() { int k; int m = n1 + n2 - 1; k = m - n1; ...
C
#ifndef __BIT_OPERATOR_H__ #define __BIT_OPERATOR_H__ #define bit(m) (1<<(m)) //returns an integer with the m'th bit set to 1 #define bit_set(p,m) ((p)|= bit(m)) //p= p | bit(m),sets the mth bit of p to 1 #define bit_clear(p,m) ((p)&=~(bit(m))) //p= p & ~(bit(m)) sets the mth bit of p to 0 #define bit_check(p,m) ((...
C
/////////////////////////////////////////////////////////////////////// // // Accept N numbers from user check whether that numbers contains 11 in // it or not. // Input : N : 6 // Elements : 85 66 11 80 93 88 // Output : 11 is present // Input : N : 6 // Elements : 85 66 3 80 93 88 // ...
C
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <math.h> #include <omp.h> #include "queue.h" #define log2(x) ((int) (log(x) / log(2))) #define getlevels(nthreads) log2(nthreads) #define BARR_ITER 4.0 enum {FALSE, TRUE}; struct tnode *createnode(); struct tnode *createtree(int levels, struct tn...
C
#include <pthread.h> #include <stdio.h> #include <stdbool.h> #include <errno.h> #include <sys/mman.h> // CONFIGS static int create_thread(pthread_t* thread, void* (func)(), int sched, int prio) { pthread_attr_t attr; struct sched_param param = {prio}; pthread_attr_init(&attr); pthread_attr_setinherits...
C
/* #include <iostream> */ /* #include <random> */ #include <stdio.h> #include <stdlib.h> #define N 10000000 /* using namespace std; */ /* std::random_device seed_gen; */ /* std::mt19937 engine(seed_gen()); */ unsigned int xorshift(); int random_integer(int); int main() { int dian, diaboxn; int select[4]; ...
C
#include<stdio.h> #include<string.h> int main () { char a[] ="Just some random string"; char * ptr_b; ptr_b = strstr (a,"other some random"); if(ptr_b != NULL) { printf("found\n"); } else { printf("not found \n"); } return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> void error(const char *msg) { perror(msg); exit(0); } int main(int argc, char *argv[]) { int sockfd, portno, n; struct sockaddr_in se...
C
#include<stdio.h> static int test_pix_sum_c(unsigned char * pix, int line_size) { int s, i, j; s = 0; for (i = 0; i < 16; i++) { for (j = 0; j < 16; j += 8) { s += pix[0]; s += pix[1]; s += pix[2]; s += pix[3]; s += pix[4]; s +...
C
#include <glu3.h> #include <assert.h> static GLboolean vec4_equals(const GLUvec4 *a, const GLUvec4 *b) { int i; for (i = 0; i < 4; i++) { if (a->values[i] != b->values[i]) return GL_FALSE; } return GL_TRUE; } static void vec4_divide(GLUvec4 *a) { a->values[0] /= a->values[3]; a->values[1] /= a->values[3];...
C
// testTransmissionAmts.c #include <assert.h> #include <stdio.h> #include <stdlib.h> #include "Graph.h" void calculateViralTransmission(Graph g, int src, int srcViralLoad, double *trasmissionArray); int main(void) { int nV; if (scanf("nV: %d ", &nV) != 1) { printf("er...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #include <signal.h> void handler(int signum, siginfo_t *info, void *extra) { void *ptr_val = info->si_value.sival_ptr; int int_val = info->si_value.sival_int; printf("Sum=...
C
#include<stdio.h> #include<conio.h> main() { int i, j, k, f, pf=0, count=0, rs[25], m[10], n; clrscr(); printf("\n Enter the length of reference string -- "); scanf("%d",&n); printf("\n Enter the reference string -- "); ...
C
double judge(int t){ if( t > 0 ){ return 1.0; }else if( t < 0){ return -1.0; }else{ return 0.0; } } void sign(double* x, double* y, int m){ int i; int a = m >> 2; int b = a << 2; for(i = 0;i < b; i+=4){ y[i] = judge(x[i]); y[i+1] =...
C
#include "holberton.h" /** * _pali - Checks for palindrome. * @len: Lenght of string. * @s1: Target string. * @i: 0, Init of string. * * Return: 1 if palindrome, 0 otherwise. */ int _pali(int len, char *s1, int i) { if (s1[i] == s1[len - 1]) { _pali((len - 1), s1, i + 1); return (1); } else if (s1[i] != ...
C
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> int main() { int n, a[100], *ptr = a, x; scanf("%d", &n); for (int i = 0; i<n; i++) { scanf("%d", ptr); ptr++; } ptr = a; scanf("%d", &x); int *x_ptr = &x; for (int i = 0; i<n; i++) { if (*ptr == *x_ptr) { pri...
C
#include <stdio.h> main() { int startH,startM,endH,endM,resultH,resultM; scanf("%d%d%d%d",&startH,&startM,&endH,&endM); resultH=endH-startH; if(resultH<0){ resultH=24+resultH; } resultM=endM-startM; if(resultM<0){ resultM=60+resultM; resultH--; } if(startH==en...
C
#include <math.h> #include <stdio.h> double maxim(double a, double b) { if (a > b) { return a; } else { return b; } } double absol(double a) { if (a >= 0) { return a; } else { return -a; } } int main(void) { double x, mx, x3, max; printf("Input x: "); scanf("%lf", &x); x3 = x * x ...
C
#include<stdio.h> #include<math.h> void main() { int base,power,result; printf("Entr base: "); scanf("%d", &base); printf("Entr power: "); scanf("%d", &power); result = pow(base,power); //pow function use get power result value printf("Result is : %d",result); }
C
/* * See Copyright Notice in qnode.h */ #include <stdio.h> #include <stdlib.h> #include <time.h> #include "qassert.h" #include "qengine.h" #include "qlog.h" #include "qmempool.h" #include "qthread_log.h" #define QRETIRED_FD -1 extern const struct qdispatcher_t epoll_dispatcher; static void init_qevent(qevent_t *e...
C
#include "mbed.h" #include <stdarg.h> #ifndef DEBUG_H_ #define DEBUG_H_ // Prints to a serial port. Max string size is 255. void inline print_serial(Serial* serial, const char* format, ...) { char buffer[256]; va_list args; va_start (args, format); vsprintf(buffer, format, args); buffer[255] = '\0'; //Ensure th...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> #include <string.h> #include <signal.h> #define BUFSIZE 512 int fifofd; char* fifoname; void sig_handler (int sig); int main (int argc, char *argv[]) { if (argc != 3) { ...
C
// 210603 // 1100-2.c - 더하기 사이클 sol 2 (Short solution) #include <stdio.h> int main() { int N, num1, cnt; // printf("enter num1: "); scanf("%d", &N); num1 = N; cnt = 0; while(1){ // printf("start while\n"); num1 = num1%10*10 + (num1/10 + num1%10)%10; cnt ++; /...
C
#include <stdio.h> #include <time.h> #include <stdlib.h> typedef struct { // ʵ int id; int primeNumber; int arrival_time[2]; int service_time; }element; typedef struct Atmqueue{// ATM element data; struct Atmqueue* link; }Atm; typedef struct { // ũ忡ƼŸ ťŸ Atm* front, * rear; int leng, service_time; int ...
C
///////////////////////////////////////////////////////////////////////////// // // (c) Copyright 2000-2016 CodeMachine Incorporated. All rights Reserved. // Developed by CodeMachine Incorporated. (http://www.codemachine.com) // ///////////////////////////////////////////////////////////////////////////// #include "nt...
C
#include <stdio.h> /* for puts, */ #include <stdlib.h> /* for malloc */ #include <assert.h> /* for assert */ #include <string.h> /* for strcmp */ #include "bst.h" int bstDoCheck = 1; #define doCheck(_bst) (bstDoCheck) /* create a new bst */ BST *BSTAlloc() { BST *bst = (BST *)malloc(sizeof(BST))...
C
/* Lista enlazada */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <locale.h> #include <stdbool.h> typedef char tString[30]; typedef struct { tString fecha; int codigoLoc; int postivosPorDia; }tDatos; typedef struct nodo { tDatos datosCovid; struct nodo * siguiente; } tListaCovid; void inicial...
C
/* * Functions etc pertaining to 3d triangle creation. */ #ifndef TRIANGLE3D_H #define TRIANGLE3D_H #include<stdio.h> #include "../common/common.h" #include "../line/line.h" #include "triangle2d.h" /* * Create 3d triangle -- get points in/on a 3d triangle. * Input -- the 3 corners of a triangle * a l...
C
#include<stdio.h> int a,b,resultado; int i=1; int main() { int a,b,resultado; int i=1; printf("INGRESE EL PRIMER DIGITO\n"); scanf("%d",&a); printf("INGRESE EL SEGUNDO DIGITO\n"); scanf("%d",&b); while(i<=a){ resultado=resultado+b; i=i+1; } printf("EL RESULTADO ES\n %d",resultado); }
C
#include "item.h" void construct_item(Item **item, char *name, char *description, char *feedback_on_use, short effect_type, short effect_value) { *item = malloc(sizeof(Item)); // Won't need to type (*item) four times Item *i = *item; i->name = name; i->description = description; i->feedback_o...
C
// // simplest_rgb24_split.c // simplest_rgb24_split // // Created by angle on 21/03/2018. // Copyright © 2018 angle. All rights reserved. // #include <stdio.h> //add #include <stdlib.h> #include <string.h> /** Splicing string exp: splicingString_f("123","456") out:"123456" @param string_1 string on the ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* tools2.c :+: :+: :+: ...
C
#include <stdio.h> int main(int argc, char** argv) { int sum = 0; for (int i = 0; i < 1001; i++) { if (i % 3 == 0 || i % 5 == 0) { sum += i; } } printf("The sum: %i\n", sum); return 0; }
C
#include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> struct alarm { int seconds; char message[64]; }; void *alarm_thread(struct alarm *a) { int status = pthread_detach(pthread_self()); if (status != 0) { fprintf(stderr, "pthread_detach: %s\n", strerror(status)); ...
C
#include "crypt_helper.h" #include "aes_vector.h" global_variable u8 GlobalScratch[AES_TEST_MAX_MSG_SIZE]; internal b32 AesVectorsPass(aes_test_vector *TestVector, u32 VectorCount) { Stopif(TestVector == 0, "Null input to TestAesVectors"); b32 Result = true; for (u32 TestVecIndex = 0; TestVecIndex < VectorCount...
C
// // main.c // 8.2 // // Created by 林斌 on 2017/6/12. // Copyright © 2017年 林斌. All rights reserved. // #include<stdio.h> #include<stdlib.h> int main(void) { char c = 0; int flag = 0; int count = 0; FILE* file_name = fopen("D:\\abc2.txt", "w"); //fputc(c, stdout); while ((c = getchar()) != E...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "../include/radixHashJoin.h" //Create new node to add to list resultNode * createNode() { resultNode * newNode; if ((newNode = malloc(sizeof(resultNode))) == NULL) { return NULL; } //initialize newNode newNode->next = NULL...
C
// $Id: raw2hist.C 3406 2015-06-26 06:13:58Z onuchin $ // Author: Valeriy Onuchin 28.07.2011 /************************************************************************* * * * Copyright (C) 2011, Valeriy Onuchin *...
C
/************************************************************************************************ *Define la estructura y funciones asociadas para un Nodo a ser utilizado en listas encadenadas * *Un nodo esta formado por : * *- info : la inf...
C
#include "config.h" #include <gem.h> #include <time.h> #include "debug.h" /* 1024 entries, means at least 8 KB, plus 8 bytes per string, * plus the lengths of strings */ #define TH_BITS 10 #define TH_SIZE (1 << TH_BITS) #define TH_MASK (TH_SIZE - 1) #define TH_BMASK ((1 << (16 - TH_BITS)) - 1) /* * set this to o...
C
#include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #define EXEC_PATH "./ex3" int main(int argc, char *argv[]) { pid_t id = fork(); if (id == 0) { /* Child process executes command */ /* Memory allocation for the arguments */ char ...
C
#include <stdio.h> #include <strings.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <pthread.h> #include <stdlib.h> #define PORT 1234 #define BACKLOG 1 #define Max 5 //設定連線人數上限 #de...
C
#include "gpio.h" #define RPI_GPIO_OUT 21 #define RPI_GPIO_IN 4 #include <unistd.h> //sleep(); int main(void) { gpio my_read = gpio_init(RPI_GPIO_IN,"in"); gpio my_led = gpio_init(RPI_GPIO_OUT,"out"); printf("%i",gpio_get_value(my_read)); sleep(1); gpio_set_value(my_led, 1); sleep(1); printf("%i"...
C
/* * File: main.c * Author: JBurnworth * * Created on December 17, 2014, 3:21 PM *----------------------------------------------------------------------- * This project mounts an SD Card with Fat Formating and looks for wav * files in the root directory. It will try to play those files using * functions in ...
C
#include <stdio.h> #include <ctype.h> #include <string.h> #include <locale.h> int main() { // Variaveis para armazenar o tamanho de cada frase e o nome const char *nomeArquivo = "./frases.txt"; char frases[5][50]; char buffer[50]; int fraseAtual = 0; // Abre o arquivo em modo de escrita+ FILE *arquivo...
C
#include <stdio.h> int main() { char c=-1; int i=-1; printf("c=%u, i=%u \n", c,i); return 0; }
C
/* print square roots in C language. R. Brown, 9/2010 */ #include <stdio.h> #include <math.h> #include <stdlib.h> int main(int argc,char **argv) { int n; int max; printf("sqrt(n)\n--------\n"); max = atoi(argv[1]); for (n=0; n<=max; n++) printf("%f\n", sqrt(n)); return 0; }
C
#include "menu.h" //Créer un menu menu_t* createMenu(const char* text){ menu_t* menu = malloc(sizeof(menu_t)); menu->pere = NULL; menu->k = 0; char* desc = malloc(strlen(text)+1); strcpy(desc,text); menu->description = desc; return menu; } //Ajoute une action à un menu void addMenuAction(menu_t* m, const...
C
/* ** EPITECH PROJECT, 2018 ** Malloc ** File description: ** realign_size.c */ #include <unistd.h> size_t realign_size(size_t size) { if (size > 0 && size % 4 != 0) size += 4 - (size % 4); return (size); }
C
#include "scope.h" t_scope* init_scope() { t_scope* scope = (t_scope *)calloc(1, sizeof(t_scope)); scope->function_definitions = 0; scope->function_definitions_size = 0; scope->variable_definitions = 0; scope->variable_definitions_size = 0; return scope; } t_ast* scope_add_function_definition(t_scope* scop...
C
#include "Texture.h" #include <assert.h> void CreateTexture(DeccanTexture *texture, int32_t width, int32_t height, int format, sg_image_content *image_content) { texture->width = width; texture->height = height; texture->pixel_format = format; sg_image_desc desc = { .width = texture->width, ...
C
int mandel(float x, float y, int max_iters, unsigned char * val); typedef struct _Img{ int width; int height; unsigned char * data; } Img; void create_fractal(Img img, int iters) { float pixel_size_x = 3.0 / img.width; float pixel_size_y = 2.0 / img.height; for (int y=0; y < img.height; y++)...
C
#ifndef __CORE_PRIMITIVES_H_ #define __CORE_PRIMITIVES_H_ struct RAY { RAY() { this->origin = VEC4(0.0f, 0.0f, 0.0f, 1.0f); this->direction = VEC3(0.0f, 0.0f, 0.0f); this->color = COLOR(0.0f, 0.0f, 0.0f, 1.0f); this->length = 0.0f; } RAY(VEC4& position, VEC3& direction) { this->origin = position; this...
C
#include <stdio.h> #include "cdg.h" #define MAX_NODES 500 CDGNode* nodes[MAX_NODES] = {NULL}; //Holds all the nodes in the tree CDGNode* root = NULL; void preOrderCDG(CDGNode*); void addtoCDGnode(int , int , int); void setArray(); void printArray(); // branch variable tell on which branch of parent the node is to ...
C
/** * water.c * * Lizzie Eng * * CONDITIONS * (1) Input (minutes) must be a positive integers * (2) If Input = positive int, output must reflect input in bottles of water * (3) Else prompt user to "Retry" */ #include <stdio.h> #include <cs50.h> int GetPositiveInt(); int main(void) { int b = 16; // bottles of w...
C
#include<stdio.h> int main() { int tc,e,f,c,l,t,count,i; scanf("%d",&tc); for(i=1;i<=tc;i++) { count=0; scanf("%d %d %d",&e,&f,&c); l=e+f; while(1) { t=l-c+1; l=t; if(l<=0) break; count++; } ...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include "utils/vec.h" #include "utils/math.h" #include "utils/utils.h" #include "d3v/d3v.h" #include "d3v/object.h" #include "display/animator.h" #define MAX_ANIMATION_STEP 20 /** * Description d'une animation. */ typedef struct animation_step { struc...
C
/******************************************************************************* * Ver 15.02.04 *******************************************************************************/ #include <string.h> #include <stdarg.h> #include <stdlib.h> #include "Parser.h" void reverse(char s[]); /* itoa: n s *...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #include "chain.h" #include "utils.h" int *build_dimensions(const int n) { int *dims = (int *)malloc(sizeof(int) * (n + 1)); for (size_t i = 0; i < n + 1; i++) { dims[i] = rand() % 600; } return dims; } float ***build_problem_instance(const int *...
C
/* * Copyright (c) 2017 RnDity Sp. z o.o. * * SPDX-License-Identifier: Apache-2.0 */ #include <zephyr.h> #include <watchdog.h> #include <misc/printk.h> /* * The independent watchdog (IWDG) is clocked by its own dedicated * 40kHz (STM32F1X or STM32F3X) or 32kHz (STM32F4X or STM32L4X) * low-speed internal clock ...
C
#include <stdio.h> #include <stdlib.h> int main(void) { { int a = rand()%20; int isDivisibleByAny = 0; int numbers[] = {2, 3, 5, 7, 11, 13, 17, 19}; for (int i = 0; i <= 7; ++i) { switch(a % numbers[i]) { case 0: printf("%d is divisi...
C
// Welch, Wright, & Morrow, // Real-time Digital Signal Processing, 2017 /////////////////////////////////////////////////////////////////////// // Filename: ISRs.c // // Synopsis: Interrupt service routine for codec data transmit/receive // ////////////////////////////////////////////////////////////////////...
C
#include <stdio.h> /* Include other headers as needed */ int firstOccurence(int a[],int l,int r,int key) { if(l<r) { int mid=l+(r-l)/2; if(a[mid]>=key) { r=mid; return firstOccurence(a,l,r,key); } else { l=mid+1; return firstOccurence(a,l,r,key); } } return l;...
C
/* * & defines the address of * * dereferences/declares ptr * ** dereferences/declares ptr2ptr */ #include<stdio.h> int main(int argc,char** argv){ { int a=8; int *b=&a; int **c=&b; fprintf(stdout,"%d\n",a); fprintf(stdout,"%d\n",*b); fprintf(stdout,"%d\n",**c); } { char *a="0123456789abcdef"; ch...
C
#include "tables.h" #include "storage_mgr.h" #include "record_mgr.h" #include "buffer_mgr.h" #include <string.h> #include <stdlib.h> #include <math.h> #define META_PAGENO 0 // Page reserved for metadata #define MAX_ATTRNAME_LEN 30 //Maximum length of the attribute name #define BUFFER_FRAME_SIZE 10 // Size of...
C
#include <iostream> //class A; template <class T> class base { public: //T Tval_; //This is wrong T * pt(){return static_cast<T*>(this);}//static_cast<T*>(this); int baseVal_; base() { baseVal_ = 99; std::cout << "This is in base(), baseVal_ = " << baseVal_ << std::endl; pt...
C
// tjadanel - C Programming 2nd Ed. // Chapter 6 - Program Exercise 6.12 // This program #include <stdio.h> int main(void) { float n, e = 1.0f; printf("Enter a small floating point number: "); scanf("%f", &n); int term = 1, factorial = 1; for (;;) { factorial *= term; if (1.0f ...
C
#include "../HEADER/header.h" void swap(long *a, long *b) { long temp; temp = *a; *a = *b; *b = temp; }
C
#include <stdio.h> #include <stdlib.h> int even(int n) { if (n % 2 == 0) return 1; else if (n % 2 == 1) return 0; } int absolute(int n) { return abs(n); } int sign(int n) { if (n < 0) return -1; else if (n > 0) return 1; else return 0; } int main() { int num; int a, b, c; printf(" ԷϽÿ: "); scanf...
C
#ifndef __SCHEDULER_H__ #define __SCHEDULER_H__ //------ Loop 1 ------- // Initialize a "loop" to run every X milliseconds // Sets up a variable to hold time of last run // Must be called outside of the infinite loop #define INIT_LOOP_1_FREQUENCY(X) \ unsigned long lastRun1 = 0; // Start of code to run every X ...
C
#include "holberton.h" /** *read_textfile - Reads a text file and prints it to the POSIX standard output. *@filename: Name of the file to read. *@letters: Letters to print. *Return: Number of letters could read-print. 0 if file cannot opened or NULL. */ ssize_t read_textfile(const char *filename, size_t letters) {...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include "wavetype.h" #include "exception.h" typedef struct TriangleFilter { int l; int c; int h; float step1; float step2; }TriangleFilter; #define TRAINGLE_PARA(low,med,high,para) {\ para.c = med;\ \ if(low==med)\ ...
C
/* Copyright 2017 Federico Cerisola */ /* MIT License (see root directory) */ /* see header file for detailed documentation of each function */ #include <stdlib.h> #include <math.h> double * create_linear_grid(const double xmin, const double xmax, const int npoints, const int round_digits)...
C
#include "trtSettings.h" #include "trtkernel_1284.c" #include <stdio.h> #include <string.h> #include <stdlib.h> #include <avr/sleep.h> // serial communication library // Don't mess with the semaphores #define SEM_RX_ISR_SIGNAL 1 #define SEM_STRING_DONE 2 // user hit <enter> #include "trtUart.h" #include "trtUart.c" #i...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdlib.h> typedef struct { char **arr; int top, max_len; } Stack; int initStack(Stack *); int pushStack(Stack *, char *); char *popStack(Stack *); int emptyStack(Stack *); int destroyStack(Stack *); Stack back_stack; Stack forward_stack;...
C
/*Escola Politecnica * Departamento de Eletronica e de Computacao * EEL270 - Computacao II - Turma: 2014/2 * Prof. Marcelo Luiz Drumond Lanza * * $Author: vitor.schoola $ * $Date: 2015/01/10 19:14:53 $ * $Log: geCgiHelp.c,v $ * Revision 1.1 2015/01/10 19:14:53 vitor.schoola * Initial revision * * */ #in...
C
#include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <time.h> #include <string.h> #include <openssl/sha.h> #include "../devices/sha1.h" #include "../devices/reduction.h" // apt-get install libcurl4-openssl-dev const unsigned int REP = 1000000 ; void test_1(){ unsigned int foo = 1; unsign...
C
#include<stdio.h> int a=0,num=0,other=0; void count(char c[]) /************program************/ int i; for (i=0;a[i]!='\0';i++){ if(a[i]>='a'&&a[i]<='z')||(a[i]>='A'&&a[i]<='z') a++; else if(a[i]>='0'&&a[i]<='9') num++; else if(a[i]='') ...
C
#include <stdio.h> int main() { int N[10],i,x; scanf("%d",&x); for(i=0; i<=9; i++) { printf("N[%d] = %d\n",i,x); x=x*2; } return 0; }
C
#include "lists.h" /** * sum_listint - returns the sum of all the data (n) *of a listint_t linked list. *@head:double pointer to head node. *Return: plus of the nodes */ int sum_listint(listint_t *head) { listint_t *ptr; int cont = 0; if (!(head == NULL)) { ptr = head; while (ptr != NULL) { cont...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> int main(int argc, char** argv) { if(argc != 4) { printf("usage: %s input.grey output.dat rate\n", argv[0]); return -1; } const char* input = argv[1]; const char* output = argv[2]; float rate = atof...
C
#include"touch_screen.h" static int fd_event0 = 0; int open_ts(void) { fd_event0 = open("/dev/input/event0", O_RDWR); if (-1 == fd_event0) { perror("Open /dev/intpu/event0 error!\n"); exit(EXIT_FAILURE); } return 0; } int read_ts(unsigned short *px, unsigned short *py) { struct input_event SIevent; while...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/wait.h> #include <time.h> #include <unistd.h> int spawn_childs(int n) { pid_t pid; int i; for (i = 0; i < n; i++) { pid = fork(); if (pid < 0) return -1; else if (pid == 0...
C
/* File: adc.c Date: Info: datasheet p.150 Functions: -adc_init() -adc_get_sample() Notes: Analog input is on pin 6, RC3/AN7 */ #include <htc.h> #include <adc.h> /* Considerations: -For now using 8 MSBs instead of full 10 bit Process for onfigure for ADC: 1) Port configuration 2) Channel selecti...