language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include<stdio.h> #include<stdlib.h> #include<sys/types.h> #include<sys/socket.h> #include<netinet/in.h> int main(){ //OUTLINE // socket() => connection() => recv() int network_socket ; // creating a socket network_socket = socket(AF_INET , SOCK_STREAM , 0); // specifing the address to conn...
C
#include<stdio.h> #define N 100 int main() { int i,j; int n; int a[N][N]={}; printf("请输入一个n级方阵\n"); scanf("%d",&n); for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(j>=i) { a[i][j]=1; } else { a[i][j]=i-j+1; } printf("%2d ",a[i][j]); } printf("\n"); } return 0; }
C
//% file: hello_pthread.c //% cmd: gcc -O3 -Wall -Wextra -o hello_pthread hello_pthread.c -lpthread #include <stdio.h> #include <pthread.h> #include <unistd.h> /* スレッドによって実行される関数 */ void * f(void * args_) { (void)args_; pthread_t tid = pthread_self(); for (int i = 0; i < 3; i++) { printf("%ld : hello %d\n",...
C
/***************************************************** * HEADER FILE: hn_modes_q.c * * MODULE: Utility functions depending on * * the update mode (to be used with * * hn_test_pattern_q) * * ...
C
#include <stdio.h> int main(void) { int i; for (i=1;i<101;i++) /*1to100*/ { if (i%3==0 && i%5==0){ /*multiple of 3and5*/ printf("FizzBuzz"); } else if (i%3==0){ /*multiple of 3*/ printf("Fizz"); } else if (i%5==0){ /*multiple of 5*/ printf("Buzz"); } ...
C
#include "usb.h" #include <stdlib.h> #include <stdio.h> #include <fcntl.h> #include <unistd.h> #include <linux/uinput.h> #include <linux/hidraw.h> struct USBDevice { FILE* file; char* name; }; USBDevice* openDevice(char* name) { FILE* file = fopen(name, "r"); if(file == NULL) return NULL; USBD...
C
/** * Copyright (c) 2015 Lazu Ioan-Bogdan * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * Permission is granted to anyone to use this software for any purpose, * including commercial...
C
int is_valid(const char c, char **grid, const int y, const int x) { int i; i = 0; while (i < 9) { if (grid[y][i] == c || grid[i][x] == c) return 0; ++i; } return ((c == grid[(y / 3) * 3 + (y + 1) % 3][(x / 3) * 3 + (x + 1) % 3]) || (c == grid[(y / 3) * 3 + (y + 2) % 3][(x / 3) * 3 + (x + 1) ...
C
/* conf.h */ /* * Declaration of block device switch. Each entry (row) is the only link between * the main code and the driver. The initialization of the device switches * is in the file conf1.c. */ extern struct bdevsw { int (*d_open)(); int (*d_close)(); int (*d_strategy)(); } bdevsw[]; /* * Character d...
C
/** Code by Uspensky *****/ /**************************************************************************************/ /* ДЗ №7 Программа "Телефонный справочник" */ /**************************************************************************************/ #include <stdio.h> #includ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* error.c :+: :+: :+: ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* nm.c :+: :+: :+: ...
C
/* ** ls_l.c for in /home/WASSEX/Semestre1/PSU_2016_my_ls ** ** Made by Wassim Alkayar ** Login <WASSEX@epitech.net> ** ** Started on Tue Apr 18 00:27:21 2017 Wassim Alkayar ** Last update Sun Jul 16 01:37:48 2017 Wassim Alkayar */ #include "my.h" void ut_tw(struct stat fileStat, int a, struct s_Dlis...
C
#include<stdio.h> int main() { char s1[10],x; int i; printf("enter char which u want to replace:\n"); scanf("%c",&x); printf("enter the string:\n"); scanf("%s",s1); for(i=0;s1[i]!='\0';i++) { if(s1[i]==x) { s1[i]='g'; } } pr...
C
#include<stdio.h> int dp[10001][10][2] = {0}; int vec[10001]; int ob[10001]; int top = -1; int n, pp = 0, tt; /* go Լ . ٸ DP[x][p][1] ߰ ܰ迡 ° ּ ּ ش. */ // X ڸ߱ . ְ, ׿ . int go(int x, int p){ if(x >= n+1) return 0; if(dp[x][p][0] != -1) return dp[x][p][0]; int c1, c2, temp = (vec[x] + p) % 10; if...
C
#include "push_swap.h" void swap(t_pile *p) { int x; int y; if (p->length > 1) { x = popup(p); y = popup(p); addup(p, x); addup(p, y); } } void sswap(t_pile *p1, t_pile *p2) { swap(p1); swap(p2); } void push(t_pile *p1, t_pile *p2) { int x; if (p2->length) { x = popup(p2); addup(p1, x); } } ...
C
#ifndef LOGGER_H #define LOGGER_H #include <stdio.h> #include <string.h> #define LOG_LEVEL_FATAL (0) #define LOG_LEVEL_ERROR (1) #define LOG_LEVEL_WARN (2) #define LOG_LEVEL_INFO (3) #define LOG_LEVEL_DEBUG (4) extern FILE *_default_log_stream; extern int _default_log_level; int setup_logger(FILE *...
C
// // Created by gcyganek on 12.03.2021. // #include <sys/times.h> #include <unistd.h> #include "library.h" #ifdef DYNAMIC #include <dlfcn.h> #endif double time_in_seconds(clock_t start, clock_t end) { return (double)(end - start) / sysconf(_SC_CLK_TCK); } int main(int argc, char* argv[]) { Table *table = N...
C
#include <stdio.h> #include <stdlib.h> #include "bintree.h" void bin_insertNode(bnode **root, int data) { bnode *temp = (bnode *) malloc(sizeof(bnode)); temp->left = NULL; temp->right = NULL; temp->data = data; if (*root == NULL) { *root = temp; return; } ...
C
//chargement des librairies standard #include <stdio.h> #include <stdlib.h> // chargement de la librairie mathsh pour la puissance de 10 #include <math.h> //chargement de la librairie windows.h pour grer les fichier en partie et la fonction sleep #include <windows.h> # define TAILLE_CHAINE_CHAR 21 # define AL...
C
/* --Done: Player movement and hitting an enemy, my backgrounds, Losing, Lives, Enemy sprites, BG1 + BG2, all states scoring --To Do: bullet cheats (and update all the art). Also colliding with the sides of the BG2 should cause you to lose a life but my BG2 is messed up so i removed it. and regulate enemies coming i...
C
/* |1nȫ, | |16/11/05ztx, thanks to wangqiqi| */ void Pern(int list[], int k, int n) { // kʾǰkƶn-kλ if (k == n - 1) { for (int i = 0; i < n; i++) { printf("%d", list[i]); } printf("\n"); }else { for (int i = k; i < n; i++) { // ƶȫ ...
C
inherit "/std/food.c"; #include <std.h> #include "../vesprus.h" void create(){ ::create(); set_name("%^BOLD%^%^RED%^A juicy cherry%^RESET%^"); set_id(({"cherry","fruit","food"})); set_strength(1); set_weight(0); set_short("%^BOLD%^%^RED%^A large red cherry%^RESET%^"); set_destroy(); set_long("%^BOLD...
C
/* ** EPITECH PROJECT, 2020 ** CPE_corewar_2019 ** File description: ** cw_asm_instruct_compile_global */ #include "asm/instructs/cw_asm_instruct.h" void cw_asm_instruct_compile_global(cw_asm_instruct_t *instruct) { int i = 0; for (; instruct->parameters[i]; i++) { switch (*instruct->parameters[i]) {...
C
/* * Jacopo Del Granchio * #063 11.12.2019 * * Controlla se due rette sono parallele o perpendicolari. */ #include <stdlib.h> #include <stdio.h> #include <math.h> #include <locale.h> #include <stdarg.h> #include <stdbool.h> // Macro #define chiedi(msg, format, ...) \ printf(msg); \ scanf(format, __VA_ARGS__)...
C
//#include<stdio.h> // //int search(int *A, int size, int search_value); // //int main() //{ // int A[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; // // search(A, 10, 8); // // return 0; //} // //int search(int *A, int size, int search_value) //{ // int i; // // for(i=0; i<10; i++){ // if(A[i] == search_value) // printf("...
C
#include <assert.h> #include "ddhcp.h" #include "dhcp.h" #include "logger.h" #include "tools.h" int ddhcp_block_init(ddhcp_config* config) { if (config->number_of_blocks < 1) { FATAL("ddhcp_block_init(...)-> Need at least 1 blocks to be configured\n"); return 1; } DEBUG("ddhcp_block_init(config)\n"); ...
C
#include "stdio.h" int fibonacci(int n) { if (n == 0) { return 0; } else if (n == 1) { return 1; } return (fibonacci(n - 1) + fibonacci(n - 2)); } int main() { int a; a = 10; printf("fibonacci(%d) = %d\n", a, fibonacci(a)); return 0; }
C
#include <stdio.h> #include <stdlib.h> int main(){ int vet1[10]; int i, n; for (i=0 ; i<10 ; i++) { printf("digite o valor do numero na posicao [%d]: ",i+1 ); scanf("%d", &n); vet1[i]= n; } for (i=9 ; i>=0 ; i--) { printf("os numeros invertidos sao:\n %d\n", vet1[i]); } return 0; }
C
/** Ŀ ֪ABֱʾǿռϣԪСһABԪظ2000Ϸʹҵѧ⣨8֣ ˣ ʽ 5 2 3 4 5 6 4 1 2 5 8 ˵ һеһAĸΪAԪأ ڶеһBĸΪBԪء ʽ 7 ˵ ABIJԪظ**/ #include <stdio.h> #include <stdlib.h> int main() { int lenA=10,lenB=10; int A[lenA],B[lenB]; int i,j,k=0,len; scanf("%d",&lenA); for(i=0;i<lenA;i++) { scanf("%d",&A[i]); } scanf(...
C
#include "flux_code.h" #include<string.h> // memcpy #include<stdlib.h> // malloc #include<endian.h> #include "flux_command.h" #include "flux_exception.h" #include "flux_exception_table.h" #include "flux_instruction.h" #include"flux_list.h" #include"flux_log.h" #include "flux_object.h" #if __BYTE_ORDER == __LITTLE_EN...
C
#include "gc.h" #include <stdlib.h> #include <assert.h> #include <stdbool.h> #include <stdio.h> // testing framework static void* __finalisersCalled[2048]; static int __finaliserIndex = 0; static void __finaliser ( void* ptr ) { __finalisersCalled[__finaliserIndex++] = ptr; } #define ASSERT(x, message) if (!(x)) {...
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> #include <stdint.h> #include <stdlib.h> uint8_t fabric[1000][1000] = {0}; uint32_t overlaps = 0; void fill_count(uint16_t cx, uint16_t cy, uint16_t width, uint16_t height) { for (int x = cx, i = 0; i < width; x++, i++) { for (int y = cy, j = 0; j < height; y++, j++) { if (!f...
C
#include "_.h" extern Value AT_VALUES; #define LIB_COUNT 4 static Value at_Math_init (); static Value at_Console_init (); static Value at_IO_init (); static Value at_Date_init (); static struct { Chars name; InitFunc func; } __lib[LIB_COUNT] = { {"Math", at_Math_init}, {"IO", at_IO_init}, {"Console", at_Console_...
C
/*! * This file defines an interface to compare single characters. * * @author Louis Dionne */ #ifndef JOY_CHAR_CMP_H #define JOY_CHAR_CMP_H #include <joy/char/value.h> #include <chaos/preprocessor/control/branch.h> #include <chaos/preprocessor/comparison/equal.h> #include <chaos/preprocessor/comparison/less.h> ...
C
#include "seqlist.h" void InitSeqlist(pseqlist pseq)//ʼ˳ { assert(pseq); pseq->size = 0; } void PrintSeqlist(pseqlist pseq)//ӡ˳ { assert(pseq); size_t i = 0; if ((pseq->size) == 0) { printf("ѾΪ"); return; } else { for (i = 0; i < pseq->size; i++) { printf("%d->", pseq->arr[pseq->size]); } pri...
C
#include "holberton.h" int prime_num(int i, int num); int _abs(int x); /** * is_prime_number - calculates a prime * @n: an integer * Return: 1 if is prime * otherwise 0 */ int is_prime_number(int n) { int i = 2; if (n <= 1) return (0); else if (n == 2) return (1); else return (prime_num(i, n)); } /**...
C
//Rafaella Silva Almeida #include <stdio.h> #include <time.h> #include <stdlib.h> int menor(int *vet, int dim, int menorvalor){ if(dim == 0) return menorvalor; else if(vet[dim-1]<menorvalor) return menor(vet, dim-1, vet[dim-1]); else return menor(vet, dim-1, menorvalor); } int ...
C
#include <stdio.h> #define COUNT 15 int main(void) { int num[COUNT], tmp; int i, j; FILE *fp; //ファイルを開く(読み込みモード)処理 if ((fp=fopen("01number.txt", "r"))==NULL) { printf("File is not found.\n"); return 1; } i = 0; while(fscanf(fp, "%d", &tmp) != EOF){ num[i]=tmp; //配列(num[i])に格納 i++; } for(j=0;j<i;j...
C
#include<stdio.h> /**int main() { int a,b; a=3+2,b=a,12; printf("%d %d\n\n",a,b); }**/ int main() { int a,b; a=(3+2,b=a,12); printf("%d %d",a,b); } /// when bracket is taken right most number will consider as final value /** a=(5,b=garb,12); a=12; **/
C
//Author: Shawn Esseltine 400145888 //Problem 1 //Import all required libraries #include <stdio.h> #include <math.h> void circleCircumference(double); // function prototype void circleArea(double); // function prototype void sphereVolume(double); // function prototype int main(void){ // Initialize array of 3 po...
C
/* Our Header File that contains the our library of function prototypes */ /********************************/ /* Encryption/Decipher - RSA */ /********************************/ /*Check whether a given number is prime or not*/ int checkPrime(int n); /*to find gcd*/ int gcd(int a, int h); void Encrypt(); void De...
C
#include "mesg.h" ssize_t mesg_send(int fd, MESG *mesg){ return write(fd, mesg, MESGHDRSIZE + mesg->mesg_len); } ssize_t mesg_recv(int fd, MESG *mesg){ size_t len; ssize_t n; // read head count, get true len. if((n = read(fd, mesg, MESGHDRSIZE)) == 0){ return 0; }else if(n != MESGHDRSIZE){ print...
C
/********************************************************* * SCANF & PRINTF * * Author: Reez Patel * * Source: Ex: 3.15 (P-81) = ANSI-C * **********************************************************/ #include <stdio.h> int main() { int a,b,c,max,min; printf("Enter 3 Numbers: "); scanf("%d %d %d",&a,&b,&c);...
C
/* --------------------------------------------------------------------------- * IDs * --------------------------------------------------------------------------- */ #define ui_push_unique_index_id(s,idx) ui_push_id(s, murmur_hash(FILE_LINE, strlen(FILE_LINE),(uintptr_t)idx)) #define ...
C
#include "at24eeprom.h" #ifdef USE_HAL_DRIVER uint8_t at24read(I2C_HandleTypeDef * eeprom, uint8_t * buf, uint16_t len, uint16_t offset) { return HAL_I2C_Mem_Read(eeprom, 0xa0 | ((offset >> 8) << 1), offset&0xff, I2C_MEMADD_SIZE_8BIT, buf, len , 1000); } uint8_t at24write(I2C_HandleTypeDef * eeprom, uint8_t * buf,...
C
/** @file Implementacja interfejsu kalkulatora wielomianów rzadkich wielu zmiennych @author Bartłomiej Sadlej @copyright Uniwersytet Warszawski @date 2021 */ #pragma once #include "calc_helper_functions.h" #include "macros.h" #include "stack.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #inclu...
C
//describe taylor series for exp, cos and sin using recursion #include<stdio.h> #include<math.h> int fact(int n){ if (n>0){ return fact(n-1)*n; } return 0; } double eRec(int x, int n){ static double power=1, factorial=1; double result; if (n==0){ return 1; }else{ re...
C
/* ************************************************************************** */ /* LE - / */ /* / */ /* mainval.c .:: .:/ . .:: ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <cs50.h> #include <math.h> #include <ctype.h> int main(int argc, string argv[]) { int argvToInt = atoi(argv[1]); if (argc > 2) { printf("Usage: ./caesar key\n"); } if (strlen(argv[1]) == 0) { printf("Usage: ./c...
C
#include <setjmp.h> /* jmp_buf */ /***************************************************************************** To use setjmp() and longjmp() for asynchronous (interrupt-driven; pre-emptive) task-switching, we want to enable interrupts simultaneous with jumping to the task. In other words, we want the EFLAGS and EIP r...
C
#include "../shell.h" #include "commands.h" int jobs(char* words[] , int word_count){ if(word_count > 2){ printf("jobs : argument error"); return 1; } int s_flag = 0; int r_flag = 0; int indices[100]; for (int j=0;j<100;j++) { indices[j] = j; } if(word...
C
#include "cdfs.h" /* * Serial port handling code */ void serial_init(int baudrate) { volatile unsigned char *s = (unsigned char *)(void *)0xffe80000; *((volatile unsigned short *)(s+8)) = 0; *((volatile unsigned short *)(s)) = 0; s[4] = 50000000/(32*baudrate)-1; *((volatile unsigned short *)(s+24)) = 12;...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <arpa/inet.h> #include <sys/socket.h> #include <netinet/in.h> #include <pthread.h> #include "/usr/include/mysql/mysql.h" #define PORT 9190 #define DBID "pi" #define DBPW "1" #define DBADR "localhost" #define DBNAME ...
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 arrA[] = { 4, 2, 5, 6}; int arrB[10]; // n : 복사할 인덱스 번호, k: 원소개수 void arrCopy(int n, int k); int main(int argc, char *argv[]) { int size = sizeof(arrA)/sizeof(arrA[0]);...
C
// The following Code is a demonstration purpose of Priority Inversion During V&V CEP 9/07/12 // // // Most of the code is written intentional to only demonstrate the purpose , don't try to use as it is // // // Author V&V Team #include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <as...
C
#include <stdio.h> struct youli { double rose; double baby; }; int main() { struct youli a1, a2, res; scanf("%lf %lf %lf %lf", &a1.rose, &a1.baby, &a2.rose, &a2.baby); res.rose = a1.rose + a2.rose; res.baby = a1.baby + a2.baby; if (res.rose < 0.05) res.rose = 0; else if (res.baby < 0.05) res.baby = 0; prin...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* displacement.c :+: :+: :+: ...
C
int a[8] = {8, 9, 11, 89, 1278, 76, 88, 52}; static void print_array(int a[], int lengh) { int index; printf("###################\n"); for(index = 0; index < lengh; index++) { printf("%d\n", a[index]); } printf("###################\n"); }
C
#include "../inc/libmx.h" static int indexChar(char *a, char b) { char *r = mx_strchr(a, b); return r - a; } int mx_read_line(char **lineptr, size_t buf_size, char delim, const int fd) { char *buff = (char *)malloc(buf_size + 1); int bytes; while ((bytes = read(fd, buff, buf_size)) > 0) { ...
C
#include <stdio.h> #include <string.h> int main(){ char str[1000001]; char* tok; int cnt=0; scanf("%[^\n]s", str); tok = strtok(str," "); while(tok != NULL){ cnt++; tok = strtok(NULL, " "); } printf("%d", cnt); return 0; }
C
/* GROUP 48: PUNEET ANAND 2016B4A70487P MAYANK JASORIA 2016B1A70703P SHUBHAM TIWARI 2016B4A70935P VIBHAV OSWAL 2016B4A70594P */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "data_structures/st.h" #include "data_structures/ast.h" #include "codeGen.h" #include "codeGenD...
C
#include <stdio.h> #include <stdlib.h> #define N 5 int main(){ double a[N] = { 1.0, 2.0, 3.0, 4.0, 5.0 }; double b[N] = {0.0}; size_t ret = 0; FILE* fp = fopen("temp.bin", "wb"); fwrite(a, sizeof(*a), N, fp); fclose(fp); fp = fopen("temp.bin", "rb"); ret = fread(b, sizeof(*b), N, fp); if(ret == N){ ...
C
#include "queue.h" #include <pthread.h> bool queueIsEmpty(Queue this) { return this.head->next == NULL; } Node *nodeCreate(void *data) { Node *this = malloc(sizeof(Node)); this->data = data; this->next = this; return this; } void queueEnqueue(Queue *this, void *data) { Node *node = nodeCreat...
C
#import <cs50.h> #import <stdio.h> #import <math.h> int main (void) { float amount; do { printf("How much change is owed? "); amount= get_float(); } while (amount < 0); // convert to cents int cents = round(amount * 100); int coins = 0; if (cents...
C
#include <stdio.h> int main() { int a = 625; char b = 65; a = a / 25; b = b + 2; printf("a=%d\nb=%c", a, b); return 0; }
C
#include <stdlib.h> #include <iostream> #include <string> #include "hash.h" using namespace std; hash::hash() { int i; for(i = 0 ; i< tableSize; i++) { HashTable[i] = new item; HashTable[i]->name = "empty"; HashTable[i]->drink = 0; HashTable[i]->next = NULL; } } void hash::AddItem(string na...
C
/* ** EPITECH PROJECT, 2021 ** B-PSU-101-BAR-1-1-minishell1 ** File description: ** show_prompt */ #include "mini.h" int last_slash(char *cwd) { int i = 0; int slash_pos = 0; while (cwd[i] != '\0') { if (cwd[i] == '/') slash_pos = i; i++; } return (slash_pos); } char ...
C
/* -*- Mode:C; Coding:us-ascii-unix; fill-column:132 -*- */ /* ****************************************************************************************************************************** */ /** @file slvSysC.c @author Mitch Richling <https://www.mitchr.me/> @Copyright Copyright 1998 by Mitch Richlin...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.c :+: :+: :+: ...
C
#include <stdio.h> /* * Our binary search makes two tests inside the loop, * when one would suffice (at the price of more tests outside.) * Write a version with only one test inside the loop * and measure the difference in runtime. */ int bin_search(int x, int arr[], int n); int main(void) { int arr[] = { 0...
C
#include <WiFi.h>; #include <AWS_IOT.h>; AWS_IOT aws_iot; int status = WL_IDLE_STATUS; void connectToWifi(char* ssid, char* password) { Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } if(aws_iot.con...
C
// Fixed on 03-19-2019 by Rodney DuPlessis (type mismatches) #include <stdio.h> #include <stdlib.h> /* ----------------- Type definitions ----------------------------------- */ typedef struct /* period ( congruence class ) */ { int mod; /* modulus of the period ...
C
/* * File: CONTROLDEMOTOR.c * Author: kenst * * Created on 11 de mayo de 2021, 10:34 */ #include <xc.h> #include <stdio.h> #include "LCD2.h" #define _XTAL_FREQ 4000000 float ciclo; float ccp = 0; float ccp1 = 0; float dato[]; int res; void configuracion_registros(void); void Ciclo_util (void); void PWM (void);...
C
#include<stdio.h> void main() { int N,k,i,j=1; int ar[10]; printf("Enter the values:"); scanf("%d %d",&N,&k); for(i=N;i>=1;i--) { if(N%i==0) { ar[j]=i; j++; } } if(k<j) { printf("%d",ar[k]); } else printf("1"); }
C
#pragma once #include "constants.h" #define ui unsigned int #define uli unsigned long int #define cp char * #define MAX_FRIENDS 50 #define MAX_USERS 100 typedef struct tophChatUser TUSER; typedef struct database TINFO; /*For our data structure, we will use a * graph and represent the users as nodes*/ struct tophC...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> #include <sys/stat.h> #include "../include/str_list.h" #define MAX_WORD_LENGTH 50 int load_lines_from_file(char* fileName, str_list *out_line_list) { char str[MAX_WORD_LENGTH]; FILE *fp; if ((fp = fopen(fileName, "r")) == NU...
C
/* ** Chapter 1, Exercise 2 ** Write a program that reads lines from the standard input. ** Each line is printed on the standard output preceded by its line number. ** Try to write the program so that it has no built‐in limit on how long a line ** it can handle. */ #include <stdio.h> int main(void) { char ch; ...
C
#include "lvp_nqueue.h" LVPNQueue *lvp_nqueue_alloc(int cap){ LVPNQueue *q = (LVPNQueue*)lvp_mem_mallocz(sizeof(*q)); q->cap = cap; q->datas = lvp_mem_mallocz(sizeof(LVPQueueEntry)*cap); for (size_t i = 0; i < cap; i++) { q->datas[i] = lvp_mem_mallocz(sizeof(LVPQueueEntry)); } return q; } void lv...
C
#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <sys/wait.h> #include <sys/types.h> #include <signal.h> #include <errno.h> void TestFun() { printf("child\n"); } int main() { int procnum =10; int loopnum = 100; int i =0; int ret; pid_t pid; for(i=0; i< procnum; i++) { pid = fork(); if...
C
int main() { int a,b,c,err; printStr("Enter the first number: "); a = readInt(&err); printStr("Enter the second number: "); b = readInt(&err); printStr("Enter the third number: "); c = readInt(&err); int *x,*y,*z; char p,q,r; char *m,*n,*o; p = 'a'; q = 'b'; r = 'd'; m = &p; n = &q; o = &r; x = &a; ...
C
/* // Title: example.c // Author: Sahaj Sarup // Copyright (c) 2019 Linaro Limited */ #include <stdio.h> #include <stdlib.h> /* mraa header */ #include "mraa/i2c.h" #include "fpga_mezz.h" int main() { mraa_result_t status = MRAA_SUCCESS; mraa_i2c_context i2c; mraa_init(); i2c = mraa_i2c_init(I2C_BU...
C
#include <stdio.h> #include <string.h> #include <fpga.h> #include <drvLib.h> #include "csl/csl.h" #include "csl/fpga.h" /* // Fpga_Open - Open FPGA Object. // // RETURNS: 0 success, -1 if failed. */ int Fpga_Open( void ) { return Drv_Open(CSL_MODULE_FPGA); } /* // Fpga_Close - Close FPGA Object. // // RETURNS: 0 suc...
C
// // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. // /*============================================================= ** ** Source: getmodulefilenamew.c ** ** Purpose: Positive test the GetModuleFileName API. ** ...
C
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <math.h> #include "jiggle.h" jgSpace *jgSpaceAlloc() { jgSpace *space = malloc(sizeof(jgSpace)); space->particles = jgListNew(); space->areas = jgListNew(); space->springs = jgListNew(); space->pendingCollisions = jgListNew()...
C
#include<stdio.h> int flower(int); int flower(int n){ if((n/100)*(n/100)*(n/100)+(n/10%10)*(n/10%10)*(n/10%10)+(n%10)*(n%10)*(n%10)==n) return 1; else return 0; } int main(){ int x; scanf("%d",&x); printf("%d",flower(x)); }
C
#include <stdio.h> #include <cs50.h> #include <string.h> int main(void) { char *s1 = get_string("s1: "); char *s2 = get_string("s2: "); printf("%lu\n", sizeof(s1)); char *s3 = concatenate(s1, s2); printf("%s\n", s3); free(s3); } // TODO: Implement concatenate function
C
#ifndef VECTOR_H #define VECTOR_H #include <stdlib.h> #include <stdio.h> #include <string.h> #include <assert.h> #define VECTOR_MAX_SIZE (8) struct Vector { int _element_size; // the size of each element int _size; // current used size of vector int _max_size; // max size of vector, default is VECTOR_MAX_SIZ...
C
/* ** EPITECH PROJECT, 2019 ** my_sokoban ** File description: ** fragment the map */ #include "my.h" void fragment_map(char *buffer, char *new_map) { int lines = count_lines(buffer); char **map = malloc(sizeof(char *) * lines); int temp = 0; int k = 0; for (int j = 0; buffer[temp] != '\0'; temp+...
C
#include <stdio.h> #include <stdlib.h> #include "fifo.h" FIFO * fifo_new_list() { FIFO * li = (FIFO*)malloc(sizeof(FIFO)); if(li!=NULL) { li->pHeadPos = NullPos; li->pTailPos = NullPos; li->pCurrentPos = NullPos; } return li; } void fifo_delete_list(FIFO * li) { if(li==NULL) return; ElementNode node = ...
C
#include "clar_libgit2.h" #include "reflog.h" static git_repository *g_repo; static git_reflog *g_reflog; static size_t entrycount; void test_refs_reflog_drop__initialize(void) { g_repo = cl_git_sandbox_init("testrepo.git"); git_reflog_read(&g_reflog, g_repo, "HEAD"); entrycount = git_reflog_entrycount(g_reflog)...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> double preco(int years, int dif, double valor) { if(years == 3 && valor <= 45) { return valor; } else if(years == 0 && valor <= 45) { return 45; } else if(years == 0) { return v...
C
#include <avr/io.h> #include <util/delay.h> #define TRUE 1 #define FALSE 0 #define NULL '\0' #define sbi(BYTE,BIT) BYTE|=_BV(BIT) // BYTEの指定BITに1をセット #define cbi(BYTE,BIT) BYTE&=~_BV(BIT) // BYTEの指定BITをクリア #define LED0_ON() sbi(PORTB, PB0) #define LED0_OFF() cbi(PORTB, PB0) #define LED1_ON() sbi(PORTD, PD7) #define L...
C
/** ****************************************************************************** * @file : main.c * @author : Vidya Viswanathan * @brief : Fault generation and handling ****************************************************************************** */ #if !defined(__SOFT_FP__) && def...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* inside.c :+: :+: :+: ...
C
#include<stdio.h> #include<unistd.h> #include<stdlib.h> #include<signal.h> int cnt = 0; void func (int sig) { printf ("输入速度是每小时%d字\n", 36 * cnt); exit (0); } int main () { signal (SIGALRM, func); printf ("请输入每个字一行:\n"); alarm (100); //定时100秒,到时会收到SIGALRM信号 for (;;) { char buf[100]; scanf...
C
#ifndef __MISC_H #define __MISC_H #include <stdio.h> /** * Tipo: Entrada da tabela de simbolos */ typedef struct s_SymbolTableEntry{ char* key; int value; struct s_SymbolTableEntry* next; } SymbolTableEntry; SymbolTableEntry* SymbolTableEntry_construct(const char* key, const int value); void SymbolTableEntry_...
C
/*Write a C program to find Simple Interest.*/ #include<stdio.h> int main(){ int p,t,r; printf("enter principal amount\n"); scanf("%d",&p); printf("enter time period\n"); scanf("%d",&t); printf("enter interest rate\n"); scanf("%d",&r); printf("simple interest is %f",p*t*r/100.0); return 0; }
C
void n_n(int n) { int k = 0; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) k++; } void n_logn(int n) { int k = 0; for(int i=1;i<=n;i++) for(int j=1;j<=n;j*=2) k++; } void n_2_n(int n) { int k = 0; for(int i=1;i<=n;i++) for(int j=1;j<=1<<n;j++) ...