language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include<stdio.h> int main() { int l,b,area,perimeter; printf("\n enter values of l,b"); scanf("\n%d%d",&l,&b); area=(l*b); perimeter=(l*b)+(l*b); printf("\narea=%d,perimeter=%d",area,perimeter); }
C
#define __REENTRANT #include <pthread.h> #include <stdio.h> void *threadhello(void *unused) { printf("Hello, world!\n"); return 0; } int main() { pthread_t thready; pthread_create(&thready, NULL, &threadhello, NULL); usleep(10); }
C
#ifndef Enum_h #define Enum_h #include <stdio.h> /** Two enums for easy usage of register names and assembly operations */ typedef enum reg{ ZERO= 0x0, AT = 0x1, V0 = 0x2, A0 = 0x3, A1 = 0x4, T0 = 0x5, T1 = 0x6, T2 = 0x7, T3 = 0x8, S0 = 0x9, S1 = 0xa, S2 ...
C
#include <stdio.h> #include <stdlib.h> void BubbleSort(int A[], int n) { int sorted = 0; int i; while (!sorted) { sorted = 1; for (i = 0; i < n; i++) if (A[i] > A[i + 1]) { sorted = 0; int aux = A[i]; ...
C
#include "RTC.h" /* Read RTC time(Hour, Min, Sec) from CMOS */ void kReadRTCTime(BYTE* pbHour, BYTE* pbMinute, BYTE* pbSecond) { BYTE bData; kOutPortByte(RTC_CMOSADDRESS, RTC_ADDRESS_HOUR); bData = kInPortByte(RTC_CMOSDATA); *pbHour = RTC_BCDTOBINARY(bData); kOutPortByte(RTC_CMOSADDRESS, RTC_ADDRESS_MINU...
C
#include <stdio.h> #define NAME_LEN 20 int main(void) { struct { int number; char name[NAME_LEN + 1]; int on_hand; } part1 = {528, "Disk drive", 10}, part2 = {914, "Printer cable", 5}; printf("Part number:\t%d\n", part1.number); printf("Part name:\t%s\n", part1.name); printf("Q...
C
/* ** EPITECH PROJECT, 2019 ** corewar ** File description: ** aff.c */ #include "corewar.h" #include <criterion/criterion.h> #include <criterion/redirect.h> champion_t *ini_champ(machine_t *machine); Test(Corewar, aff_i, .init = redirect_all_std) { machine_t machine; machine.champion[0] = ini_champ(&machin...
C
#include <stdio.h> #define LENGTH_OF_ARRAY(array) \ (sizeof(array) / sizeof(*array)) int sum(int* array, size_t length_of_array); int array[] = {1,2,3,4,5,6,7,8,9,10}; int main(int argc, char** argv) { int index; printf("Array: "); for(index = 0; index < LENGTH_OF_ARRAY(array); index++) { ...
C
#include <stdlib.h> #include <stdio.h> #include "seqpair.h" int main(int argc, char ** argv) { if (argc != 3) { fprintf(stderr, "not proper amount of inputs\n"); return EXIT_FAILURE; } FILE * infptr = fopen(argv[1], "r"); if (infptr == NULL) { fprintf(stderr, "Input fil...
C
#include "unity/src/unity.h" #include "common.h" # define ENTRY 1 /* * Rules: * ENTRY = "0"* * Input: * "" * Output: * NULL */ P4_PRIVATE(void) test_match_zeroormore_at_least_zero(void) { P4_Grammar* grammar = P4_CreateGrammar(); TEST_ASSERT_NOT_NULL(grammar); TEST_ASSERT_EQUAL( P4_Ok, ...
C
#include <stddef.h> // For NULL #include <stdlib.h> // For malloc() #include <string.h> #include <stdio.h> #include <sys/stat.h> // For stat #include "printer.h" #include "arguements.h" #include "directory.h" #include "list.h" #include "sort.h" static void freeItem(void *item) { free(item); }; int main(int numArg...
C
#include <stdio.h> int main() { int n,a,b,c; scanf("%d", &n); for(int i=0; i<n; i++) { scanf(" %d %d %d", &a, &b, &c); if(a+b == c || a-b == c || b-a == c || a*b == c || ((a/b == c) && (a%b == 0)) || ((b/a == c) && (b%a == 0))) { char string [] = "Possible"; puts(string); } else { char string [] =...
C
#include<stdio.h> int main() { int n,nn,sm; while(scanf("%d",&n)==1&&n!=0) { nn=n; while(nn/10>0) { sm=0; while(n) { sm=sm+n%10; n=n/10; } nn=sm; n=nn; } printf("%d\n",...
C
#include "libmx.h" void mx_print_arr(int *arr, int n, char *delim) { if (!arr) { return; } for (int i = 0; i < n; i++) { mx_printint(arr[i]); mx_printstr(delim); } mx_printchar('\n'); }
C
#include <stdlib.h> #include <stdio.h> typedef char *data; typedef int keyType; struct tree{ keyType key; data info; struct tree *left; struct tree *right; }; void insertKey(keyType key, data x, struct tree **T); void deleteKey(keyType key, struct tree **T); struct tree *search(keyType key, struct tree *T...
C
#pragma once #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <signal.h> #include <unistd.h> #include <stdlib.h> #include <assert.h> #include <stdio.h> #include <string.h> static bool g_stop = false; //SIGTERMźŴʱеѭ static void handle_term(int sig) { g_stop = true; } void blacklog...
C
#include"gauss.h" Matrix permuter(Matrix m, int row1,int row2){ E *tmp_ligne=m->mat[row1]; m->mat[row1]=m->mat[row2]; m->mat[row2]=tmp_ligne; return m; } Matrix multLigne(Matrix m,int row,float scalar){ int j; for(j=0;j<m->nb_columns;j++){ m->mat[row][j]*=scalar; } return m; } Matrix addMultLigne(M...
C
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> bool prime(int n) { int i = 2; for(; i < n / 2; i++) if(n % i == 0) return false; return true; } int main(int argc, char const *argv[]) { int TC, n, i, count; int* a; int* b; scanf("%d", &TC); while(TC--) { scanf("%d", &n); count = 0; a = ...
C
#include "ps2simulator.h" void ps2sim_init(unsigned char* datapin, unsigned char databit, unsigned char* clockpin, unsigned char clockbit) { // gather data_pin and clock_pin data_pin = datapin; data_bit = databit; clock_pin = clockpin; clock_bit = clockbit; // default them to high ...
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 "search_algos.h" /** * print_array - Prints an array * @array: Target array * @l: Left index of @array * @r: Right index of @array */ void print_array(int *array, size_t l, size_t r) { size_t i = 0; printf("Searching in array: "); for (i = l; i <= r; i++) { printf("%d", array[i]); if (i == r) ...
C
#include "checker.h" int is_sorted(t_stack **a) { int i; t_stack *tmp; tmp = *a; i = 0; while (i < list_size(*a) - 1) { if (tmp->number > tmp->next->number) return (0); tmp = tmp->next; i++; } return (1); } int up_number_position(t_stack **a, int a_size, int min, int max) { t_stack *tmp; i...
C
/*********************************************** Author: Vibishan Wigneswaran Date: 8/2/2020 Purpose: Create a program that uses top down approach and utilizes stub functions Time Spent: 5 minutes ***********************************************/ #include <stdio.h> int convert_length (int num); int convert_weig...
C
#include "simple_insertion.h" #include <stdlib.h> #include <stdio.h> #include <stdbool.h> // Declaration in simple_insertion.h typedef struct list_node { struct list_node* next; struct list_node* back; unsigned int value; } list_node_t; list_t* create_list() { list_t* newList = malloc(sizeof(list_...
C
/* display.c -- draw azimuth, elevation, and roll displays * * All functions assume a coordinate system of (0.0,0.0) to (1.0,1.0) */ #include <math.h> #include <GL/glut.h> #include "display.h" #include "fsim.h" static void drawRoundDisplay(); static void drawAxes(); static void drawMeter(float min, float max, floa...
C
#include <stdio.h> //求今年有多少个黑色星期五 13 //统计年份 int is_year(int year) { if (year % 400 == 0 || year % 4 == 0 && year % 100 != 0) return 1; return 0; } int count_year_days(int sy, int ey) { int days = 0; int i; for (i = sy; i < ey; i++) { days += 365 + is_year(i); } return days; } int count_month_days(int mont...
C
#include <stdio.h> #include<math.h> #include <string.h> #include <stdlib.h> #include <pthread.h> pthread_cond_t cond = PTHREAD_COND_INITIALIZER; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; double sum=0.0; int num_threads; int size, error; void* calculate(void* threadid){ int* tid = (int*)threadid; int i; ...
C
#include <func.h> void sigFunc(int signum){ printf("before sleep,signal %d is coming!\n",signum); sleep(3); printf("after sleep,signal %d is coming!\n",signum); } int main(){ if(signal(SIGINT,sigFunc)==SIG_ERR){ perror("signal"); return -1; } if(signal(SIGQUIT,sigFunc)==SIG_ERR) { perror("signal"); ret...
C
#include<omp.h> #include<stdio.h> #include<stdlib.h> int vecsize = 1000000; int vecsum_odd(int *vec_a, int vecsize) { int i; int sum = 0; #pragma omp parallel for reduction(+ : sum) for(i=0; i<vecsize; i++) if((i+1) % 2 != 0){ sum += vec_a[i]; } return sum; } int main(int argc, char *argv[]) { double...
C
// A demonstration of creating threads. #include <stdio.h> #include <pthread.h> #define NUM_OF_THREADS 10 // Function to carry out inside each thread. void * hello(void * tID) { printf("Hello from thread %d!\n", * ((int *) tID)); pthread_exit(NULL); } int main() { // Use a fixed array of thread IDs instead of an...
C
/* * mm-naive.c - The fastest, least memory-efficient malloc package. * * In this naive approach, a block is allocated by simply incrementing * the brk pointer. A block is pure payload. There are no headers or * footers. Blocks are never coalesced or reused. Realloc is * implemented directly using mm_malloc an...
C
// Room: /d/wuguan/npc/orange.c // Date: 99/05/30 by Byt inherit NPC; void create() { set_name("", ({ "ju zi","orange"}) ); set("gender", "" ); set("age", 22); set("long", "\n"); set("combat_exp", 100); set("attitude", "friendly"); setup(); carry_object("/clone/misc/cloth")->wear(); } void init() { obje...
C
#define F_CPU 8000000L #include <avr/io.h> #include <util/delay.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #define LCD_Dir DDRD /* Define LCD data port direction */ #define LCD_Port PORTD /* Define LCD data port */ #define RS PD0 /* Define Register Select pin */ #define EN PD1 /...
C
#include "../includes/philo.h" int ft_atoi(const char *str) { int i; long long res; int minus; i = 0; minus = 1; res = 0; while (str[i] == '\n' || str[i] == '\t' || str[i] == ' ' || str[i] == '\v' || str[i] == '\f' || str[i] == '\r') i++; if (str[i] == '-' || str[i] == '+') { if (str[i] == '-')...
C
#include <stdbool.h> #define SIZE 4 struct game { // game board char board[SIZE][SIZE]; // current score int score; }; /** * Adds random A or B tile to the game. This is very dumb function. * The board must have at least one empty tile. * If there is no empty tile, function will end in infinite lo...
C
#include <stdio.h> int main() { /* double quotes for strings */ /* An implicit null character \0 is placed at the end of the array */ /* If you put a null character inside a string, only the substring up to that point is printed */ char str_var1[] = "The cat is on the table"; char str_var2[] = "T...
C
#include <stdio.h> // 迭 Ҹ ϴ ԼԴϴ. void print_array(int* array, int size) { for (int i = 0; i < size; i++) { printf("%d ", array[i]); } printf("\n"); } // 迭 Ҹ ȯϴ ԼԴϴ. void swap_array(int* first, int* second, int size) { int temp; for (int i = 0; i < size; i++) { temp = first...
C
#include <stdio.h> #include <stdlib.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char *argv[]) { int i,fac=1,num=0; printf("Ingrese un numero "); scanf("%d",&num); for (i=1;i<=num;i++){ fac=fac*i; } printf("El factorial ...
C
#include <stdio.h> #include <stdbool.h> #define N 3 int magico(int a[20][20], int n){ int ref = 0; for(int i = 0; i < n; i++){ // referencia da primeira linha ref += a[i][0]; } for(int i = 1; i < n; i++){ // resto das linhas int linha = 0; for(int j = 0; j < n; j++){ linha += a[i][j]; ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* instructions2.c :+: :+: :+: ...
C
#include<stdio.h> #define filas 3 #define columnas 2 int main(){ int m,n; char array[filas][columnas]={{'X','O'},{'O','X'},{'X','X'}}; printf("Introduce una fila: "); scanf("%d",&m); printf("Introduce una columna: "); scanf("%d",&n); printf("En la fila %d, columna %d encontramos: %c\n",m,n,a...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "src/sobel.h" #define FORMAT_STRING_SIZE 4 /* * Function to read arguments into variables. * Input and Output files are necessary and threads number is optional. * Returns -1 in case of missed parameters. */ int read_args(int argc, char **argv, ...
C
/* Ex06_01.c */ // 함수를 사용해보자. #include <stdio.h> void print_hello(void) { printf("Hello world!\n"); } void printf_line(void) { int i; for( i = 1; i <= 20; i++ ) { printf("-"); } printf("\n"); } int main(void) { print_hello(); printf_line(); print_hello(); return 0; }
C
#include <gmp.h> #include <stdbool.h> #include <stdarg.h> #include <stdlib.h> #include "primes.h" bool isPrime(mpz_t n) { mpz_t i, c, r; mpz_init(i); mpz_init(c); mpz_init(r); if (mpz_cmp_si(n, 2) < 0) return false; if (mpz_cmp_si(n, 2) == 0) return true; mpz_mod_ui(r, n, 2); if (mpz_cmp_ui(r, 0) == 0) return...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include <ctype.h> typedef struct treeNode { char value[33]; struct treeNode *left, *right; }TreeNode; TreeNode* stack[300]; char name_variable[50][33]; int n = 0, value_variable[50]; TreeNode* newTreeNode(char *input){ TreeNod...
C
// Remove blank lines from the given file #include <stdio.h> #define TEMPFILE "tempfile.txt" int isnonblank(char * s) { int i; for(i=0; s[i] != 0; i ++) { if (!isspace(s[i])) return 1; // non-blank line } return 0; } main(int argc, char * argv[]) { char line[100], *p;...
C
#ifndef __VIDEO_GR_H #define __VIDEO_GR_H /** @defgroup video_gr video_gr * @{ * * Functions for outputing data to screen in graphics mode */ /** * @brief gets pointer to variable mouse_buffer * @return pointer to variable mouse_buffer */ unsigned getMouse_buffer(); /** * @brief gets pointer to variable dou...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(){ int t = 0, i = 0, k = 0, totalFrutas = 0, contFrutas = 1; double vlrDia = 0, mediaKg = 0, mediaVlr = 0, vlrTotal = 0; char frutas[10000]; //Leitura da qtd de casos de testes scanf("...
C
/************************************************************************* > File Name: 求荒岛面积.c > Author: > Mail: > Created Time: 2017年07月19日 星期三 15时29分22秒 ************************************************************************/ #include<stdio.h> int book[21][21]; int sum; int n,m; int a[21][21]; void dfs(int ...
C
#include "stdint.h" typedef enum game_play_level { STARTUP, LEVEL_1_TRANSITION, LEVEL_1, LEVEL_2_TRANSITION, LEVEL_2, LEVEL_3_TRANSITION, LEVEL_3, LEVEL_4_TRANSITION, LEVEL_4, GAME_WINNER, GAME_OVER_LEVEL, MAX_GAME_LEVELS, } game_play_level; /** * This function manages game play current level...
C
#include<stdio.h> void main() { int year; printf("Type Year:\n"); scanf("%d",&year); if(year%100!=0 && year%4==0) { printf("Leap year"); } else if(year%100==0 && year%400==0) { printf("Leap Year"); } else { printf("Not Leap Year"); ...
C
/* This code was written to support the book, "ARM Assembly for Embedded Applications", by Daniel W. Lewis. Permission is granted to freely share this software provided that this notice is not removed. This software is intended to be used with a run-time library adapted by the author from the STM Cube Librar...
C
/* ** EPITECH PROJECT, 2020 ** PSU_navy_2019 ** File description: ** print_map */ #include "navy.h" void print_map(char **map) { for (int i = 0; map[i] != NULL; i = i + 1) { for (int j = 0; map[i][j] != '\0'; j = j + 1) write(1 , &map[i][j], 1); my_putchar('\n'); } }
C
#include <stdio.h> #include <string.h> int main() { char stringArray[25]; printf("Please input a String!\n"); fgets(stringArray,25,stdin); printf("Input is %s and length is %d\n", stringArray, strlen(stringArray)); int length = strlen(stringArray); int i,j; char temp; for (i = length-...
C
#include<stdio.h> #define TRUE 1 #define FALSE 0 typedef int BOOL; BOOL chkPalindrome(char *str) { char *start=NULL; char *end=NULL; if(str==NULL) { return -1; } start=str; end=str; while(*end!='\0') { end++; } end--; while(start<=end) { if(*start!=*end) { break; } start++; end--; } ...
C
void infoUsrMenuInicial() { printf("#######################################################################\n"); printf("############################ MENU INICIAL #############################\n"); printf("#######################################################################\n\n"); printf("Por favor, seleccione ...
C
#include <assert.h> #include <iostream> using namespace std; int main() { const int n = 100; double bchoosek[n+1]; for (int k=0;k<n+1;k++) { bchoosek[k] = 0.0; } // compute binomial coefficients bchoosek[0] = 1.0; for (int k=0;k<n;k++) { cout << "n = " << k+1 << endl; for (int...
C
/* * hash.h * * Created on: Apr 23, 2017 * Author: cossete */ #ifndef HASH_H_ #define HASH_H_ #include <openssl/sha.h> #include <openssl/ripemd.h> void sha256(uint8_t *digest, const uint8_t *message, size_t len) { SHA256_CTX ctx; SHA256_Init(&ctx); SHA256_Update(&ctx, message, len); SHA256...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.c :+: :+: :+: ...
C
/* * headas_parstamp(fitsfile *fptr, FITS file pointer * int hdunum HDU in which to write HISTORY block (0 -> current HDU) * ) * * This routine writes a block of HISTORY keywords detailing the runtime values of all * parameters into the specified FITS file HDU. Any param...
C
#include "cdg.h" int max(int a, int b) { return a > b ? a : b; } void pushNodeListToStack(Stack * s, CDGNode * node) { assert(NULL != node); do { stackPush(s, &node); node = getNextNode(node); } while (node); } void postOrder(CDGNode * root, Stack * s) { if (NULL == root) return; Stack *temp...
C
/** * @file hashtable.c * @author Adam Sinclair * @created Sun April 8 2018 * @purpose Implementation of HashTable **/ #include "HashTableAPI.h" #include "debug.h" static unsigned int hash(const char* string, unsigned int size); HashTable initializeHashTable(int size, char* (*printFunction)(void* toBePrinted), v...
C
#include<stdio.h> #include<stdlib.h> # define max 4 int a[max],top; top=-1; void push(int val) { if(top==max-1) printf("\n Stack Overflow !! No values can be added now.\n"); else { top++; a[top]=val; } } void pop() { if(top==-1) printf("\n Stack underflow !! No elemen...
C
/* * string output to stderr only */ #include<stdio.h> int main(int argc,char** argv){ perror("Hello world\n"); return 0; }
C
/* Implementation of dequeue */ #include<stdio.h> #include<stdlib.h> #define MAX 1007 int dequeue[MAX]; int front = -1; int rear = -1; void insert_front(int item); void insert_rear(int item); int del_front(); int del_rear(); void display(); int isEmpty(); int isFull(); int main(){ int choice,item; while(1){ ...
C
/* ** EPITECH PROJECT, 2021 ** mylib ** File description: ** mylib */ #include "../../includes/utils.h" char *my_revstr(char *str) { char tmp; int index = 0; int len = my_strlen(str) - 1; while (index < len) { tmp = str[index]; str[index] = str[len]; str[len] = tmp; ++...
C
#include <stdio.h> #include <string.h> int main(void) { // char inputOne[5] = "B"; // char inputTwo[5] = "A"; // printf("문자열 비교 : %d\n", strcmp(inputOne, inputTwo)); char input[10] = "I Love You"; char result[5] = "Love"; strcpy(result, input); printf("문자열 복사 : %s\n", result); return 0;...
C
/******************************************************************************* * Stefan Bylund 2017 * * String utility functions. ******************************************************************************/ #include <stdint.h> #include <stdio.h> #include <string.h> #include <stropts.h> #include <ctype.h> #inc...
C
#include <stdint.h> #include "kassert.h" #include "rpi.h" #include "thread.h" #include "interrupt.h" #include "mmu.h" static core_tasks_ctlr core_tasks[CORE_NUM] = {0}; static const struct cpu_context empty_context = {0}; extern void ret_from_fork(void); extern void context_switch(struct task_struct* prev, struct tas...
C
//gcc BERKIN_MYMORE.c -o myMore // Created by berkin on 05.11.2016. // Finished by berkin on 14.11.2016 at 01:45 // Edited project name on 15.11.2016 at 18:42 #include "stdlib.h" #include "stdio.h" #include "unistd.h" #define BUFFER_SIZE 500 #define MAXIMUM_LINE_NUMBER 100 #define LINES_PER_TURN 24 int main(int arg...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* set_color.c :+: :+: :+: ...
C
#include "shm_sem.h" #include <assert.h> #include <errno.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <sys/ipc.h> #include <sys/sem.h> #include <unistd.h> void ReadData(const char* path_input, char* shared_memory, int id_sem); void ReadToSharedMemory(const char* path_input) { errno = 0...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* pipex.c :+: :+: :+: ...
C
SARA HASNAOUI MATRICOLA:322294 #include "mylib.h" #include <stdio.h> #include <stdlib.h> int main(){ int choose=0; system("clear"); do while{ printf("Scegli un opzione \n"); printf(" 1. Crea cunicoli,\n 2. Gioca, \n 3. Termina Gioco.\n"); printf(">$"); ...
C
#include <stdio.h> int main(void) { // your code goes here int year; scanf("%d",&year); if(year%4==0) printf("yes"); else printf("no"); return 0; }
C
#include <stdio.h> /********************************************** Program Nilai Deskripsi : Mengetahui grade dari sebuah nilai yang diinput IS : User siap menginput nilai FS : Di layar tertulis grade nilai Dibuat oleh : Nama : Diaz Adha Asri Prakoso Tanggal : 24 Oktober 2018 ******************************...
C
#include <stdio.h> #include <string.h> int main() { char str_a[20]; //Tableau de 20 caracteres char *pointer; //Pointeur pour un tablau de caractere char *pointer2; //Un seconde pointeur strcpy(str_a, "Hel...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_next_line.c :+: :+: :+: ...
C
#include <stdio.h> void printd(int n){ if(n<0){ putchar('-'); n = -n; } if(n/10) printd(n/10); putchar(n%10 + '0'); } void qsort(int v[], int left, int right){ int i, last; void swap(int v[], int i, int j); if(left>=right) return; swap(v, left, (left+right)/2); last = left; for(i=left+1; i<=right;...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* strmapi.c :+: :+: :+: ...
C
/* * Uart.h * * Created on: Jan 23, 2018 * Author: Karl Kobel */ #ifndef UART_H_ #define UART_H_ #include "stm32f4xx_ll_usart.h" typedef enum { // U_MATCH, // setup a callback to fire when a received character matches U_IDLE, // setup a callback to fire after line idle U_CHAR, // setup a callback for...
C
#include <time.h> #include <stdbool.h> clock_t startTime = 0; bool timedOut = true; bool harTimetUt() { clock_t tid = clock(); if(tid - startTime > 3000000 && !timedOut) { timedOut = true; return true; } return false; } void startTimer() { startTime = clock(); timedOut = false; }
C
/* gcc -Wall math.c -lm */ #include <stdio.h> #include <math.h> /* IMPORTANT! */ int main (void) { double x = pow (2.0, 3.0); /* need math.h */ printf ("Two cubed is %f\n", x); return 0; }
C
#include <stdio.h> #include <stdlib.h> main( int ac, char *av[] ) { int do_random, i, j, size, loop ; long fout, li ; if ( ac <= 3 ) { printf("Usage: %s size loop|max_random 0/1[1=random]\n", av[0] ) ; printf(" loop: number of size output in the case of the " "sequencial number\n") ; printf(" max_random...
C
/* Tail implementation for XV6 created by Siddharth Singh (01siddharthsingh@gmail.com) The reason why tail implementation is lot more difficult than head is because 1. We can't keep the whole file in memory as the file may be very large. We need to keep a array of pointers, each pointing to a //char array conta...
C
/* Binary Search Tree interface for use in CS136 Fall 2015 Author: Gordon V. Cormack Description: "struct inttree" is an abstract data type that maintains a binary search tree with distinct int elements. */ struct inttree; // definition is secret struct inttree * create(); /* return a new, empty B...
C
#include <criterion/criterion.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <assert.h> #include "quests/prereq.h" #include "quests/samples.h" /* tests init function for prereq struct */ Test(prereq, init) { int hp = 40; int level = 5; prereq_t prereq; int rc = prereq_init(&pr...
C
#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> void selfadd(int* pa) { (*pa)++; } int main() { int x = 1; selfadd(&x); printf("%d\n", x); return 0; } //int is_leap_year(int y) //{ // if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) // return 1; // else // return 0; // //} // // //int main() //{ /...
C
#include <stdio.h> void bubbleSort(int vetor[], int n); int main() { int vetor[] = {5, 2, 3, 1, 4, 7, 6}; bubbleSort(vetor[], 7); return 0; } void bubbleSort(int vetor[], int n) { int tmp, i, j; for(i = 0; i < n - 1; i++) { for(j = 0; j < n - i - 1; j++) { if(vetor[j] > v...
C
/* wordwrap.c - given a proportional font and a window of a certain size, figure out how many words we can fit in a line. with some utilities for justification of text */ #define WORDWRAP_INTERNALS #include "wordwrap.h" typedef struct wwdata { int wid; /* wrap window width */ int wid_sp; /* precalc w...
C
/* Copyright (c) Centre National de la Recherche Scientifique (CNRS, France). 2010. Copyright (c) Members of the EGEE Collaboration. 2008-2010. See http://www.eu-egee.org/partners/ for details on the copyright holders. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file excep...
C
/* ** EPITECH PROJECT, 2019 ** libmy ** File description: ** returns the factorial of a number */ int factorial(int nb) { int nbcpy = nb; if (nb == 0) { return (1); } else if (nb < 0) { return (0); } for (int i = 1; i < nbcpy; i++) { nb *= i; } return (nb); }
C
#include "main.h" // Démarrer le mode graphique de Ncurses void initialiser_ncurses(void) { initscr(); // Initialisation de l'écran standard de Ncurses (stdscr) noecho(); // Ne pas écrire ce que l'utilisateur tape dans la saisie curs_set(false); // Cacher le curseur // Si le terminal ne supporte pâs les couleurs,...
C
/* * Copyright (c) 1993 Colin Plumb. All rights reserved. * For licensing and other legal details, see the file legal.c. * * MS-DOS non-echoing keyboard routines. */ #include <conio.h> /* For getch() and kbhit() */ #include <signal.h> /* For raise() */ #ifdef _MSC_VER #include <time.h> /* For clock() */ #else #...
C
#ifndef CORTHREAD_LOCK_INCLUDE_H #define CORTHREAD_LOCK_INCLUDE_H #include "corthread_define.h" #ifdef __cplusplus extern "C" { #endif /* corthread locking */ /** * corthread mutex, thread unsafety, one corthread mutex can only be used in the * same thread, otherwise the result is unpredictable */ typedef str...
C
/* * Copyright (c) 2009 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. * * Author(s): Torsten Hoefler <htor@cs.indiana.edu> * */ #include <inttypes.h> #include <stdio.h> #include "calibrate.h" #define...
C
#define PY_SSIZE_T_CLEAN #include <Python.h> /* Prototype for main function */ static PyObject* checksum(PyObject*, PyObject*); /* List methods and module definition */ static PyMethodDef MyMethods[] = { {"checksum", checksum, METH_VARARGS, "Compute an IPv4 checksum of arbitrary data."}, {NULL, NULL, 0, NULL} /* S...
C
/* copycat_cli.c * Caleb Zulawski * * Handles command line argument parsing, logging, * and displaying errors. */ #include "copycat.h" /* Library functions */ #include <stdio.h> // sscanf, printf #include <getopt.h> // getopt #include <stdlib.h> // exit #include <string.h> // strerror /* Parses co...
C
#include<stdio.h> void disp(int *, int ); int main() { int a[5]={1,2,3,4,5}; disp(&a[0],5); } void disp(int *a, int n) { int i; for(i=0;i<n;i++) ++*a; printf("The values of the array..\n"); for(i=0;i<n;i++) printf(" %d",a[i]); printf("\n"); }
C
/* tst-strptime2 - Test strptime %z timezone offset specifier. */ #include <limits.h> #include <stdbool.h> #include <stdio.h> #include <time.h> #include <libc-diag.h> /* Dummy string is used to match strptime's %s specifier. */ static const char dummy_string[] = "1113472456"; /* buffer_size contains the maximum t...