language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#ifndef TEXTBUFFER_H #define TEXTBUFFER_H typedef struct textbuffer *TB; /* Allocate a new textbuffer whose contents is initialised with the text given * in the array. */ TB newTB (char text[]); /* Free the memory occupied by the given textbuffer. It is an error to access * the buffer afterwards. */ void releas...
C
#include <stdio.h> #include <stdbool.h> #include <stm32f4xx.h> #include "uart.h" #include "flash.h" #define FLASH_USER_START_ADDR ADDR_FLASH_SECTOR_2 #define FLASH_USER_END_ADDR ADDR_FLASH_SECTOR_5 void print_flash(uint32_t start_address, uint32_t end_address) { uint32_t addr = start_address; uint32_t data_read; w...
C
#include <pthread.h> #include <stdio.h> #include <signal.h> #include <semaphore.h> #include <limits.h> pthread_t t1, t2, t3, t4, t5, t6, t7, t8, t9, t10; sem_t x; sem_t b1; sem_t b2; int global = 0; int pthread_cnt = 0; void* helperFun(void* args){ for(int i = 0; i <= 10; i++){ sem_wait(&x); global++;...
C
#include <stdio.h> #define T 10 /* 2. Desenvolva um programa que faça a leitura de 10 valores no vetor A. Construir um vetor B do mesmo tipo, observando a seguinte formatação: a. Se o valor do índice for par, o valor deverá ser multiplicado por 5; b. Se o valor do índice for ímpar, deverá ser somado com 5. ...
C
// ESCLAVO Comunicacin SPI //#include <18F4550.H> #include <16F887.H> #device adc=8 #fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP #use delay(crystal=4000000) #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) #byte SSPBUF = 0x13 // Direccin del Registro para 16F877 //#byte SSPBUF = 0xFC9 // Direccin del Reg...
C
#include <stdio.h> int main() { int n, i, j, s = 0; int a[10][10]; printf("Enter the size of Identity Matrix : "); scanf("%d",&n); printf("Enter the matrix elements : "); for(i = 0; i < n ; i++) { for(j=0; j< n; j++) { scanf("%d",&a[i][j]); } } pr...
C
#include <stdio.h> #include <stdlib.h> #include <conio.h> #include <math.h> //Segunda escritura del programa, sigue mandando error //Empec con esto a las 6 de la maana, son las 8 y no hay progreso, ni con Switch ni con else o for //Este ejercicio es posible, pero por el momento, algo se escapa de mis manos //Sospecho ...
C
#include <reg52.h> #define uchar unsigned char #define uint unsigned int sbit ADDR0 = P1^0; sbit ADDR1 = P1^1; sbit ADDR2 = P1^2; sbit ADDR3 = P1^3; sbit ENLED = P1^4; signed long frequency=0; bit start=0; //ʱģʽ unsigned char Pulse = 0; unsigned char T0RH=0; unsigned char T0RL=0; unsigned char code LedChar[] = { /...
C
#include<stdio> #include<conio.h> int main(){ int n,i,j,temp; int array[5]={3,4,7,8,9}; for(i=0;i<=n;i++){ for(j=1;j<=n-1;j++) { temp = arr[j]; arr[j] = arr[j-1]; arr[j-1] = temp; j--; } printf("Sorted list in assanding orderd:\n",arr(i)); } }
C
#include "../api.h" #include <stdio.h> static int integer_add(jack_state_t *state) { printf("\nInside add call\n"); jack_dump_state(state); int sum = 0; for (int i = 0; i < state->stack->top; ++i) { sum += jack_get_integer(state, i); } jack_new_integer(state, sum); return 1; } int jack_test(jack_sta...
C
int main() { int x[1000],y[1000],i=1,j,k,num[1000]={0},max=0; cin>>x[0]; while(cin.peek()!='\n'){ cin.get(); cin>>x[i++]; } for(j=0;j<i;j++){ cin.get(); cin>>y[j]; } for(k=0;k<1000;k++) for(j=0;j<i;j++) { if(k>=x[j]&&k<y[j]) num[k]++; } for(j=0;j<1000;j++) if...
C
//另一个思路是,全部先bw间隔放好,之后把-添加进去! #include<stdio.h> #define MAX 200 int main() { int n,m; scanf("%d%d",&n,&m); char chess[MAX][MAX]; int i,j; for(i=0; i<n; i++) { scanf("%s",chess[i]); } char chess2[MAX][MAX]; for(i=0; i<n; i++) { for(j=0; j<m; j++) { if((i+j) ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> #include <semaphore.h> #include <unistd.h> #define SIZE 100 void* reader(void* param); void* writer(void* param); FILE* inout; sem_t mutex, wrt; int data = 0, readcount = 0; char task[SIZE][SIZE]; int main(int argc, char *argv[]) { in...
C
/*-------------------------------------------------------------------------* * File: mstimer.c *-------------------------------------------------------------------------* * Description: * Using a timer, provide a one millisecond accurate timer. *-----------------------------------------------------------...
C
#include <cs50.h> #include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> int shift(char c); string error_message = "Usage: ./vigenere keyword\n"; int main(int argc, string argv[]) { //check if argv has an input if(argv[1] == NULL) { printf("%s", error_messag...
C
#ifndef _ELEMENT_A #define _ELEMENT_A typedef int ElementA; void afficherElementA(ElementA e); /* Preconditions : aucune Postconditions : e est affiche a l'ecran sans retour a la ligne */ int estInferieurElementA(ElementA e1, ElementA e2); /* Preconditions : aucune Resultat : 1 si e1 < e2, 0 sinon */ int est...
C
/*定义函数数组*/ /*函数数组的成员必须是同一种类型的函数,即形参相同,但是函数名不同, 返回值不同会产生警告,但是可以通过编译运行*/ #include <stdio.h> int fun1( int a,int b ) { return a+b; } float fun2( int a,int b) { return a-b; } int main( ) { int (* fun_arry[ 2 ] )(int,int); ...
C
#include "c4_5.h" /* compute the GAIN of class variable when it is divided into several subsets by attribute variable */ //function: compute gain for class variable divided by boolean attribute variable //arguments: // attribvar - attribute variable // classvar - class variable // n - length of dataset float gainC...
C
#include "apue.h" #include <stdio.h> #include <unistd.h> #include <pthread.h> pthread_mutex_t hashlock = PTHREAD_MUTEX_INITIALIZER; int total = 0; void* tfn(void * arg) { int num = *((int *) arg); long d2num = 3*num; pthread_mutex_lock(&hashlock); printf("In thread %lu arg:%d.\n", (unsigned long)pthread_self(), n...
C
#include "pawn.h" #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include "board.h" #include "communicator.h" #include "types.h" /** * Returns the position where a pawn should be moved to. * * @param game_board The reference to the game board. * @param current_position The reference to the current po...
C
#include <stdio.h> #include <sys/stat.h> int main (void) { if (mkfifo("minhaFifo", S_IRUSR | S_IWUSR) == 0) { puts ("FIFO criada com sucesso"); } if (mkfifo("minhaFifo2", S_IRUSR | S_IWUSR) == 0) { puts ("FIFO criada com sucesso"); } if (mkfifo("minhaFifo3", S_IRUSR | S_IWUSR) == 0) { ...
C
# include <stdio.h> # pragma warning (disable:4996) // Լ Ű 迭 (迭 ũ ) void print_array(int arr[], int size) { for (int i = 0; i < size; i++) printf("%d ", arr[i]); printf("\n"); } // ϴ Լ // ־ ׸ ϴ void sort_array(int arr[], int size) { int index_min, tmp; for (int i = 0; i < size - 1; i++) { index_min ...
C
/* x_unmou.c - x_unmou */ #include <conf.h> #include <kernel.h> #include <io.h> #include <name.h> /*------------------------------------------------------------------------ * x_unmou - (command unmount) remove a prefix from the namespace table *-------------------------------------------------------------------...
C
#ifndef _COMPRESS_H_ #define _COMPRESS_H_ // 256 ascii character + 1 pseudo-EOF #define MAX_LEAF 257 #include <stdbool.h> #include <stdio.h> // leaf node. typedef struct h_node { int id; // ASCII code. pseudo-EOF is 256 int count; // times of character char code[30]; // Huffman code struct h_node* parent; stru...
C
#include "bmp.h" #include <stdio.h> #include <stdlib.h> #include <sys/time.h> //Print info about how to use the app void usage(){ printf( "Usage: progName <infile> <outfile> [parallel] [threshold] [filter]\n" ); printf( "<infile> = Input bmp file\n" ); printf( "<outfile> = Output bmp file\n" ); } int main...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* split.c :+: :+: :+: ...
C
#include <stdio.h> int main() { void *a; int da = 1; a = (void *)&da; printf("da=%d\n", da); printf("a=%d\n", *(int *)a); }
C
// // Created by Thiago on 03/04/2021. // #ifndef ALGORITMO_TCC_2_OPTIMAL_H #define ALGORITMO_TCC_2_OPTIMAL_H #include "../data_structures/solution.h" #include "../data_structures/optmized-matrix.h" #include "../utils/distance.h" /** * Realiza o movimento 2-Optimal em uma solução, que consiste em retirar duas arest...
C
#include <stdio.h> #include <string.h> int main(){ char abc[] = "When the going gets tough, the tough stay put!"; char check[20]; int count = 0; scanf("%[^\n]",check); int i,j,iscorr; /*for(i=0;i<strlen(abc);i++){ if(check[i] <= 'Z') check[i] += 22; }*/ for(i = 0;i<strlen(abc);i...
C
#include <stdio.h> /* 定义一个double a[3][4]; (1)打印第一维数组每个元素的起始地址 (2)打印第二维数组每个元素的起始地址 (3)打印第一维数组的地址地址 (4)从键盘输入数组,输出每个元素的内容 (5)计算数组的大小,并输出 */ int main() { int a[4][2]={1,2,3,4,5,6,7,8}; int i,j; printf("第一维数组每个元素的起始地址:\n"); for(i=0;i<4;i++) { printf("&a[%d]=%p\n",i,&a[i]); } printf("\n===...
C
typedef struct avl_node { void *data; //pointer to arbitrary data struct avl_node *left; //left pointer struct avl_node *right; //right pointer int height; //height of leaf nodes are 0; } avl_node; typedef struct avl_tree { int (*cmp_function)(void *,void *); //pointer to a function that will compar...
C
#include <stdio.h> #include <stdlib.h> long int* Load_File(char *Filename, int* Size){ FILE* inf = fopen(Filename, "r"); fscanf(inf, "%d", Size); //Gets size from file long int* Array = malloc(sizeof(long int) * (*Size)); //Allocs array for (int i = 0; i < *Size; i++){ //Fills array with file f...
C
//a program to convert celsius to fahrenheit #include <stdio.h> int main (void) { float temp_f; //float for more precision + this variable will represent the temperature in fahrenheit float temp_c; //float for more precision + this variable will represent the temperature in celsius printf ("Please...
C
// // main.c // identity matrix // // Created by Pushpa Jain on 20/01/21. // Copyright © 2021 Pushpa Jain. All rights reserved. // #include <stdio.h> void main() { int i,j,a[3][3],flag=1; printf("enter matrix values"); for(i=0; i<3; i++) { for(j=0; j<3; j++) { scanf("%d"...
C
#include "../ft_printf.h" char *ft_itoa_hexa(t_tab *tab, char *s, unsigned long n, int base) { int l; l = 0; if (n == 0) { s[l] = '0'; l++; } while (n > 0) { if (base > 10 && (n % base >= 10)) { if (tab->hexa == 0) s[l] = (n % base) + 87; else s[l] = (n % base) + 87 - ...
C
#include<stdio.h> int fact(); int main() { int n; printf("enter any number"); scanf_s("%d", &n); printf("The factorial of %d is %d", n, fact(n)); getch(); return 0; } int fact(int a) { if (a > 1) return a * fact(a - 1); else return 1; }
C
#include <stdio.h> int cnt(int n){ if(n <= 0) return 0; return n*n+cnt(n-1); } int main(void){ int n; scanf("%d", &n); printf("%d\n", cnt(n)); return 0; }
C
#pragma once struct FCoordinate; struct ICoordinate { int x = 0; int y = 0; inline ICoordinate add(const ICoordinate other) const { return ICoordinate{this->x + other.x, this->y + other.y}; } inline ICoordinate operator+(const ICoordinate other) const { return this->add(other); } }; struct FCoo...
C
#include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> #include <curl/curl.h> #include <json/json.h> #define SPACE ' ' //Function used by libcurl to allocate memory to data received from the HTTP response struct MemoryStruct { char *memory; size_t size; }; static size_t WriteMemoryCallb...
C
#include <stdlib.h> #include <stdio.h> #include <sys/sem.h> #include <sys/ipc.h> #include <sys/types.h> int main(int argc, char **argv) { key_t key = ftok("/main", 1); int semId = semget(key, 1, IPC_CREAT | 0666); struct sembuf *sops; sops->sem_num = 0; sops->sem_op = -1; sops->sem_flg = IPC_NO...
C
/* * strUtil.c -- * * Copyright 1989 Regents of the University of California * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies. The University of California...
C
#include <string.h> #include <stdio.h> #include <stdbool.h> #include "debug.c" #include "memory.c" typedef bool Success; typedef struct string { const char* buffer; int lenght; } String; void string_from_buffer(String *s, const char* c) { s->buffer = c; s->lenght = strlen(c); } void string_from_char(String *s,...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* solve_tetri.c :+: :+: :+: ...
C
/* *208539270 yardenbakish *208983700 tamircohen1 * initialize.c * * This function initializes all of the neccessary data structures in order to implement the K-means algorithm. * The function's caller is the function first run by our C extension * The function passes along all of the data structures forward *...
C
#include<stdio.h> // #include<string.h> void main(){ int arr[] = {12, 11, 13, 5, 6,8,8,40,12}; int pos=0,temp,temp2; int n = sizeof(arr)/sizeof(arr[0]); while(pos!=(n-1)){ pos=0; for(int i=0;i<n-1;i++){ temp = arr[i]; if(arr[i]>arr[i+1]){ arr[i]=arr[i+1]; ...
C
#include "tcpSvr.h" char *FindMessageTrailer(unsigned char *Buf, int len, unsigned char ch, int charset) { register int i; UCHAR *p = Buf+len,*pAscii; for(i=len; i>=0 ; i--,p--) { if(*p==ch){ int tLen = len - (p+1 - Buf); if(tLen) { if(charset == CHARSET_EBCDIC){ pAscii = (UCHAR *)malloc(tLen+...
C
//+Dep3_prog1basico+// #incluide <studio.h> int main[] [ int a,b,c; printf ("\n escribe el valor de a"); scanf("%d,&a"); printf ("\n escribe el valor de b"); scanf("%d,&b"); printf ("\n escribe el valor de c"); scanf("%d,&c"); a = a+ 1; b = b+ 2; c = c+ c; ...
C
#include <stdio.h> #include <time.h> int main_condition(void) { /* // źٰ . л / Ϲ (Ϲ : 20) int age = 15; //if() {...} else {...} if (age >= 20) { printf("Ϲ Դϴ."); } else { printf("л Դϴ."); }*/ // ʵл(8-13) л(14-16) л(17-19)? // if/ else if/ else /* int age = 8; if (age >= 8 && age <= 13) { printf(...
C
/** * Esse programa recebe um nmero inteiro como entrada e * diz se esse nmero primo ou no. Essa soluo no * traz otimizaes. O procedimento para testar se um nmero * primo ser verificar se eles possui algum divisor inteiro at n/2. */ //Incluso das bibliotecas #include<stdio.h> //Funo Principal de um progra...
C
/* * tosfs/tosfs.h * * * (c) 2012 David Picard - picard@ensea.fr * */ #ifndef __TOSFS__ #define __TOSFS__ #include <linux/types.h> #define TOSFS_MAGIC 0x1b19b10c #define TOSFS_BLOCK_SIZE 4096 #define TOSFS_SUPERBLOCK 0 #define TOSFS_INODE_BLOCK 1 #define TOSFS_ROOT_INODE 1 #define TOSFS_ROOT_BLOCK 2 #defin...
C
#include <stdint.h> #include "inc/tm4c123gh6pm.h" #define SIZE 128 uint32_t SrcBuf[SIZE],DestBuf[SIZE]; int main(void){ volatile uint32_t delay; uint32_t i,t; PLL_Init(); // now running at 80 MHz SYSCTL_RCGCGPIO_R |= SYSCTL_RCGC2_GPIOF; // enable Port F clock delay = SYSCTL_RCGCGPIO_R; // all...
C
#include "lists.h" /** * reverse_listint - function that reverses a listint_t linked list. * @head: Pointer to the head of the list. * * Return: a pointer to the first node of the reversed list. */ listint_t *reverse_listint(listint_t **head) { listint_t *temp, *cursor; temp = *head; cursor = *head; *head ...
C
#include"List.h" void SlistPrint(SlistNode *Plist) { while (Plist->next) { printf("%d->", Plist->data); Plist = Plist->next; } printf("NULL\n"); } SlistNode* SlistBuyNode(SLTdataType x) { SlistNode * SlistnewNode = NULL; SlistnewNode = (SlistNode*)malloc(sizeof(SlistNode)); SlistnewNode->data = x; SlistnewN...
C
#include <stdio.h> #include <stdlib.h> void selectionSort(int a[100], int n){ int min,temp; for (int i=0;i<n-1;i++){ min = i; for(int j=i+1;j<n;j++){ if(a[j]<a[min]){ min=j; } } temp=a[i]; a[i]=a[min]; a[min]=temp; } } int main(){ int x; printf("\nEnter size of array: ")...
C
#include "paging.h" #include "../cpu/isr.h" #include "../kernel/panic.h" #include "../drivers/screen.h" #include "../libc/string.h" #include "../libc/mem.h" /* State for managing physical pages. */ // Current position (stack pointer) in physical addr stack. static uintptr_t stack_phys_loc = STACK_PADDR; // Max po...
C
#include <stdio.h> int i = 5; char text[255]; void foo(void); int main(void) { printf(" %i ", i); foo(); printf(" %i \n", i); return 0; }
C
#include <stdio.h> #include <ctype.h> int main(int counter, char *words[]) { for (int i = 1; i<counter; ++i){ for (int j=0; words[i][j]!=0; ++j) { if(isupper(words[i][j])){ words[i][j]= tolower(words[i][j]); printf("_"); } printf("%c", words[i][j]); } printf("\n"); } return 0; }
C
#include "heap_debug.h" #include "node_debug.h" #include "allocator_debug.h" #include <string.h> /* static inline void push_(BlockHeader** tgt, BlockHeader* b) { */ /* b->next = *tgt; */ /* *tgt = b; */ /* } */ /* static inline BlockHeader* pop_(BlockHeader** src) { */ /* BlockHeader* b = *src; */ /* ...
C
#include "timer.h" #include "common.h" #include <stdlib.h> #include <stdint.h> #include <sys/timerfd.h> #include <sys/epoll.h> #include <unistd.h> static int timerfd; static int timerstate = TIMER_OFF; int timersetup(int epollfd) { struct epoll_event ev; timerfd = timerfd_create(CLOCK_REALTIME, 0); if...
C
#include <stdio.h> typedef struct { int x; int y; } coordonnee; void fonction(coordonnee *fi); int main() { coordonnee i; i.x = 0; i.y = 0; coordonnee *ptri = &i; printf("Avant la fonction, la structure a pour adresse %x et valeurs [%d, %d].\n", &i, i.x, i.y); // exemple de passage ...
C
#include <stdio.h> #include <sys/ioctl.h> int main(int argc, char *argv[]) { struct winsize ws; /* * ioctl(2)システムコールを使ってウィンドウサイズ * (ターミナルサイズ)を取得し、構造体winsize wsに * 値を保存している。 */ ioctl(1, TIOCGWINSZ, &ws); printf("ws_row: %d, ws_col: %d\n", ws.ws_row, ws.ws_col); }
C
#include <stdio.h> int main(void) { char str[5] = { 'O', 'X', 'X', 'O', 'X'}; char answer[5] = { 'O', 'O', 'X', 'O', 'X' }; int score = 0; for (int i = 0; i < 5; i++) { if (str[i] == answer[i]) { score = score + 10; } } printf(" : %d", score); }
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <omp.h> #include "PE_functions_15350.c" int main(int narg, char *argv[]) { char* filename; double d,eps; int n; double *xk; filename = argv[1]; d = atof(argv[2]); eps = atof(argv[3]); n = atoi(argv[4]); if (narg < 2) { printf("F...
C
/******************************************************* ** Created by Nick Major 0879292 ** A2, main ** Due: 02/13/17 *******************************************************/ #include <string.h> #include <stdio.h> #include <time.h> struct Set { double x; double y; }; int * readArray(int *size); struc...
C
#include<stdio.h> struct MY_TYPE { short int value; int stuff; } MY_TYPE; void main() { struct MY_TYPE MY_TYPE; MY_TYPE.value = 15; MY_TYPE.stuff = 13; function(); { extern struct MY_TYPE MY_TYPE; printf("%d", MY_TYPE.value); } printf("\n\n%d %d", MY_TYPE.value, MY_TYPE....
C
#include<stdio.h> void fibonacci(int n); int main(){ int n; printf("enter n"); scanf("%d",&n); printf("fibonacci series"); printf("\n%d\n",0); fibonacci(n); } void fibonacci(int n) { static int first=0,second=1,sum;//else for each recursion first is 0 and second is 1. //static keeps only ...
C
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<assert.h> #include<getWord.h> #include"ht.h" struct KVpair* array; //hold all the wordpairs int arrayIndex = 0; int main( int argc, char **argv){ FILE* fp; char* myWord; //streaming word char* fHalf; //first part of word pair char* sHalf; ...
C
#include<stdio.h> int show(int n,int m) { int s,b,i,j,k; s=0; j=n; while(j!=0) { i=j%10; i=i*i*i; s=s+i; j=j/10; } if(s==n) { printf("%d is a armstrong no.",n); } else { printf("%d is not a armstrong no.", n ...
C
// // ex5_task6.c // Infor2_Exercise // // Created by 谭特 on 17/5/7. // Copyright © 2017年 谭特. All rights reserved. // #include <stdlib.h> #include <stdio.h> #define black 0 #define red 1 struct rbNode { int key; int color; struct rbNode* left; struct rbNode* right; struct rbNode* parent; }; s...
C
#include <stdio.h> unsigned int rotate_left(unsigned int i, int n); unsigned int rotate_right(unsigned int i, int n); int main(){ unsigned int n = 5; printf("%u, %u\n", n, rotate_left(n, 3)); printf("%u, %u\n", n, rotate_right(n, 3)); return 0; } unsigned int rotate_left(unsigned int i, int n){ unsigned int...
C
#define MCU 'attiny84' #define F_CPU 1000000UL #include "include/macros.h" #include <avr/io.h> #include <avr/interrupt.h> #include <stdio.h> #include <stdlib.h> #include <util/delay.h> #define ENCODER_A PA1 //PCINT1 #define ENCODER_B PA2 //PCINT2 #define ENCODER_PIN PINA #define ENCODER_DDR DDRA #defi...
C
#include<stdio.h> int main(){ int t; scanf("%d",&t); while(t--){ int n; scanf("%d",&n); int array[n]; for(int i=0;i<n;i++) scanf("%d",&array[i]); int zero_count = 0,j=1; for(int i=0;i<n;i++){ if(array[i]==0) zero_count++; else if(array[i]==array[j]){ ...
C
#include<stdio.h> #include<stdlib.h> typedef struct Node { int data; struct Node* next; struct Node* prev; }Node; // create a node with given integer Node* NewNode(int data){ Node* new_node = (Node*)malloc(sizeof(Node)); new_node->data = data; new_node->next = NULL; new_node->prev = NULL; return new_node; } ...
C
#ifndef F_CPU #define F_CPU 4915200 #include <stdio.h> #include <avr/io.h> #include <stdlib.h> #include <util/delay.h> #include "oled.h" #include "buttons.h" #include "adc.h" #include "highscore.h" int char_selector = 0; int array_pos = 0; volatile uint8_t *score_data = (uint8_t *) 0x1C00; //OLED Data s...
C
/* make sure to set Env.DEBUG on! */ /* this file is meant to stress test the compile-time evaluation of * constant expressions and to make sure that the compiler figures out * the sizes of types. * * Note: all type sizes are rounded up to the nearest multiple of 4 bytes. * this is simplifies any alignment...
C
#include "clipper.h" void clip(render_context *rc, int width, int height) { } // int i, i1, i3; // bool c1, c2, c3; // Vec3 *p1, *p2, *p3, r1, r2, nr1, nr2; // Vec2 tr1, tr2; // Vec3 oob = {-1, -1, 0}; // for(i1 = 0, i3 = 0; i1 < rc->mlist->len; i1++, i3++) { // // c1 = false; c2 = false; c3 =...
C
#include<stdio.h> #include<time.h> #include<stdlib.h> #define NUMBER 20000 int main(void){ clock_t t_start,t_end; t_start = clock(); srand((unsigned)time(NULL)); int data[NUMBER]={0}; //乱数生成 for(int i=0;i<NUMBER;i++){ data[i]=rand(); } //基数ソート int flag=1; for(int keta=1;keta<5...
C
#include <stdio.h> #include <cs50.h> int main(void) { // int numbers[50]; -- Cannot do that, user might want to enter 51 //Array is a chunk of memory int *numbers = NULL; //numbers really is just a pointer to the chunk of memory, there is no array; this pointer points to 0x00. // you can point thi...
C
#include <SDL.h> #include <SDL_net.h> #include <stdio.h> #include <string.h> #include "TCP.h" #include "game.h" #include "definition.h" void sendMessage(int player_id, char incommingMsg[]) { IPaddress ip; TCPsocket client; char completeMsg[100] = "HELLO"; int portNr = SENDPORT + player_id; //varje spelare skic...
C
#include "cmsis_os2.h" // CMSIS RTOS header file #include "Objects.h" #include "Board_GLCD.h" #define XOFFSETT 16*12 #define YOFFSETT 0 #define XOFFSETM 32 #define YOFFSETM 24*2 #define XOFFSETW 0 #define YOFFSETW 297 #define CHARWIDTH 16 #define CHARHEIGHT 24 #define LCDX 320 #d...
C
#include <stdlib.h> #include <string.h> #include "line.h" #include "asmbl.h" #include "misc.h" #include "symbols.h" #include "opcodes.h" #include "globals.h" symbol_t *init_macro(); symbol_t *init_data(enum SYMBOL type); symbol_t *init_code(); symbol_t * init_symbol(enum SYMBOL type) { symbol_t ...
C
#include <stdlib.h> int random_int(int ceiling) { return rand() % ceiling; } size_t random_index(size_t ceiling) { size_t high = (size_t) rand(); size_t low = (size_t) rand(); size_t big = (high << 32) | low; return big % ceiling; }
C
// Name: Christopher Boyd // Date: April 6, 2020 // Title: Lab5 - matrix task // Description: Computes the dot product of matrices A and B as matrix C. // One thread is created per row. // ---------------------------------------------------------------------------- #include <stdio.h> #include <stdlib.h> #include <time...
C
/* #include<stdio.h> #include<string.h> */ #include<sys/types.h> #include<sys/stat.h> #include<fcntl.h> #include<unistd.h> #include "ft.h" void ft_putstr_fd(int fd, char *str) { write(fd, str, ft_strlen(str)); } int main() { int fd; fd = open("42", O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR); ...
C
/* mon_cnf_file.c * part of watchlist_monitor * uses inotify to monitor the config file for changes, reloads it when changed * uses kill(child_pid,SIGUSR1) to signal the reload. */ #include "watchlist_monitor.h" #include <sys/inotify.h> #include <sys/select.h> #define EVENT_SIZE (sizeof(struct inotify_event)) #define...
C
/** * \file funciones.c * \brief * \details Descripcion detallada del archivo * \author * \date 23-09-2017 09:54:06 */ int contm1 = 0 ;int ninguna = 0 ;int m0 = 0 ;int Flagcorriente = 0 ; #include "funciones.h" //Implementacion Switch-Case /** * \fn void maquina_estado() * \brief Implementacion Switch-Case *...
C
/* 09 Stereo Test.c Run 2 sound processes, one for each channel. Play a brief tone in each ear, one from each process. Then, create a tone that fades in volume and frequency from left to right. */ #include "simpletools.h" // Library includes #include "badgetools.h" #include "sound.h" s...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> struct county{ char *longName; char *shortName; unsigned int population; }; struct town{ char *name; unsigned int population; struct county aCounty; }; int main(void) { //declare variables to read files FILE *file_towns; FILE *f...
C
#include <Windows.h> #include <process.h> // #include <stdlib.h> struct MyStruct { int num; }; void run(void *p) { int *px = (int *)p; //ָ͵ת //printf("߳%d\n",*px); char str[100] = { 0 }; sprintf(str," ߳%d",*px); MessageBox(0, str, "߳", 0); } void main01() { /*for (int i = 0; i < 5; i++) //run(NULL);*/ for...
C
#include <stdio.h> int main(){ long int query; while (scanf("%ld", &query) != EOF) { if(query == 2){ query = 0; } else{ query = (query + 1) / 2; query = 3 * ((2 * query * query) - 1) - 6; } printf("%ld\n", query); } return 0; }
C
#include <stdio.h> #include <stdlib.h> #define SPACE ' ' #define TAB '\t' /* K&R 1-20 detab: replaces tabs with spaces */ int Spaces(int N, int position); int main( int argc, char *argv[] ) { int N; //columns per tabstop int position, spaces, c, a; // N is set via command line or defaults to 5 if (argc < 2...
C
#include <stdio.h> #include <string.h> #define M 10000 #define N 1000 char buf[M]; char *A[N]; void swap(char *a[], int i, int j) { char *tmp = a[i]; a[i] = a[j]; a[j] = tmp; } int partition(char *a[], int l, int r) { int i, j; for (j=l, i=l+1; i<=r; i++) if (strcmp(a[i],a[l])<0) swap(a, i, ++j); ...
C
#define NRANSI #include "nrutil.h" void bcuint(double y[], double y1[], double y2[], double y12[], double x1l, double x1u, double x2l, double x2u, double x1, double x2, double *ansy, double *ansy1, double *ansy2) { void bcucof(double y[], double y1[], double y2[], double y12[], double d1, double d2, double **c); ...
C
#include<stdlib.h> #include<stdio.h> #define TAM 8 int main(){ int vetor[TAM]; int i, numero = 0, alteracoes = 0; for(i= 0; i < TAM; i++){ printf("Digite um numero para entrar no vetor: "); scanf("%d", &numero); vetor[i] = numero; } ...
C
#include<stdio.h> #define SIZE 150 struct student { int roll; unsigned int marks[2]; unsigned int total; char name[15]; }; struct student inputStudentDetails(); void printStudentDetails(struct student); void updateTotal(struct student *); struct student getTopper(struct student [], int); //struct stud...
C
/* Uiversal_queue.c -- ʵļ */ #include "Uiversal_queue.h" /* Proclaim local functions */ static Node * makeNode (const Item * const pi) ; /* Define interface functions */ Bool Initialize_Q (Queue * const pq) { *pq = (struct queue *) malloc (sizeof (struct queue)) ; if (NULL == *pq) return FALSE ; (*pq) -> fron...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* lem_free.c :+: :+: :+: ...
C
#include<stdio.h> int main() { //code int testcase; scanf("%d",&testcase); for(int i = 0; i < testcase; i++) { // int c1[10000], c2[10000]; int score1 = 0, score2 = 0; int n1, n2; scanf("%d %d",&n1, &n2); int c1[n1] , c2[n2]; for(int j = 0; j < n1; j++) { scanf("%d",&c1[j]);...
C
///////////////////////////////////////////////////////////////////////////// #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> struct triple_s { char **data; int maxlen; int len; }; void sss_print(struct triple_s *sss) { printf("%d\n", sss->len); for(int i = 0;...
C
/***************************************************************************** AUTH: William Payne * FILE: g_command.c * LAST MOD: 15/10/18 * PURPOSE: Functions for GCommand structs *****************************************************************************/ #include "g_command.h" #include "file_io.h" /*...