language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include<stdio.h> int main() { int num; printf("\n Enter a number:\t"); scanf("%d",&num); if(num%7==0) { printf("\n%d is divisible by 7",num); } else { printf("\n%d is not divisible by 7",num); } return 0; }
C
#include "Process.h" /*Constructors*/ Process *new_Process(int i, int fpos) { Process *temp = malloc(sizeof(Process)); /*PCB*/ temp->id = i; temp->pc = -1; temp->state = NEW; temp->inst_pos = fpos; temp->var_pos = -1; temp->timer = -1; temp->in_memory = false; return temp; } /*Methods*/ /* loaders and unloa...
C
#include <stdio.h> int main() { int n, fact=1,i; printf("Please enter number:"); scanf("%d",&n); for(i=1; i<=n;i++) { fact = fact*i; } printf("\nThe two numbers are after swapping: %d",fact); return 0; }
C
// node.h // Phone_node struct definition for node of a doubly linked list #define NAME_LENGTH 30 // replace all subsequent occurrences of the symbolic constant NAME_LENGTH with 30 #define PHONENUM_LENGTH 15 // replace all subsequent occurrences of symbolic constant PHONENUM_LENGTH with 15 // Phone_node struct ...
C
/* ** EPITECH PROJECT, 2021 ** vlib ** File description: ** vector_find macro unit tests */ #include <criterion/criterion.h> #include <stdbool.h> #include <vlib.h> static bool cmp_fun(int *e, int cmp) { return (*e == cmp); } Test(vector_find, empty_vector) { vector(int) *vector = vector_create(int); int ...
C
#include <stdio.h> int main(){ int a[5] = {1, 2, 3 ,4 ,5} ; printf("%u\n", &a ); printf("%d\n", a ); printf("%d\n", *a ); printf("%d\n", a[0] ); }
C
#include <stdio.h> #include <stdlib.h> struct date//ṹ { int year;// int month;// int day;// }; struct student { char num[9];//ѧ char numr[21];// char sex[4];//Ա int age;// struct date birthday;// int score[3];//ſĿɼ double aver; }; int main(void) { struct student stu;//ṹ int i,sum=0; printf("Ϣ\n"); p...
C
#include "shared.h" #include <unistd.h> void print_parent() { sem_t* parent; sem_t* child; open_semaphores(&parent, &child); for (int j = 0; j < PRINT_TIMES; j++) { sem_wait(parent); printf("%s[Parent]: ", PARENT_COLOR); for (int i = 0; i < 10; i++) { printf("%c", '0' + i); fflush(stdout); usle...
C
/** LeetCode Question 12. Integer to Roman Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. **/ class Solution { public: string intToRoman(int num) { int thousands = 0; int fundreds = 0; int hundreds...
C
/* HOME5.C :Homing routine using a mechanical hard stop. This sample demonstrates a basic homing algorithm. The home location is found based on a mechanical hard stop. The DSP senses the hard stop when the difference between the command and actual positions exceeds the error limit. Here is the algorith...
C
/*@ requires \valid(t+(0..n-1)) && n>0; behavior success: assumes \exists integer i; 0<=i<n && t[i]==val; ensures 0<=\result<n; behavior failure: assumes \forall integer i; 0<=i<n ==> t[i]!=val; ensures \result==-1; */ int index(int t[], int val, int n){ /*@ loop invariant 0<=i<=n; loop ...
C
/***************************************************************************************************************** * Compiling: mpicc fattor.c -lgmp -fopenmp -o fattor * Running: mpirun -n PROCNUM --bind-to none fattor NUMBER * Note: PROCNUM is the number of processes that will be ran, and it must be >=2, NUMBER is the...
C
#include <stdio.h> void main() { int num,factor; printf("Enter the number: "); scanf("%d",&num); printf("Factors of %d are:\n",num); for(factor=1;factor<=num/2;factor++) { if(num%factor==0) printf("%d\n",factor); } printf("%d\n",num); }
C
/* ========================================================================= */ /* ------------------------------------------------------------------------- */ /*! \file vec2d.h \date Jun 2012 \author TNick \brief Contains the definition for Vec2D class *//* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~...
C
#include <stdio.h> int main(){ float c, f; printf("Digite o valor da temperatura em graus C: "); scanf("%f", &c); f = (c * (9.0/5.0)) + 32.0; printf("O valor convertido: %f", f); return 0; }
C
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> typedef struct Node { int data; struct Node *next; } Node; Node *head; void addFront(Node *root, int data) { Node *node = (Node*)malloc(sizeof(Node)); node->data = data; node->next = root->next; root->next = node; } void ...
C
/* USART Examples for Atmega1284 */ /* Initializes the desired USART Call this function before the while loop in main */ void initUSART( unsigned char usartNum); //Example initUSART(0); //initializes USART0 initUSART(1); //initializes USART1 //Empties the UDR Register of the desired USAR...
C
// Write a C program to find factorial of any number using recursion. #include<stdio.h> #include<math.h> int factorial_of_a_num(int n) { if(n==1 || n==0) return 1; else return n*factorial_of_a_num(n-1); } int main() { int n,result; printf("enter number\n"); scanf("%d",&n); result=factorial...
C
/* **************************************************************** * * * scan.c * * * * Analisador lxico * * * * Verso 1.0.0, de 23.08.88 * * 4.1.0, de 22.08.01 * * * * Modulo: CPP * * Tradutores * * Categoria D * * * * TROPIX: Sistema Op...
C
/* ============================================================================ Name : 2Problem1.c Author : SHO Version : Copyright : Your copyright notice Description : Hello World in C, Ansi-style ============================================================================ */ #include <stdi...
C
#include <stdio.h> int bitsUm(); int main() { unsigned int n; int bits; scanf("%u",&n); printf("O 'unsigned int': %u tem %d bits a 1\n",n,bitsUm(n)); return 0; } int bitsUm (unsigned int n) { int bits=0; while (n!=0) { if (n%2==1) ++bits; n/=2; } return bits; }
C
/*c4droid代码手册 *读取文本 *TTHHR编写 *转载请说明出处 */ #include<stdio.h> #include<stdlib.h> main() { FILE *fp; char ch,wjm[51]; printf("请输入文本路径:"); scanf("%s",wjm); if (!(fp=fopen(wjm,"r"))) { printf("%s文件打开错误\n请检查!",wjm); exit(1); } while (feof(fp)==0) { ch=fgetc(fp); printf("%c",ch); } printf("\n完成!"); return 0; }
C
#include<stdio.h> int main(){ int n; printf("Enter the limit: "); scanf("%d",&n); int i,p,count=0; for(i=1;i<=n;i++){ p=i; while(p>0){ int rem = p%10; if(rem==1){ count++; p=p/10; } else p=p/10; } } printf("Number of occurences of 1's is..: "); printf("%d",count); }
C
/* DIGITAL SIGNATURE(S): ==================== List the student author(s) of this code below: Fullname Seneca Email Address --------------------------- ---------------------------- 1) Kamran Astanov kastanov@myseneca.ca 2) 3) +------------------------------------...
C
#include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> //server int main(){ char server_message[265] = "You have reached the server!"; //creat a server socket int server_socket; server_socket = socket(AF_INET, SOCK_STREAM, 0); //define the serve...
C
/* c source code for matrix multiplication */ # include <stdio.h> # include <stdlib.h> # include <mkl.h> /* To be compiled as: $ icc -mkl matmult.c */ /* Consider adjusting LOOP_COUNT based on the performance of your computer to make sure that a total run time is at least 1 second */ /* LOOP_COUNT as a constant mac...
C
/* * @File: arp.c * @Date: 2015-11-30 16:53:29 * @Last Modified time: 2015-12-08 22:52:39 * @Description: * ARP service functions * - void PrintAddressPairs(arp_object *obj) * [Print all address pairs] * - void PrintARPFrame(char *frame) * [Print ARP Frame Content] * - arp_cache *G...
C
#include <stdio.h> int ans[16]; void dfs(int idx, int n, int m, int i) { if(idx == m) { printf("{%d", ans[0]); for(i = 1; i < m; i++) printf(",%d", ans[i]); puts("}"); return; } for(; i <= n; i++) { ans[idx] = i; dfs(idx+1, n, m, i+1); } } int ...
C
#include<stdio.h> #include<unistd.h> int main() { int arr[2]; char msg[200]; char rcv[200]; printf("Enter message :"); scanf("%s",msg); int ret=pipe(arr); // creating a pipe printf("write descriptor: %d\n ",arr[1]); printf("read descriptor: %d\n ",arr[0]); int ret1 = write(arr[1],msg,sizeof(msg)); ...
C
#include <stdio.h> #include <stdlib.h> typedef struct a { int len; int sum; char str[55]; }A; A T[1005]; int n, i, j; int cn; int sum; char str[55]; int compare(A*a, A*b) { if (a->len > b->len) return 1; else if (a->len == b->len) { if (a->sum < b->sum) return -1; else if (a->sum == b->sum) { return s...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> #define MAX_SIZE (1000+1) typedef struct { int bIsCreated; int bIsVisited; int x,y; int x_pre,y_pre; int Opt; }Point; Point Table[MAX_SIZE][MAX_SIZE]; Point *queue[MAX_SIZE]; int first,next; char *Show[] = { "fill A\n", "fill B\n", ...
C
#include "holberton.h" /** *jack_bauer - time format * *Return: m (success) */ void jack_bauer(void) { int n1; int n2; int n3; int n4; for (n1 = 0; n1 < 2; n1++) { for (n2 = 0; n2 <= 9; n2++) { for (n3 = 0; n3 < 6; n3++) { for (n4 = 0; n4 <= 9; n4++) { _putchar(n1 + '0'); _putc...
C
/* * main.c * * Created on: Sep 26, 2020 * Author: slavius */ #include <stdio.h> #include <threads.h> #include <stdatomic.h> #include <stdbool.h> #include <stdlib.h> #include <math.h> #include <time.h> /////////////// CORES ///////////////////// #define __USE_GNU #include <sched.h> #include <errno.h> #inc...
C
#include <stdio.h> #ifndef _LIST_ #define _LIST_ #ifndef NULL #define NULL 0 #endif struct list_elem { struct list_elem *next; struct list_elem *prev; }; struct list { struct list_elem head; struct list_elem tail; }; #define offsetof (TYPE, MEMEBER) ((size_t) &((TYPE *)0)->MEMBER) #define list_entry(...
C
#include <stdbool.h> #ifndef _PARSETREE #define _PARSETREE typedef enum {INT_TYPE, DOUBLE_TYPE, STR_TYPE, BOOL_TYPE, SYMBOL_TYPE, PAIR_TYPE, NULL_TYPE} ParseNodeType; struct ParseNode { ParseNodeType type; union { int i; double d; bool b; char *s; struct Pair { struct ParseNode *car; ...
C
/*------------------------------------------------------------------------------ -- SOURCE FILE: Presentation.c - Contains all the OSI "presentation layer" -- functions for the Terminal Emulator. -- -- PROGRAM: Advanced Terminal Emulator Pro -- -- FUNCTIONS: -- BOO...
C
#include <cairo/cairo.h> #include <fcntl.h> #include <linux/types.h> #include <linux/ioctl.h> #include <sys/ioctl.h> #include <linux/fb.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <signal.h> #include <sys/mman.h> #include <time.h> #include <getopt.h> static volatile sig_a...
C
#include<stdio.h> int Day(int a,int b,int c) { int i,j; int r=0;//湫Ԫ1굽 int m[]={31,28,31,30,31,30,31,31,30,31,30,31};//mÿµ if(a>=1&&b>0&&b<13&&c>0&&c<32) { for(i=1;i<=a;i++)//ĸ { if(i%400==0||i%100!=0&&i%4==0) r++; } for(j=0;j<b-1;j++)//ͳƵ11յµ,ǰ(b-1) { c+=m[j]; } if(a%400==0||a%...
C
/* ** EPITECH PROJECT, 2019 ** engine_header.c ** File description: */ #include <stdio.h> #include "objdump.h" static void header_64(int mo[ET_NUM], char *at[ET_NUM], data64_t *obj) { static const char *archi = "architecture: i386:x86-64, flags 0x%08x:\n"; static const char *format = "%s\n"; stat...
C
#include <assert.h> #include <stdio.h> #include <stdlib.h> #include <stddef.h> #include "lib/array.h" #include "lib/memory.h" struct array { void **data; size_t size; size_t capacity; }; array *create_array(void) { return array_init(32); } struct array *array_init(long initial_capacity) { assert...
C
#include <stdio.h> #include <stdlib.h> int main () { int n1,n2,t,i,j; printf("Enter first number: "); scanf("%d",&n1); printf("Enter second number: "); scanf("%d",&n2); printf("Prime numbers between %d and %d are:\n", n1, n2); for(i=n1;i<=n2;i++) { t=0; for(j=2;j<=i/2;j++) {...
C
#include <stdio.h> #include <stdlib.h> #include "local_matrix.h" #include <math.h> #include <time.h> #define MAX(a,b) (((a)>(b))?(a):(b)) #define MIN(a,b) (((a)<(b))?(a):(b)) typedef struct TDM { double* a; double* b; double* c; double* y; int size; } TDM; TDM* allocate_tdm(int size); void rando...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* threads.c :+: :+: :+: ...
C
#include "mongocrypt-private.h" #include "bson/bson.h" /* This key cache is a very rudimentary fill-in until we design something * better. * - keys are never removed. * - limited to 64 keys total. */ static int _cmp_uuid (const _mongocrypt_buffer_t *uuid1, const _mongocrypt_buffer_t *uuid2) { if (uuid1->len !=...
C
#include <stdio.h> // puts(), printf(), perror(), getchar() #include <stdlib.h> // exit(), EXIT_SUCCESS, EXIT_FAILURE #include <unistd.h> // getpid(), getppid(), fork() #include <sys/wait.h> // wait() #include <time.h> // time_t, time() #include <sys/time.h> // gettimeofday() #define NUM_CHILDREN 10 #define...
C
#ifndef CASS_H #define CASS_H #include <inttypes.h> #include <math.h> #include <stdio.h> #include <string.h> static int cass_errors = 0; inline static int cass_close_impl(double actual, double desired, double rel_tol, double abs_tol); inline static void cass_print_context(const cha...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strsplit.c :+: :+: :+: ...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include "simulator.h" #include "helper.h" #include "math.h" // get the number of digits of a number int int_length(int number) { return (int) floor(log10(abs(number))) + 1; } void print_tapes(struct tapes *tapes, struct program *program, char *prefix, in...
C
/* ----------------------------------------------------- timer2_demo.c Demonstriert im Gegensatz zum Demo in der Stopuhr eine weitere Methode, einen Timer (hier Timer2) zu verwenden Hardware : STM32F103 Takt : 72 MHz IDE : make - Projekt Library : lib...
C
//Gabriel Espinosa #include "processor.h" int main(void) { char inputBuffer[BUFFER_SIZE]; while (true) { // get a line of input from he user scanf(" %[^\n]", inputBuffer); if (strncmp(inputBuffer, SENTINEL, SENTINEL_LEN) == 0) // stop when "END" is read in brea...
C
/** * Un programa que recibe dos argumentos enteros a y b * Si a > b el programa termina e imprime el mensaje: * Error: a tiene que ser menor o igual a b * Si a <= b el programa busca e imprime todos los enteros divisibles por 3 * en el rango [a, b] * Ejemplo: * $ ./divisible 1 20 * 3 6 9 12 15 18 */ #include...
C
// hostserial.c - provide serial comms for host #ifndef _HOSTSERIAL_C_ #define _HOSTSERIAL_C_ #include "hostserial.h" #include <pthread.h> // formula: (freq/(16*BAUD)) - 1 // freq = 10 MHz (f_CPU) /* #define B9600 64 #define B57600 10 #define B19200 31 #define B38400 15 */ // baud rate //#define BAUD_RATE B384...
C
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <stdlib.h> #include <sys/time.h> #include "thread.h" /* test de la préemption. * * le programme doit terminer correctement (faire le printf et s'arreter entièrement). * valgrind doit être content. * le programme doit passer la main a l'autre threa...
C
#include <McpgOS.h> LListElement* LListGet(LListElement* list, uint32_t index) { uint32_t i; KAssert(list != NULL); KAssert(index < 0xFFFFFFFF); list = LListGetFirst(list); for (i = 0; i < index; i++) { list = list->Next; if (list == NULL) return NULL; } r...
C
int main() { int arr [] = {10, 9, 2, 3, 5, 11, 9, 0}; int i = 1; int min = arr[0]; while(arr[i] != 0) { if (arr[i] < min) min = arr[i]; i += 1; } return min; }
C
/* Name:Prokopios Stamelias AM 1115201400190 */ #include <stdio.h> #include <stdlib.h> #include "Session.h" void print_options() { printf("---------------------------------------\n"); printf("Type 1 for SessionNew\n"); printf("Type 2 for SessionNewTab\n"); printf("Type 3 for SessionAddressShow\n"); printf...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_next_line.c :+: :+: :+: ...
C
#include "minishell.h" #include "libft.h" static int get_len_to_semicolon(const char *str) { int ret; int quote; ret = 0; quote = 0; if (*str == '\0') return (-1); while (str[ret] && (str[ret] != ';' || quote != 0)) { if (str[ret] == '"' && quote == 0) quote = 1; else if ((str[ret] == '"' && str[ret -...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <assert.h> #include "basic_type.h" #include "utils.h" #define b_calloc(s,n) util_calloc(s,n) #define b_free(p) util_free(p) #define debug printf struct type_map { int type; const char* str; }; const static struct type_map m_type_map[] = { ...
C
#include "lists.h" /** * is_palindrome - checks if a LL is a palindrome or not * @head: the head of a linked list * Return: 1 if is a palindrome, 0 otherwise */ int is_palindrome(listint_t **head) { listint_t *h = NULL; listint_t *new = NULL; listint_t *tmp = NULL; int len = 0, half = 0; int pali = 1; if (!...
C
#ifndef _symbol_table_h #define _symbol_table_h #define MAX_SYMBOLS 1000 #define MAX_VALUES 1000 #define TRUE 1 #define FALSE 0 #define ERR -1 typedef struct { char *name; char type; int values_count; char *values[MAX_VALUES]; } symbol; symbol table[MAX_SYMBOLS]; // INPUT: Name of symbol to look up // OUTPUT: ...
C
#include "tdd_network.h" static int serialize_packet_message_count(unsigned int*, stream_t*); static net_message_t* read_next_net_message(packet_t*, net_message_factory_func_t); static int measure_net_message_size(packet_t*, net_message_t*); static void clear_net_message(void**)...
C
#include <i2p/cryptoimpl/openssl.h> #include <string.h> #include <openssl/sha.h> #define ELG_FULL_EXPONENT_BITS 2048 #define ELG_FULL_EXPONENT_BYTES (ELG_FULL_EXPONENT_BITS/8) void i2p_openssl_elg_encrypt(struct i2p_crypto * crypto, struct elg_op * op) { struct i2p_cryptoimpl_openssl_st * impl = (struct i2p_crypt...
C
// Trabalho 4 - SCC0215 - Organizacao de Arquivos // Luis Eduardo Rozante de Freitas Pereira #ifndef SERVIDOR_REGISTER_H #define SERVIDOR_REGISTER_H # include <stdio.h> # include "servidorheader.h" // Template para guardar o registro de um servidor na memória. typedef struct reg { // Informações sobre o regis...
C
#include <wiringPi.h> #include <stdio.h> #include <stdlib.h> #include <stdint.h> int main (void) { int bright; printf ("Raspberry Pi test\n"); if (wiringPiSetup () == -1) exit (1); pinMode (1,PWM_OUTPUT); for (;;) { for (bright = 0; bright <1024; ++bright) { pwmWrite (1, bright); delay (1); } for (bright =1023; bright ...
C
//Write a C program to check a given integer and return true if it is within 10 of 100 or 200 #include <stdio.h> int main(){ int x; printf("Input an integer: "); scanf("%d", &x); if((x >= 10) && (x <= 200)){ puts("True"); }else { puts("False"); } }
C
#include <stdio.h> #define EU 1 #define US 2 #define ITALIA 10 #define UK 20 #define AREA EU #define PAESE ITALIA main() { #if AREA==EU #if PAESE == ITALIA char moneta[]="euro"; #elif PAESE == UK char moneta[]="sterlina"; #endif #else char moneta[]="dollaro"; #endif pri...
C
#ifndef WEBSERVER_H_ #define WEBSERVER_H_ #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <pthread.h> #include <sys/stat.h> #include <semaphore.h> #define BUF_SIZE 1024 sem_t sem; // semap...
C
#include <stdio.h> int main() { int a[100],b[100],c[100],d,p,e,f,g,j,k,i=0,l=0,u; printf("Merge 2 arrays\n"); printf("Input: Size of the array - A: "); scanf("%d",&p); printf("Input: Size of the array - B: "); scanf("%d",&d); printf("\nInput: Elements of array-A\n"); for(e=0;e<p;e++) { printf("Element %d: ...
C
#include<stdio.h> #include<string.h> void main() { char ch[10]; char *ch1; printf("Enter the string"); scanf("%s",&ch); ch1=strrev(ch); printf("%s",ch1); }
C
/* Defining pins of LCD setting RS : pin which enables a user to select the instruction mode or the character mode of a LCD. RW : pin which enable user to set read / write mode of LCD EN : when this pin is set to logical high the LCD stsrts processing the incoming data */ #define RS (1<<16) #define RW (1<...
C
#include <sys/socket.h> #include <netinet/in.h> //sockaddr_in #include <unistd.h> //fork,read,write #include <stdlib.h> //exit(0) #include <errno.h> #include <string.h> //bzero #include <sys/epoll.h> //epoll #include <limits.h> //OPEN_MAX #include <stdio.h> const int SERV_PORT = 9527; con...
C
/* //finding sum of n numbers by allocating memeory dynamically// #include<stdio.h> #include<stdlib.h> int main() { int i,n,*p,sum=0; printf(" enter the value of n\n"); scanf("%d",&n); p=(int*)malloc(sizeof(n)); if(p==NULL) { printf("memeory not allocated\n"); } else{ ...
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 <stdio.h> int main() { float x,y; scanf("%f %f", &x, &y); printf("MEDIA = %.5f\n", (x*3.5+y*7.5)/(3.5+7.5)); return 0; }
C
#include<stdio.h> #include<conio.h> void main() { char a[100]; int i=0,c=0; clrscr(); printf("paragraph:"); for(i=0;i<n;i++) { switch(a[i]) { case '.':c++;break; case '!':c++;break; case '?':c++;break; case ';':c++;break; }} printf("%d",c); getch(); }
C
#pragma once struct Rect { int x; int y; Rect(int x_, int y_):x(x_),y(y_){} };
C
#include <stdio.h> #include "lib.h" #include <string.h> #include <stdlib.h> int main() { int status_code = 1; while (status_code == 1) { struct Vector* p_first_vec = create_vector(); struct TrieNode* p_root_node = make_trie_node('\0'); status_code = read_line(p_first_vec); if (status_code != 1) { print_er...
C
#include <string.h> #include <stdlib.h> #include <stdio.h> #include <assert.h> #include <errno.h> #include "CasesContigues.h" #include "Booleen.h" #include "Case.h" #include "Mot.h" CasesContigues CC_casesContigues () { errno = 0; return NULL; } Booleen CC_estVide (CasesContigues desCasesContigues) { errno = ...
C
/*\file * For debugging connections and message formatting; * sends bytes read from file to serial port or UDP socket * * Default is broadcast UDP socket on port 6056 * */ #include <sys_os.h> #include <sys_rt.h> #include "udp_utils.h" /** global definitions for signal handling */ static int sig_list[] = { ...
C
#include <util/TimeService.h> #include "LightScheduler.h" #include "LightController.h" enum { TURN_ON, TURN_OFF, DIM, RANDOM_ON, RANDOM_OFF }; enum { MAX_EVENTS = 128, UNUSED = -1 }; typedef struct { int id; int minuteOfDay; int event; Day day; } ScheduledLightEvent; static ScheduledLightEve...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "common.h" #include "chunk.h" #include "debug.h" #include "vm.h" #define ERR_USAGE 64 #define ERR_DATAERR 65 #define ERR_SOFTWARE 70 #define ERR_IOERR 74 #define REPL_LINE_MAX 1024 static char* read_file(const char* path) { FILE* file = fopen(p...
C
#define _LARGEFILE_SOURCE #define _LARGEFILE64_SOURCE #define _FILE_OFFSET_BITS 64 #include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #include <errno.h> #include "bloom.h" #include "hashes.h" #include "file_dir.h" /*---------------------------*/ #include <fcntl.h> #include <unistd.h> #include...
C
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> int binaryFind(int arr[],int n,int t){ int right = n-1; int left = 0; int mid = 0; while (left <= right){ mid = (left + right) / 2; if (t < arr[mid]){ right = mid-1; } else if (t > arr[mid]){ left = mid+1; } else{ break; } } if (left <= rig...
C
#ifndef CLIENTE_H_INCLUDED #define CLIENTE_H_INCLUDED typedef struct{ int id; char nombre[51]; char sexo; int isEmpty; }eCliente; /** \brief Para indicar que todas las posiciones del array estan vacias, * esta funcin pone todas las banderas (estaVacio) en TRUE * \param lista eCliente* puntero al arra...
C
#include "std_types.h" #include "registers.h" #include "gpio.h" void gpioPortDirection(uint8 port, uint8 direction) { if(port >=GPIOA && port <=GPIOD) { switch (port) { case GPIOA: PORTA_DIR=direction; break; case GPIOB: PORTB_DIR=direction; break; case GPIOC: PORTC_DIR=direct...
C
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <sys/time.h> #include <math.h> #include "primechecker.h" int isPrime(int n) { if (n <= 1) { return 0; } int nSquareRoot = (int)sqrt(n); for (int i = 2; i <= nSquareRoot; i++) { if (n % i == 0) { ...
C
// Room: /open/dancer/room/r5-2.c :cgy #include <room.h> #include <ansi.h> inherit ROOM; void create () { set ("short","ɽ"); set ("long", @LONG ɽ֮ϣĶһС·DzԭϷ ԶԶׯǺˡ LONG); set("exits", ([ /* sizeof() == 1 */ "east" : "/open/dancer/room/r5-3.c", ])); set("light_up", 1); setup(); }
C
#ifndef VARLIB_H #define VARLIB_H #include"headers.h" #define VARSIZE 100 struct var{ char *name; char *value; int is_globle; }; /*varible container */ struct var *var_list[VARSIZE] ; static int var_num=0; /* determine whether the args is to set the varible*/ int var_handler(char **); /* to store the varible *...
C
#include "threadpool.h" #include <stdlib.h> #include <unistd.h> #include <string.h> // 初始化线程池 void threadpool_init(threadpool_t *pool, int maxtrd) { condition_init(&pool->ready); pool->head = NULL; pool->tail = NULL; pool->max_thread = maxtrd; pool->counter = 0; pool->idle = 0; pool->quit ...
C
#include <stdio.h> #include <stdlib.h> /* for atof() */ #include <math.h> #define MAXOP 100 /* max size of operand or operator */ #define NUMBER '0' /* signal that a number was found */ int getop(char []); void push(double); double pop(void); void clearval(); /* reverse Polish calculator */ double alpha[26]; int ialpha...
C
/* * Copyright (c) 2004, QUALCOMM Inc. All rights reserved. * Created by: abisain REMOVE-THIS AT qualcomm DOT com * 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. * * Test that pthread_mutex_unlock() * shall wak...
C
//Sorting an array using shell sort #include <stdio.h> int main() { int i, j, temp, gap, n; printf("Enter number of elements in the array : "); scanf("%d", &n); int a[n]; printf("Enter n = %d numbers for storing in array :\n", n); for (i = 0 ; i < n ; i++) { ...
C
/* Program 1: Write a Program that Checks whether a number entered by user is an Automorphic Number or Not. {An Automorphic Number is such a number, whose Square ends with that number itself. e.g. 5 is Automorphic number. Square of 5 is 25 which satisfies the condition} ...
C
/** @file getopt_long.h ** @brief getopt_long ** @author Andrea Vedaldi **/ /* Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson. All rights reserved. This file is part of the VLFeat library and is made available under the terms of the BSD license (see the COPYING file). */ #ifndef VL_GETOPT_LONG_H #define...
C
#include "projet.h" //inclusion du fichier header //inclusion des bibiliotheques standards #include <stdio.h> #include <stdlib.h> #include <math.h> double **matrice2n(int a){ //creation de la matrice 2*n par allocation dynamique int i; double** p = malloc ( 2 * sizeof ( d...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "arvore.h" /*Como não havia um espaco para implementar uma struct de pilha no susy, foi implementado no lab10.c como sugerido pelo professor*/ /*As pilhas possuem a funcao de empilhar arvores durante a recursao*/ typedef struct no { p_arvore dado;...
C
#include <stdio.h> int fun(int x); int main() { int x ,n ; printf("Enter a Number: \n"); fun(x); return 0; } int fun(int x) { int n; scanf("%d", &n); x = n*n*n; printf("cube = %d",x); }
C
/** * - JsonInf can reads information from JSON file and show the string from object * in this file. Uses libjson-c-dev – JSON-C implements a reference counting * object model that allows you to easily construct JSON objects in C, output * them as JSON formatted strings and parse JSON formatted strings bac...
C
#include "led.h" #include "ets_sys.h" #include "osapi.h" #include "gpio.h" #include "user_interface.h" static os_timer_t led_timer; static uint16_t led_tick = 0; static uint32_t led_period = 0; void ICACHE_FLASH_ATTR led_init() { PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2); gpio_output_set(BIT2, 0, BIT2,...