language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#ifndef TIME_H #define TIME_H #ifdef __cplusplus extern "C" { #endif #include <stdint.h> #ifndef NULL #define NULL (void*)0 #endif typedef int64_t time_t; typedef uint64_t clock_t; struct tm { int tm_sec; // seconds after the minute [0, 60] int tm_min; // minutes after the hour [0, 59] int tm_hour; // h...
C
/* * ===================================================================================== * * Filename: ftx_vector4f_add_by_return.c * * Description: Function that adds 2 ftx_vector4f (float 4 dimensions vector) and return * the result, the a value is a const pointer to the first vector to add ...
C
#include <gnss/gnss.h> #include <gnss/log.h> bool gnss_nmea_decoder_vtg(struct gnss_nmea_vtg *vtg, char *field, int fid) { bool success = true; union { char type; char unit; gnss_float_t speed; } local; switch(fid) { case 0: /* xxVTG */ break; case 1: /* True Track */ success = gnss_nm...
C
#include <stdio.h> int main(void){ int n,i; printf("Enter a integer(1-100): "); scanf("%d",&n); for (i=1;i*i<=n;i++){ if(i%2==0){ printf("%d\n",i*i); } } return 0; }
C
/* * Let create a server that continuously runs and sends the date and time as soon as * a client connects to it. * * Example 1: * [1] first open two terminals, let call them terminal x and y * (terimanl x) $ ./server * (terimanl y) $ ./client 127.0.0.1 * * Example 2: use hostname command * (terimanl x) $ ....
C
//分治法解最大子数组问题 #include <stdio.h> #include <limits.h> typedef struct result { int low; int high; int sum; }result; result max(result r1, result r2, result r3) { result max = r1; if(r2.sum > max.sum) max = r2; if(r3.sum > max.sum) max = r3; return max; } //寻找跨越中点的最大子数组 result find_max_cross_subarray(int *a,...
C
/*** *fsetpos.c - Contains fsetpos runtime * * Copyright (c) 1987-2000, Microsoft Corporation. All rights reserved. * *Purpose: * Fsetpos sets the file position using an internal value * returned by an earlier fgetpos call. * *Revision History: * 01-16-87 JCR Module created * 04-13-87 JCR Added const to declaration *...
C
#include <stdio.h> #include <stdlib.h> int main() { long length; FILE *fp; fp = fopen("student_rst1.txt","r"); if(fp == NULL){ fprintf(stdout,"File doesn't exist!\n"); exit(1); } fseek(fp,0,SEEK_END); length = ftell(fp); fprintf(stdout,"File size: %ld\n", l...
C
#include <linux/module.h> // declare module_init() and module_exit() #include <linux/fs.h> // define func to register and unregister device number #include <linux/device.h> // define func to create and ddestroy device file #include <linux/cdev.h> // #include <linux/slab.h> // allocate memory in kern...
C
#include <linux/string.h> #include <linux/init.h> #include <linux/linkage.h> #include <linux/moduleloader.h> #include <linux/fs.h> #include <asm/uaccess.h> #include <linux/slab.h> #include <linux/ctype.h> #include <linux/kthread.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/module.h> #include <...
C
#include "tree.h" //Trees - creation and pruning int main(int argc, char *argv[]) { Node *node; Node *mono; Node *topnode; char **nodestr; char **monostr; nodestr = (char **)malloc(sizeof(char *)); monostr = (char **)malloc(sizeof(char *)); *nodestr = NULL; *monostr = NULL; node = read_Tree(...
C
#include "papi_multiplex_test.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> //global values for counters long long *counter_values; int *testEvent; char **testEventname; int eventSet; int NUM_EVENTS; PAPI_MPX_attr attr; FILE *fout; struct timespec start, end; int overflow_cycle[]={...
C
#ifndef _H_SIMPLEC_SCHEAD #define _H_SIMPLEC_SCHEAD #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <errno.h> #include <string.h> #include <time.h> #include <stdint.h> #include <stddef.h> /* * 1.0 错误定义宏 用于判断返回值状态的状态码 _RF表示返回标志 * 使用举例 : int flag = scconf_get("pursue"); if...
C
/* Dev Patel */ /* Prototype to test using linked list functions using function pointers from last prototype */ #include <stdio.h> #include <stdlib.h> #include "linkedlist.h" #define TEXT 1 /* Prints an integer (action)*/ void printNum(void *data) { printf("Data: %d\n", *(int *)data); } /* Prints an integer and ...
C
#include "fecha.h" int valida_fecha(const t_fecha * f) { if (f->a >= 1600) if (f->m >= 1 && f->m <= 12) if (f->d >= 1 && f->d <= cant_dias_mes(f->m, f->a)) return FECHA_VALIDA; return FECHA_INVALIDA; } int cant_dias_mes(int m, int a) { int dm[] = {31, 28, 31, 30, 31, 3...
C
int f1(int x); int f2(int x); int f1(int x){ return x + f2(x); } int f2(int x){ if(x <= 0){ return 0; } else{ return f1(x-1); } } int fmain(){ return f1(5); }
C
/* <p>Alice has a <code>hand</code> of cards, given as an array of integers.</p> <p>Now she wants to rearrange the cards into groups so that each group is size <code>W</code>, and consists of <code>W</code> consecutive cards.</p> <p>Return <code>true</code> if and only if she can.</p> <p>&nbsp;</p> <ol> </ol> <p><...
C
统计从键盘输入的若干个字符中有效字符的个数,以换行符作为输入结束。有效字符是指第一个空格符前面的字符,若输入字符中没有空格符,则有效字符为除了换行符之外的所有字符。 #include <stdio.h> int main() { char ch; int count=0; //注意这里 while((ch = getchar())!='\n') { if(ch==' ')break; count++; } printf("输入的若干个字符中有效字符的个数:%d\n",count); return 0; }
C
#include <stdio.h> #include <unistd.h> #include <sys/wait.h> int main() { pid_t pid; int i,j; pid=fork(); if(pid<0) { printf("Process is not created\n"); } else if(pid == 0) { printf("Child process\n"); printf("Id of the child process : %d\n",getpid()); } else { wait(NULL); printf("Parent process...
C
#include "Node.h" //#define DEBUG #if defined (DEBUG) static void test_computeChildren() { // Sequence is UP(0), DOWN(1), LEFT(2), RIGHT(3) // Suppose grid with children UP and LEFT int grid1[] = {1, 2, 3, 4, 5, 6, 7, 8, 0}; Node *node = initNode(grid...
C
#include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <stdlib.h> /*Количество цифр в числе t*/ int getn(int t) { if(t<=9) return 1; else { int res = 1; int tmp = t; while(t>9) { t/=10; res++; } return res; } } /*Сделать из двух чисел одну строку*/ char * msg(int m, in...
C
#include<stdio.h> #include<stdlib.h> int main(void) { int n1, n2; printf("JQƻP:");scanf_s("%d %d", &n1,&n2); printf("\n"); if (n1%n2 == 0) printf("%d%d\n", n1, n2); else printf("%d%d\n", n1, n2); system("pause"); return 0; }
C
// // Created by danil on 25.04.2021. // #include "cstring.h" static void update_chars(string* self) { if (self->_chars_changed) { self->_chars = realloc(self->_chars, sizeof(char)*(self->size+1)); char* curr = self->_chars; void** item = self->chars->items; for (int i = 0; i<self->size; i++) *(curr++) = ...
C
#include <stdbool.h> #include <stdlib.h> #include <avr/interrupt.h> #include <util/delay.h> #include <usart.h> #include <ledlib.h> #include <buttonlib.h> #include "simonsays.h" bool button1 = false; bool button2 = false; bool button3 = false; // ISR(PCINT1_vect) // { // // Todo: why do I really need double ifs? ...
C
#include<stdio.h> #include<math.h> double SigmaFunc1(int n, double xarr[n], double yarr[n]) { double result = 0; for(int x = 0; x < n; x++) { result += xarr[x]*yarr[x]; } return result; } double SigmaFunc2(int n, double iarr[n]) { double result = 0; for(int x = 0; x < n; x++) { ...
C
/* * controlBoxV01HAL.h * * Created: 15-Apr-17 11:58:26 AM * Author: Kofler Joshua * Editor: Jenny Patrick */ #include <stdint.h> #ifndef CONTROLBOXV01HAL_H_ #define CONTROLBOXV01HAL_H_ /* initialize hardware abstraction layer */ void HAL_init(void); /* hardware abstraction layer process */ void HAL_proces...
C
#include "binary_trees.h" /** * binary_tree_insert_left - inserts a node as the left-child of another node * * @parent: pointer to the parent node * @value: value to be inserted * * Return: pointer to the new node */ binary_tree_t *binary_tree_insert_left(binary_tree_t *parent, int value) { binary_tree_t *new...
C
//======================================================================== // quick-sort-basic-tests.c //======================================================================== // This file contains the tests for the quick sort function #include <stdio.h> #include <stdlib.h> #include "utst.h" #include "quick-sort.h"...
C
// motorzx.h // Tabla de colores para un nico valor de papel/tinta // - TINTA - // // NEGRO 0 00000000 // AZUL 1 00000001 // ROJO 2 00000010 // MAGENTA 3 00000011 // VERDE 4 00000100 // AZULADO 5 00000101 // AMARILLO 6 00000110 // BLANCO 7 00000111 // // - PAPEL - // // NEGRO 0 00000000 // AZUL 8 00001000 // ROJO...
C
/*H********************************************************************************/ /*! \File zlist.h \Description Generic list module for samples to use. \Copyright Copyright (c) 2005 Electronic Arts Inc. \Version 04/26/2005 (jfrank) First Version */ /*******************************...
C
//to create hard link and soft link #include<stdio.h> #include<unistd.h> int main() { /* Hard Link: You have one file with two different filenames. If you edit one, it gets edited in all filename locations. If you delete one, it still exists in other places. Only one file on disk. Soft Link: You...
C
#include <stdio.h> typedef struct Student { int id; int marks; char fav_char; char name[60]; }std ; int main() { std s1,s2;// here whole struct Student got converted into std by typedef keyword in c. s1.id=13; s2.id=14; printf("The value of s1 id is %d\n",s1.id); typedef...
C
#include <hidef.h> /* common defines and macros */ #include "derivative.h" /* derivative-specific definitions */ // A CAN message has a CAN ID, DLC and 8 bytes of data struct CAN_MSG { unsigned long ID; unsigned char DLC; unsigned char *DATA; }; typedef struct Node *link; // Declaring a link as a pointer...
C
#include "utils.h" /** * Delay by executing some "nop"s. * * @param[in] d number of "nop"s to perform. */ void delay(int d) { int i; for(i = 0; i < d; i++) { __asm("nop"); } }
C
#include <stdio.h> void printRange(int a,int b){ if(a<=b){ for(int i=a;i<=b;i++){ printf("%d ",i); } }else{ for(int i=a;i>=b;i--){ printf("%d ",i); } } } void main(){ int a,b; scanf("%d\n%d",&a,&b); printRange(a,b); }
C
#include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include "list.h" #include "jobs.h" Running_List running_jobs_list = NULL; Queued_List queued_jobs_list = NULL; int N = 1; void jobExecutorServer() { int fd, fd2, unknown_com...
C
/* Trabalho 1 - Programacao Concorrente - SSC0143 Segundo semestre de 2019 Daniel Penna Chaves Bertazzo - 10349561 Gabriel Seiji Matsumoto - 10295332 Leonardo Miassi Netto - 9326688 */ #include <stdlib.h> #include <stdio.h> #include <math.h> #include <time.h> // Struct que representa as ...
C
#include "stdlib.h" #include "math.h" #include "stm32f429xx.h" #include "stm32f4xx_ll_bus.h" #include "stm32f4xx_ll_gpio.h" #include "stm32f4xx_ll_tim.h" #include "stm32f4xx_ll_dac.h" #include "stm32f4xx_ll_rng.h" #include "sonate.h" #define true 0x1 #define false 0x0 #define SAMPLE_...
C
/* ** expand.c for 42sh in /goinfre/grosli_o-42sh/src/expansion ** ** Made by olivier grosliere ** Login <grosli_o@epita.fr> ** ** Started on Sun Jan 16 15:09:42 2005 olivier grosliere ** Last update Tue Jan 18 18:14:54 2005 olivier grosliere */ /** ** @file expand.c ** Contains the mainframe of expansion module ...
C
#include"Linklist.h" const int lenNodetoNode(pLinkNode start, pLinkNode end) { int count = 0; while (start != end) { count++; start = start->next; } return count+1; } const pLinkNode BuyNode(DataType x) { pLinkNode newNode = (pLinkNode)malloc(sizeof(LinkNode)); newNode->data = x; newNode->next = NULL; retu...
C
/* * Regresa el gen en formato de palabra para imprimirse */ #include "bevolucion.h" int8_t * gen_string (gen g) { int8_t *gs; int32_t i; gs = calloc (sizeof (int8_t), MAX_NUC_GEN*2); for (i = 0; i < g.tamano; i++) memcpy (gs + (i * 2), nombre_par_base (g.par_bases[i]), 2); return gs; }
C
// Andrea Orlando - 4BROB #include <stdio.h> #include <stdlib.h> #define MAX_NUM_CONTATTI 1024 typedef struct contatto { int id; char nome[64]; char numero[16]; } Contatto; typedef struct rubrica { int num_inseriti; Contatto db[MAX_NUM_CONTATTI]; } Rubrica; int inserisc...
C
/* Author: Internshala Module: Getting Started with Programming in C Topic: Operators */ #include <stdio.h> int main() { // Arithmetic Operators: +, -, *, /, and %. // Precedence: {*, /, %} > {+, -} // Associativity: Left to Right int result = 3 + 1 - 7 * 5 % 3 / 2; printf("%d", result); // => 3 + 1 -...
C
#include "testing.h" #include "chatShared.h" #include "networks.h" #include "server.h" #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/uio.h> #include <sys/time.h> #include <unistd.h> #include <fcntl.h> #include <string.h> #include <strings.h> #include <sys/socket.h> #i...
C
/* Tashkinov Mikhail (c) 2013 Game "Life" */ #include <malloc.h> #include "play.h" #include "field.h" enum Error { OK = 0, INVALID_ARG_NUM = 1, NO_SUCH_FILE = 2 }err; FILE * Parse_file(int argc, char * argv[]) { FILE * input = NULL; if (argc == 2) { input = fopen(argv[1], "r"); if (input == NU...
C
#include <stdio.h> #include <dstring.h> int main(void) { struct string s; string_init(&s); string_append(&s, "Held"); string_insert(&s, 2, "llo, wor"); string_grow(&s, 1); s.str[s.len - 1] = '!'; string_insert(&s, 7, "MOUSE "); string_delete(&s, 7, 12); printf("%s\n", s.str); string_deinit(&s); }
C
#include<stdio.h> void suma (int n) { int i,s=0; for (i=1;i<=n;i++) { s=s+i; printf("%d",i); if (i!=n) printf ("%c",'+'); } printf("%c %d",'=',s); } int main() { int n; printf("n="); scanf("%d",&n); while (n<0) { printf("Valoar...
C
#include<stdio.h> #include <stdint.h> /** * λŻn & n-1 ÿζὫһλת0 * @param n * @return */ int hammingWeight(uint32_t n) { int result = 0; while (n) { n &= n - 1; result++; } return result; } /** * 򵥵ѭÿλж * @param n * @return */ int hammingWeightOne(uint32_t n) { int i, result...
C
#include "fdf.h" void set_color(t_mlx *mlx) { int i; i = -1; while (++i < mlx->global.g_i) { if (mlx->p_arr[i].z < mlx->global.g_max_z / 3) mlx->p_arr[i].color = 0x87ceeb; else if (mlx->p_arr[i].z < mlx->global.g_max_z * 2 / 3) mlx->p_arr[i].color = 0x6400; else mlx->p_arr[i].color = 0xffa500; } ...
C
/* * Bignum routines for RSA and DH and stuff. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "ssh.h" unsigned short bnZero[1] = { 0 }; unsigned short bnOne[2] = { 1, 1 }; Bignum Zero = bnZero, One = bnOne; Bignum newbn(int length) { Bignum b = malloc((length+1)*sizeof(unsigned short)...
C
#include<reg52.h> // 51ƬĴͷļ unsigned char code Tab[11]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff}; //ʾ09Ķ unsigned char int_time; //¼жϴ unsigned char second; // /*********************************************************************** ܣٶ̬ɨʱ,ʱԼ0.6 *********************************...
C
/* * twiSlave.c * * Created: 4/9/2015 2:27:29 PM * Author: kwgilpin */ #include <stdint.h> #include <stdbool.h> #include <stddef.h> #include <avr/io.h> #include <avr/interrupt.h> #include <util/atomic.h> static bool m_initialized = false; static volatile bool m_waitingForAddr; static volatile uint8_t m_regi...
C
#include <stdlib.h> #include <math.h> double distance (double PR[], double PRv[], int db) { float pwr = 0.5; double osszeg = 0.0; for(int i = 0; i < db; i++) { osszeg += (PRv[i] - PR[i]) * ( PRv[i] - PR[i] ); } return pow(osszeg, pwr); //sqrt (osszeg); } ...
C
#include <stdio.h> #include <sys/timeb.h> int main(int argc, char **argv) { struct timeb tp; time_t time; ftime(&tp); time = tp.time; printf("the current time is : %d\n", time); printf("the millitm is : %d\n", tp.millitm); //timezone以分钟为单位,表示本地时间和UTC时间的偏离。 //负值表示东时区。例如北京为东8区,该值为-4...
C
#include <stdlib.h> #include "queue.h" struct Queue * queue_create(void) { struct Queue * q = malloc(sizeof(struct Queue)); *q = (struct Queue) {.front = NULL, .back = NULL}; return q; } void queue_delete(struct Queue * q) { struct Node * current = q->front; while (current != NULL) { struct Node * tmp = curre...
C
#include <stdio.h> #include <stdbool.h> #include <stdlib.h> typedef struct Node { int data; struct Node *next; } Node; Node *createNode(int element) { Node *temp = NULL; temp = (Node *)malloc(sizeof(Node)); temp->data = element; temp->next = NULL; return temp; } void insertNode(Node **Bi...
C
/* gv.h Funções públicas do módulo graphviz. */ #ifndef __GV_H__ #define __GV_H__ #include <stdio.h> #include <stdlib.h> static FILE *fp = NULL; static inline void __gv_test_valid_fp (const char *function_name) { if (!fp){ fprintf (stderr, "%s foi chamada, mas gv_init não foi chamada antes, abort()\n", ...
C
/* * Copyright (c) 2015 Google, Inc * Written by Simon Glass <sjg@chromium.org> * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> #include <command.h> #include <errno.h> static int test_get_timer(void) { ulong base, start, next, diff; int iter; base = get_timer(0); start = get_timer(0); for (iter =...
C
#include<stdio.h> #include<stdlib.h> #include<assert.h> int foo() { int k = 0; // k=>[0,0] while (k < 100) { int i = 0; // i=>[0,0] int j = k; // j=>[0,100) while (i < j) { i = i + 1; // i=>[1,99] j = j - 1; // j=>[-1,99) } k = k + 1; // k=>[1,100] } return k; // k=> [100,...
C
#include <stdio.h> int main(void){ char c,arrC[80], changer=0; int counter=0; while ((c=getchar())!=EOF) { if(changer){ putchar(c); }else if(counter==79){ int i=0; for(;i<79;i++){ putchar(arrC[i]); } ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.c :+: :+: :+: ...
C
#define HISTORYBUFFERSIZE 15 byte historyBuffer[HISTORYBUFFERSIZE]; byte historyBufferIDX; // Use arduinojson.org/assistant to compute the capacity. StaticJsonDocument<4024> doc; JsonObject obj; byte spellWordListLength; byte currentSelectedWordIndex = 0; void btox(char *xp, byte *bb, int n) { const char xx[] = ...
C
#include<stdio.h> #include<math.h> void main() { int n,i,j=0,sp,k,t; scanf("%d",&n); for(i=0;i<n;i++) { for(sp=i;sp<=n;sp++) printf(" "); k=pow(11,j); while(k!=0) { t = k %10; printf("%d ",t); k = k/10; } j++; printf("\n"); } }
C
#include "flacmetaread.h" #include <stdlib.h> #include <limits.h> int main(int argc, char* argv[]) { struct flac_file_structure *file_structure; struct flac_meta_block *current_metablock, *metablocks; struct flac_meta_vorbis *current_vorbis, *vorbis_tags; char path[4096]; if(argc <= 1) { prin...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <malloc.h> #include <sys/socket.h> #include <sys/types.h> #include <netdb.h> #include <netinet/in.h> #include <unistd.h> #include <arpa/inet.h> void posalji(int sock,char* rijec) { int poslano=0; int novoposlano=0; while (poslano!=sizeof(rijec)) ...
C
/* * input.c * * Created: 2017-09-28 15:37:07 * Author: Filip */ #include "input.h" #include "main.h" #include "hal.h" /*---------------------------------------------------------------------------*/ /*! Moves through all 18 holes and fills the arrays with values, enter to proceed to next hole *...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> struct stack{ int size; int top; int *array; }; int empty(struct stack*ptr) { if(ptr->top==-1) { return 1; } return 0; } int full(struct stack*ptr) { if(ptr->top==ptr->size-1) { return...
C
// // Created by Guy Moyal on 20/03/2018. // #include "utils.h" #include <stdio.h> int createNumByIdx(int indices, int num) { int numLength = findLength(num); int indicesLength = findLength(indices); if (checkIndices(indices,numLength)) { fprintf(stderr,"Bad indice"); return -1; } /...
C
#include <stdio.h> #include <stdlib.h> /* A binary tree node has data, pointer to left child and a pointer to right child */ struct node { int data; struct node* left; struct node* right; }; void printarray(int *array,int n) { int i; for (i = 0; i < n; ++i) { printf("%d->",array[i] ); } printf("\n...
C
#include "bool.h" const char *bool_str(t_bool b) { static const char true_str[] = "TRUE"; static const char false_str[] = "FALSE"; return (b == false ? false_str : true_str); }
C
#include "CommonDef.h" //Ա洢ռijʼ typedef struct{ ElemType *elem;//洢ַ int length;//ǰЧ int listsize;//ǰĴ洢 }SqList; //(1)ʼԱ /* ĽǹһյԱ LΪԱ洢ռڴԪ, ɹ 1 ,Ϊ 0 */ int InitList(SqList *L); //(2)Ա /* ĽͷԱ L ռõڴռ */ void DestroyList(SqList *L); //(3)жǷΪձ /* 㷵һֵʾ L ǷΪձ L Ϊձ,򷵻 1,򷵻 0 */ int ListEmpty(SqList L); ...
C
/* Escrever um programa em C que apresente todos os valores numricos inteiros mpares na faixa de 0 a 20. */ #include <stdio.h> #include <stdlib.h> int main() { int i = 0; while (i <= 20) { if (i % 2 != 0) { printf("%d ", i); } i++; } printf("\n\n"); system("pause"); return 0; }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* sort_lst.c :+: :+: :+: ...
C
#include<stdio.h> int main() { int i; printf("ASCII TABLE"); for(i=0;i<=255;i++) printf("\n%d - %c",i,i); }
C
#include <stdio.h> #include <stdlib.h> #include <conio.h> #include <ctype.h> #include <math.h> int choixMenu(int nbChoix) { char touche = 0; do { touche = getch(); } while(touche < '1' || touche >= '1' + nbChoix); return(touche - 64); } int lireTexte (char chaine[],int longueur, int...
C
#include "can.h" //u32 CANERR_Flag = 0; // CAN //u8 CAN_ErrorCode; //u32 test6; extern CAN_HandleTypeDef hcan1; CanTxMsgTypeDef TxMessage; CanRxMsgTypeDef RxMessage; //CANʼ //mode:CAN_Mode_Normal,ͨģʽ;CAN_Mode_LoopBack,ػģʽ; //Fpclk1ʱڳʼʱΪ36M,CAN_Mode_Init(CAN_SJW_1tq,CAN_BS2_8tq,CAN_BS1_9tq,4,CAN_...
C
#ifndef ARQUITECTURA_COMPUTADORA_H #define ARQUITECTURA_COMPUTADORA_H #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ncurses.h> #include <math.h> #include "EasyPIO.h" //output estandar, convierte cualquier numero //decimal/Hexa a binario pero al revez (osea 1 = 1000000) ////////////////////Mostr...
C
#ifndef MESSAGE_QUEUE_H #define MESSAGE_QUEUE_H #include "message.h" #include "fifo_queue.h" /* message queue possible status */ #define NOT_WAITING 0 #define WAITING_FIRST 1 #define WAITING_PRIORITY 2 #define WAITING_FROM 3 /* type definition */ typedef struct{ list queue; int32_t status; int32_t status_data...
C
#include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include<sys/ioctl.h> #include <unistd.h> int main(){ int fd; fd = open("/dev/gpio_test", 0); if(fd<0){ printf("gpio_test open failed!"); } while(1){ ioctl(fd,1,0); sleep(1); ioctl(fd,0,0); sleep(1); } return 0; }
C
#include <stdio.h> #include <stdlib.h> /** *countCoins - counts the amount of coints *needed to equal the value it is given * *@value: The value from which we will calculate the *amount of change to give back * *Return: returns the amount of coins counted from change */ int countCoins(int value) { int count; ...
C
#ifndef FIXED_POINT_H #define FIXED_POINT_H #define FIXED_SHIFT 16 #define FIXED_SCALE 0x10000 // Referred to the Tonc library's fixed point primer for these functions. // http://www.coranac.com/tonc/text/fixed.htm // This utilizes 16.16 fixed point numbers typedef int fixed; // Conversions static inline fixed int_...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 10000 #define bool char #define START 0 #define END 1 void solve(int *array,int len) { int history[2] ={0,}; int max = 0; int cnt =1; bool isflat = 0; for(int i=0; i <len-1; i ++) { //is same~ if(array[i] == array[i+1]) { cnt++; ...
C
void main() { /* comentarios comentarios comentarios */ int x,y; x = 3; y = 2; if (x > y || x == 2) then{ /* só aceita */ printf(x); } else { printf(y); }; printf(x + y); printf(x - -y); printf( /* bla */ 1 /* bla */); printf( 3+4/2 + ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* di_convert.c :+: :+: :+: ...
C
#include<stdio.h> #include<conio.h> #include<string.h> int main() { char st1[100]; scanf("%s",st1); int count=0,count1=0,i; for(i=0; i<strlen(st1); i++){ //if(st1[i]>=65 && st1[i]<=90){ if(isupper(st1[i])){ count++; } else if(islower(st1[i])){ //(st...
C
#include "color_print.h" static int cp_apply(cp_state_ptr cp) { #ifdef WINDOWS return SetConsoleTextAttribute(cp->std_output, cp->current_color) == TRUE ? 0:(-1); #else if (cp->current_color == CP_DEF) return (fprintf(cp->std_output, "\e[0m") > 0) ? 0:(-1); int cp_fg = ((cp->current_color & 0x0f) ...
C
#define F_CPU 921600UL #include <avr/io.h> #include <util/delay.h> void left(); void gimbal_transmit(int byte1,int byte2,int byte3,int byte4,int byte5,int byte6,int byte7); void UART_Transmit(unsigned char data); int main(){ UCR = (1<<RXEN)|(1<<TXEN); UBRR= 12; while(1){ left(); } } v...
C
#include "header.h" struct student_disk stud; struct student_disk sd; struct teacher_disk teach; struct teacher_disk td; int num_records ,n; int num_record ,n; void error(const char *msg) { perror(msg); exit(1); } int main(int argc, char *argv[]) { int sockfd, portno, n; struct sockaddr_in serv_addr; struct host...
C
/* * To compile use * cc cgrep.c -lmisc * This uses libmisc.a and the misc.h header from libmisc.a.Z */ /* * cgrep is egrep for c programs. * * cgrep checks all c identifiers (cgrep considers if, etc to be * identifiers) against an egrep type pattern for a full match. * * cgrep tmp *.c * will find tmp as ...
C
#include <stdio.h> main() { char c; unsigned char d; int i; unsigned int j; long int k; unsigned long int m; float x; double y; long double z; clrscr(); do { clrscr(); printf("\nEnter charecter ,unsigned char"); scanf("%d %d",&c,&d); printf(" %c %c\n",c,d); printf("\nEnter int,unsigned "); scanf...
C
#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> #include<stdlib.h> #include<assert.h> #if 0 void InsertSort(int *a, int n) { assert(a); int i = 0; for (i = 0; i < n - 1; i++) { int end = i; int tmp = a[end + 1]; while (end >= 0 && a[end] > tmp) { a[end + 1] = a[end]; end--; } a[end + 1] = tmp...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "jerasure.h" #include "product_matrix.h" #include "MBR_MSR.h" #define talloc(type, num) (type *) malloc(sizeof(type)*(num)) #define mprint jerasure_print_matrix void aprint(int* a, int len) { for(int i = 0; i < len; i++) printf("%d, ", a[i])...
C
/** This hash table is an approximate LRU cache. The timestamps are not strictly LRU, and are approximated due to the read write lock's allowing changes to the timestamps in nonlinear order in concurrent runs. The concurrency of the cache is maintained by read write locks, where all functions modifying the hash table a...
C
//// 290207 //// lista 9 //// zad 1 // //#include <stdio.h> //#include <stdlib.h> // //#define MAX_N 999999 // //void rzymska(int n){ // if (n<1 || n>MAX_N) { // printf("Brak reprezentacji\n"); // return; // } // // char num[] = { 'I', 'V', 'X', 'L', 'C', 'D', 'M'}; // // 1 5 ...
C
// Copyright (c) 2018 Felix Schoeller // // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. #include <stdio.h> #include <string.h> #include "../util/common.h" #include "scanner.h" static bool at_end(Scanner *scanner) { return *scanner->cu...
C
//***************************************************************************** // Real Time Operating System /* This example accompanies the book "Embedded Systems: Real Time Interfacing to the Arm Cortex M3", ISBN: 978-1463590154, Jonathan Valvano, copyright (c) 2011 Programs 6.4 through 6.12, sect...
C
#include "push_swap.h" void print_stacks(t_stack *A, t_stack *B) { t_stack *temp; temp = A; ft_putendl("Stack A:"); while (temp) { ft_putnbr(temp->content); ft_putstr(", "); temp = temp->next; } ft_putendl(""); temp = B; ft_putendl("Stack B:"); while (temp) { ft_putnbr(temp->content); ft_putstr("...
C
#include "parser.h" void parse_error(const char* string) { DEBUG("Unexpected symbol '%c' at position %u.\n\n", string[G_STRING_ITERATOR], G_STRING_ITERATOR); exit(1); } char Get_char(const char* string, char c) { if(string[G_STRING_ITERATOR] != c) parse_error(string); ++G_STRING_ITERATOR; ...
C
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <string.h> int main() { int i; char string1[20] = "Dreams come true!"; char string2[20]; char *ptr1, *ptr2; printf("%u\n", string1); ptr1 = string1; printf("%u\n", ptr1); printf("%s\n", string1); printf("%s\n", ptr1); printf("%s\n", ptr1 + 7); ptr...
C
#include<stdio.h> int main() { int a,b; a=1; b=2; int c = a+b; printf("%d",c); return 0; }