language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
/** * This is a brief test of how doxygen documents #defines * * \author Will Holcomb <wholcomb@gmail.com> * \date 5 August 2006 */ #include <stdio.h> /** * \def BIT_1 * \brief The first bit */ #define BIT_1 (1<<0) #define BIT_2 (1<<1) #define BIT_3 (1<<2) #define BIT_4 (1<<3) #define BIT_5 (1<<4) #define BI...
C
#include <stdio.h> #include <stdlib.h> #include "liste.h" int main(int argc, char** argv) { Polynome poly1=NULL, poly2 = NULL; poly1 = ajouterOuRemplacerIndiceValeur(0,0.8,NULL); poly1 = ajouterOuRemplacerIndiceValeur(3, 6.8, poly1); poly1 = ajouterOuRemplacerIndiceValeur(2, 0.1, poly1); poly1 =...
C
#include "stdio.h" int main() { int i,sum,arr[10]; float av; printf("enter the array charcters\n"); for(i=0;i<10;i++) { scanf("%d",&arr[i]); } for(i=0;i<10;i++){ sum=sum+arr[i]; } printf("the sum of the array is %d \n",sum); av=sum/10; printf("the average of...
C
int peakIndexInMountainArray(int *A, int ASize) { int *p = A; while (*p < *(p+1)) { p++; } return p-A; } int main() { int a[] = { 0, 2, 1, 0 }; int r = peakIndexInMountainArray(a, 4); return 0; }
C
#include<stdio.h> #include<stdlib.h> struct Node { int data; struct Node *Next; }*first; void Create(int *A,int n) { int i; struct Node *last,*t; first=(struct Node *)malloc(sizeof(struct Node *)); first->data=A[0]; first->Next=first; last=first; for(i=1;i<n;i++) { t=...
C
// Copyright (c) 2015-2017 Nuxi, https://nuxi.nl/ // // SPDX-License-Identifier: BSD-2-Clause #include <testing.h> #include <threads.h> extern thread_local int tlsvar_i; thread_local int tlsvar_i = 0x4d653c57; extern thread_local int tlsvar_j; thread_local int tlsvar_j = 0; static int validate(void *arg) { // Vali...
C
#include <stdio.h> #include <stdlib.h> #include "bucketsort.h" int bucketsort(int vet[], int tam, int mask){ int i,j, tmp; Fila *bucket[10]; for(i=0;i<10;i++){ bucket[i] = criarFila(); } for(i=0;i<tam;i++){ inserir(bucket[(vet[i]/mask)%10],vet[i]); } for(i=0,j=0;i<tam;){ ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define LEN 128 typedef struct sChecker { struct sChecker * letters[LEN]; char end; } checker; checker * newChecker() { checker * spellChecker = (checker*) malloc(sizeof(checker)); for (int i = 0; i < LEN; i++) { spellChecker->letters...
C
/*! * \file genericLL.h * \brief Generic SIngle LinkList * * Generic LinkList to create dynamic linklist and perform various generic operations. * * Revision History: * Date User Comments * 4-Apr-19 Mukund A Create Original */ #ifndef __G_LINKLIST__ #define __G_LINKLIST__ typede...
C
#include<stdio.h> int main() { int n; printf("Enter Your Number :$"); scanf("%d", &n); if(n >= 0 && n <= 9) { printf("Number of digit : 1"); } else if(n >= 10 && n <= 99) { printf("Number of digit : 2"); } else if(n >= 100 && n <= 999){ prin...
C
#include <stdio.h> #include <conio.h> void title(void); //function prototype for title void inst(void); //function prototype for instructions void hangman(int,int); //function prototype for hangman void credits(void); //function prototype for credits void title(void) //defining title { prin...
C
// khai báo hằng số #define MAX 100 #define TAB '\t' typedef int DaySo[MAX]; // khai báo nguyên mẫu hàm int soduong_min(DaySo a, int n); int soammax(DaySo a, int n); int xuat_VTcuoi_NT(DaySo a, int n); bool ktsonguyento(int n); void xuatmang(DaySo a, int n); int PT_Xuathien_nhieu(DaySo a, int n); int tim_PT_min(...
C
#include "holberton.h" /** * print_chessboard - Print the chessboard * @a: Store the array */ void print_chessboard(char (*a)[8]) { int b = 0, c; while (b < 8) { for (c = 0; c < 8; c++) { _putchar (a[b][c]); } _putchar (10); b++; } }
C
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <sys/socket.h> #include <arpa/inet.h> #include <string.h> #define SERV_IP "127.0.0.1" #define SERV_PORT 6666 int main() { int cfd; struct sockaddr_in serv_addr; socklen_t sock_addr_len; char buf[BUFSIZ]; cfd=socket(AF_INET, SOCK_STREAM, 0); m...
C
#include"Header.h" int evalRPN(vector<string>& tokens) { stack<int>stk; int n = tokens.size(); if (n == 0)return 0; for (int i = 0; i < n; ++i) { if (tokens[i] == "+") { int a = stk.top(); stk.pop(); int b = stk.top(); stk.pop(); stk.push(a + b); } else if (tokens[i] == "-") { int a = s...
C
/* ** EPITECH PROJECT, 2020 ** Visual Studio Live Share (Workspace) ** File description: ** my_itoa */ #include "../include/my.h" char *my_intostr(int nb) { char *str = NULL; int len = 0; for (int tmp = nb; tmp > 0; tmp = tmp / 10, len++); str = malloc(sizeof(*str) * (len + 1)); str[len] = '\0'; ...
C
/* This function marks the start of the farm */ int start_farm() { return 1; } unsigned getval_382() { return 2428995912U; } void setval_251(unsigned *p) { *p = 3347646611U; } unsigned getval_138() { return 3470574424U; } void setval_185(unsigned *p) { *p = 2425393496U; } void setval_358(unsign...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> int main() { char a[10]; int b[10]; printf("the size of char array is %lu\n",sizeof(a) ); printf("the size of int array is %lu\n", sizeof(b)); memset(a, 0, 10); for (int i = 0;i<10;i++) printf("a[%d] is %d\n", i, a[i]); return 0; }
C
#include<stdio.h> struct process { int all[6],max[6],need[6],finished,request[6]; }p[10]; int avail[6],sseq[10],ss=0,check1=0,check2=0,n,pid,work[6]; int nor,nori; main() { int safeseq(void); int ch,i=0,j=0,k,pid,ch1; int violationcheck=0,waitcheck=0;do { printf("\n\n 1.Input"); printf("\n\n 2. New Request ...
C
// gcc -o vecAdd_seq.out vecAdd_seq.c -lrt -lm #include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> int main( int argc, char* argv[]) { if(argc!=2) { printf("./vecAdd_seq num_elem\n"); return 0; } int n; n=atoi(argv[1]); // vector declaration float *a; float *b; float *c; // Size, i...
C
#include <stdio.h> int main(void) { int day, month, year, still; printf("\n Que dia e hoje?\n"); scanf("%d", &day); printf("\n\n Em que mes estamos?\n"); scanf("%d", &month); printf("\n\n Em que ano estamos?\n"); scanf("%d", &year); switch (month){ case 1: printf("\n Estamo...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> void copy_str(char **dst, char *src) { size_t size= strlen(src)+1; *dst= malloc(size); while (*src!='\0') { **dst= *src; src++; dst[0]++; } *dst-=size-1; } int main() { char *src= "Hello"; char **dst= malloc(sizeof(src)); copy_str(dst,src...
C
#include <stdio.h> #include <fcntl.h> #include <unistd.h> #define BUFSIZE 512 // 읽혀질 block의 크기 #define PERM 0644 // 새 파일의 화일 허가 // name1 file 내용을 name2 파일에 복사한다. int copyfile(const char *name1, const char *name2) { int infile, outfile; ssize_t nread; char buffer[BUFSIZE]; if ((infile = open(name1,O_RDONLY)) =...
C
#include "parser.h" #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <sys/wait.h> #include <stdio.h> #define TAM_STR 50 #define TAM_STR_MAIN 100 #define PATCH_TMP "/tmp/filesSO_work" void escreveFicheiroAux(int fp, int fp_aux, LCMD comando){ int n; char ...
C
//Server Side #include<stdio.h> #include<stdlib.h> #include<string.h> #include<sys/types.h> #include<sys/socket.h> #include<arpa/inet.h> #include <sys/socket.h> #include<netinet/in.h> void main() {//Decleration int listenfd,connfd,n,size=0; struct sockaddr_in servaddr,clientaddr; char sendBuff[300...
C
/* * ===================================================================================== * * Filename: superlib.c * * Description: Super function definitions * * Version: 1.0 * Created: 03/13/2018 09:37:23 AM * Revision: none * Compiler: gcc * * Author: Ga...
C
#include <stdio.h> //README //AUTHOR: ERIK BLONDELL //generated 2019-09-15 //based on selectionSort however it will only find negatives and swap them //place the nagatives at the start of the array and the positives at the endsre //because the algorithm is based on selection sort we know that the memory comple...
C
#include <avr/io.h> #include <avr/sleep.h> #include <avr/interrupt.h> #include <util/delay.h> #include <stdint.h> /** * Fuses are defined in makefile. * * Led segments: * * (DIAG1) (DIAG2) * (HORIZ) (DOT) (HORIZ) * (DIAG2) (DIAG1) * * * Wiring: * * ...
C
//Problem Link: https://www.codechef.com/problems/BOLT /* Constraints: 0<k1,k2<2 0<k3<=1 9<v<11 */ #include <stdio.h> #include<math.h> //Solution Link: https://www.codechef.com/viewsolution/45330827 int sol1(int a,int b,int c,int v) { float a,b,c,v,x; x=100/(a*b*c*v); if ((round(x*100)/100) < 9...
C
#include <stdio.h> #include <stdlib.h> #define tam 10 typedef struct{ int tamanho; int vetor[tam]; int topo; int inicio; } FilaV; void inicializar(FilaV *p){ p->tamanho = 0; p->topo = 0; p->inicio = 0; } int cheio(FilaV *p) { if(p->topo > tam - 1) return 1; return 0; } int vazio (FilaV *p) { ...
C
#include <time.h> #include <stdio.h> int main(){ int status =0; time_t whatTime = time (NULL); printf("Current time: %s\n",ctime(&whatTime)); printf("Secondi da 1/1/1970: %lu",whatTime); return status; }
C
// thermo3_skel.c // R. Traylor // 11.15.2011 (revised 11.18.2013) //Demonstrates basic functionality of the LM73 temperature sensor //Uses the mega128 board and interrupt driven TWI. //Display is the raw binary output from the LM73. //PD0 is SCL, PD1 is SDA. #include <avr/io.h> #include <avr/interrupt.h> #include <...
C
#include <stdio.h> #include <string.h> struct _Person { char *name; size_t age; }; typedef struct _Person Person; Person *CreatePerson(char *name, size_t age) { Person *p = malloc(sizeof(Person)); if (p) { p->name = malloc((name ? strlen(name) : 0) + 1); if (p->name) { strcpy(p->name, name ? name : ""...
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
//basic #include <stdlib.h> #include <stdio.h> //string #include <string.h> #include <sys/types.h> //sleep #include <unistd.h> //threads #include <pthread.h> //USS #include "../library/uss.h" /* * this is a testapplication filling using the * library calls offered by uss_library */ /* ...
C
#include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/fs.h> #include <linux/interrupt.h> static struct tasklet_struct my_tasklet; // tasklet处理函数 static void tasklet_handler (unsigned long data) { printk(KERN_ALERT...
C
/* Write a program that calculates the remaining balance on a loan after the first, second, and third monthly payments. Display each payment with two digits after the decimal point. Hint: Each month, the balance is decreased by the amount of payment, but increased by the balance times the monthly interest rate. T...
C
//TidyNumbers by asprazz for small inputs //t<=100 n<=1000 #include<stdio.h> #include<string.h> #include<math.h> #include<stdlib.h> //int calcno(char s[4]); void lowestpossible(char s[4],int i); void checkstring(char s[4]); int main() { //Variables declarations int t,c=1; char s[4]; int no; int l,i; int fla...
C
// // range_validation.c // adsbDecoder // // Created by YangHongbing on 18/3/12. // Copyright © 2018年 qiandian. All rights reserved. // #include "range_validation.h" #include <math.h> double X0, Y0, Z0; /*self relative to earth's core*/ double X1, Y1, Z1; /*enemy relative to earth's core*/ d...
C
#include <stdio.h> #include <sys/wait.h> #include <sys/types.h> #include <unistd.h> #include <stdlib.h> #include <fcntl.h> #include <string.h> #define BUFFER_SIZE 64 #define READ 0 #define WRITE 1 // enum para definir tipo de mensagem trocada entre os pipes typedef enum { string_t = 0, integer_t = 1 } MsgType...
C
/* ************************************************************************ * Filename: 07_sprintf的使用.c * Description: * Version: 1.0 * Created: 2017年09月07日 12时00分35秒 * Revision: none * Compiler: gcc * Author: YOUR NAME (), * Company: * *************...
C
# include<stdio.h> void main() { int a; printf("enter num"); scanf("%d",&a); if((a>=1)&&(a<=10)) { printf("range"); } else { printf("not in range"); } }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "htable.h" #include "string_utils.h" #define CONF_BUFFER_SIZE 512 void _destroy_string(void* v); htable* load_configuration(char* conf_file) { FILE* f = fopen(conf_file, "r"); char buffer[CONF_BUFFER_SIZE]; htable* conf = new_htable(_destroy_stri...
C
/* * PI calculation using the Leibniz formula: * (1/1) - (1/3) + (1/5) - (1/7) +...+ (1/n) = pi/4 , where n is the last odd number * * The process must fork a child. The child then, have to calculate PI * and send it to its father in order to print it. */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #in...
C
#ifndef _QUEUE_H_ #define _QUEUE_H_ #include "deque.h" #define QUEUE_INIT(q, elem_size) queue_init((q), (elem_size), NULL, NULL) typedef struct { deque_t d; } queue_t; /* initialize the queue */ static inline void queue_init(queue_t *q, size_t elem_size, void (*copy_func)(void *, void *), void (*free_func)(void *...
C
#include <stdio.h> // Neue Bibliothek - benötigt für atof #include <stdlib.h> int main(int argc, char ** argv) { float z1; // Einlesen der Seitenlängen z1 = atof(argv[1]); if(z1 < 0) { printf("%f is a negative number!",z1); } else if (z1 == 0) { printf("%f = 0",z1); } else { printf("%f is a positive n...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_printf_d_i_u_l.c :+: :+: :+: ...
C
#include "../deps/bdd-for-c.h" #include "../src/cpu.c" #include "../src/instruction.h" #include "stdbool.h" #include <stdio.h> #define NZ_FLAGS_CHECK(val) { \ if (val > 0) { \ cpu->flags.zero = true; \ cpu->flags.ne...
C
//https://www.interviewbit.com/problems/list-cycle/ /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ ListNode* Solution::detectCycle(ListNode* A) { ListNode *slow = A, *fast = A, *start = A, *start2, *new1 ...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #include "fonctionsC.h" void main(argc,argv) int argc; char *argv[]; { /*-------------- Variables --------------------------*/ int nb_fonc; // Number of ODEs float *y, *yout, *dydx; // State vector and derivatives float...
C
#include "newton.h" #include "data.h" #include <stdlib.h> static void forward_init(size_t n, Data *data, double **y) { size_t i, j; for (i = 0; i < n; i++) { y[i] = malloc((n - i) * sizeof(double)); } // Copy the data to the first column for (i = 0; i < n; i++) { y[i][0] = data[i].y; } // Calcula...
C
#ifndef _PCS_SHELL_HASHTABLE_H_ #define _PCS_SHELL_HASHTABLE_H_ #ifndef HASH_EXTEND_MULTIPLIER #define HASH_EXTEND_MULTIPLIER ( 1.75F ) #endif #ifdef __cplusplus extern "C" { #endif typedef struct HashtableNode HashtableNode; struct HashtableNode { char *key; unsigned int hashA; unsigned int hashB; void ...
C
#include <stdlib.h> #include <stdio.h> typedef enum {false,true} bool; typedef enum {subir,bajar} direccion; static bool M[21][21] = { {1,1,1,1,1,1,1,0,0,0,1,0,1,0,1,1,1,1,1,1,1}, {1,0,0,0,0,0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,1}, {1,0,1,1,1,0,1,0,1,0,1,1,0,0,1,0,1,1,1,0,1}, {1,0,1,1,1,0,1,0,0,0,0,0,1,0,1,...
C
#include <stdlib.h> #include <string.h> #include <math.h> #include <movchain.h> #include <hpchain.h> #include <fitness/fitness.h> #include <random.h> #include "abc_alg.h" #include "hive.h" /******************************************/ /****** OTHER PROCEDURES ********/ /************************************...
C
#ifndef bst_h #define bst_h #include <stdio.h> #include <stdlib.h> /* * BST : binary search tree * * Max nodes per level ==> 2^(level-1) * * Max number of nodes in a binary tree with height h (2^h - 1 ) * */ typedef struct node { int data_; struct node *left_; struct node *right_; }node; node *newnod...
C
#include <stdio.h> #include <float.h> #include <math.h> #include "../libs/inputlib.h" #include "../libs/gavlib.h" int find_squares(long long number, long long* sq1, long long* sq2, long long* sq3, long long* sq4); int is_square(long long number); int main() { GREET("C3 problem", "1"); long long number = 0; ...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <pthread.h> #include <time.h> long sizes[4] = {8,8*1024,8*1024*1024,80*1024*1024}; const char *sizenames[]={"8 Bytes","8 Kilobytes", "8 Megabytes", "80 Megabytes"}; long numOps[4]={174483045,170392,165,16}; char *source; //Method ...
C
#include <stdio.h> #define TAM_MAXIMO 80 int main(void) { char cadena[TAM_MAXIMO]; int entero1, entero2; float decimal; printf("Introduce dos enteros separados por un espacio: \n"); scanf("%d %d", &entero1, &entero2); printf("Introduce un número decimal:\n"); scanf("%f", &decimal); printf("Introduce u...
C
#include "all.h" uint8 a; //**************************************************************** //ʼI2CI2C.h //ʿѡںڲ ޸ġ //*************************************************************** void I2C_INIT(uint32 I2C_NUM,char PIN_NUM) { SIM_SCGC4|=(uint32)(1<<(6+I2C_NUM)); switch(PIN_NUM) { case I2C0_PB0_PB...
C
/* * @desc : protocol parser * */ #include <stdio.h> #include <limits.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include "protocol.h" command_cell_struct * create_command_array(unsigned int command_all_cell_length) { command_cell_struct * r; r = create_command_cell(TIP_OBJECT_ARRAY); ...
C
#include "raylib.h" int main(void) { // Initialization //-------------------------------------------------------------------------------------- const int screenWidth = 800; const int screenHeight = 450; InitWindow(screenWidth, screenHeight, "Planetarion"); Vector2 mousePos = { -100.0f, -100.0...
C
#include <string.h> #include <stdlib.h> #include <unistd.h> #include <ctype.h> #include <errno.h> #include <limits.h> #include "klogctl.h" #include "util.h" int main(int argc, char **argv) { int optc; int len = 16*1024; int level = 0; int clear = 0; char *buf; char last = '\n'; while((optc = getopt(argc, argv...
C
#ifndef _BP_LAYER_H #define _BP_LAYER_H #include "bp_node.h" struct BPLayer { struct BPNode* first; int node_count; }; /// empty layer created, returns NULL if failed struct BPLayer* bp_layer_create(); /// init layer with given nodes, returns NULL if failed struct BPLayer* bp_layer_init(struct BPNode* nodes, int ...
C
#include <stdlib.h> #include <stdio.h> #include "../libft/includes/libft.h" int main() { char **product; int i; product = 0; i = 0; while (i < 63 + 1) { if (!(product[i] = (char *)ft_strnew(16427))) return (0); i++; } printf("size of product is %lu\n", sizeof(product)); return (0); }
C
/* * Basic definition and functions in BSP Layer. * * Notice: * 1. The delay series function are CPU blocked, means high currency consumption. * BE CAUTIOUS WITH THEM! * 2. The delay series function are not interrupt-blocked. it's the caller's duty * to decide if the context of usage should enable/disable...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> int main(int argc, char* argv[]) { char cmd[32], tmp[8]; strcpy( cmd, "ls" ); if((argc>1)&&(argv[1]!=NULL)){ strcpy( tmp, argv[1] ); } system( cmd ); return 0; }
C
#include <stdlib.h> #include <stdio.h> #define LSH_RL_BUFSIZE 1024 /* Print error message (msg) following colon (':') whitespace and an perror(3) generated error message. Does not return. Exit with error code of EXIT_FAILURE. */ void ftl(char *msg) { perror(msg); exit(EXIT_FAILURE); } void *ec_malloc(unsigned in...
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<stdlib.h> int main() { int a=5; int b=6; int d=7; int e=8; int c; c=a+b+d+e; printf("%d",c); return 0; }
C
// This is the type of the vector elements #ifndef TYPE #error "Expected macro TYPE to be defined" #endif // This is an abbreviation of the type name. // The vector will be declared as `struct avl_TYPE_ABBREV`. // Defaults to TYPE, and should only be used for pointers. #ifndef TYPE_ABBREV #define TYPE_ABBREV TYPE #e...
C
//205748010310003 //VÕ TÁ NAM #include <stdio.h> #include <stdbool.h> #include <math.h> bool isPrime(int n); int main() { printf("Nhap n\t: "); int n; scanf("%d", &n); printf("%d %s nguyen to\n", n, isPrime(n)?"la":"khong phai la"); return 0; } bool isPrime(int n) { bool kq = true; if(n > ...
C
#include "Collection.h" const void * const Collection=&Object; bool add(void * _self,void * obj){ struct CollectionClass * class = classOf(_self); return class->add(_self,obj); } void clear(void * _self){ struct CollectionClass * class = classOf(_self); class->clear(_self); } bool contains(vo...
C
/* * uart.c * * Created on: 23 jun. 2021 * Author: Braulio */ #include "pin_mux.h" #include "clock_config.h" #include "board.h" #include "fsl_uart.h" #include "uart.h" #include <stdint.h> //variables uint8_t data = 0; uint8_t flag1 = 0; uint8_t hour; uint8_t demoRingBuffer[RING_BUFFER_SIZE]; volatile uint1...
C
/* * myPort.c * * Created on: Apr 22, 2019 * Author: r */ #include "myPort.h" #include "Dio_Regs.h" STATIC Port_Channel_ConfigType * Port_PortChannels = NULL_PTR ; STATIC uint8 Port_Status = PORT_NOT_INITIALIZED; /************************************************************************************ *...
C
#include <stdio.h> #include <string.h> #include <time.h> int main(int argc, char *argv[]) { int start_year, start_mon, start_day; int end_year, end_mon, end_day; int diff_day; double diff_sec; struct tm user_time; time_t start_time; time_t end_time; memset(&user_time, 0, sizeof(user_time)...
C
#include <stdio.h> int main() { int a, b, c; int num = 0; int num1 = 0; for (a = 1; a < 5; a++) { for (b = 1; b < 5; b++) { for (c = 1; c < 5; c++) { num = 100 * a + 10 * b + c; if (a != b && a != c && b != c) { printf("%4d", num); num1++; } } } } ...
C
#include <stdio.h> #include <string.h> #define NUM 10 #define MAX 1000000 void make_working(int wt[][NUM], int h, int w, const char *str1, const char *str2); int search_min(int wt[][NUM], int i, int j); void arr_output(int arr[][NUM], int h, int w); int main(int argc, char **argv) { char *str1, *str2; int wt[NUM...
C
#include<stdio.h> int linearSearch(int arr[], int size, int element) { for(int i = 0; i < size; i++) { if(arr[i] == element) { return i; } } return -1; } int main() { int arr[] = {1, 5, 3, 4, 7, 6, 2, 8, 9, 0}; int size = sizeof(arr)/sizeof(int); int element...
C
/* * Copyright (c) 2016 Jeremy Yallop. * * This file is distributed under the terms of the MIT License. * See the file LICENSE for details. */ #include <caml/mlvalues.h> #include <caml/threads.h> #ifdef _WIN32 value ctypes_setup_thread_registration(value _) { /* Don't override the hook on systems without pthre...
C
#include <linux/types.h> #include <linux/kernel.h> #include <linux/list.h> #include <linux/sched.h> #include <linux/errno.h> #include <asm/uaccess.h> int sys_is_short(pid_t pid) { struct task_struct *t = find_task_by_pid(pid); if (!t) { return -ESRCH; } if (t->policy != SCHED_SHORT) { return -EINVAL; } else ...
C
void bfs(vertex v) { q : queue; q.push(v); visited[v] = 1; while(!q.empty()) { x = q.pop(); visited[x] = 1; forall (x,w) in G { if visited[w] == 0 q.push(w) } } } void dfs(vertex v) { s : stack; s.push(v); while(!s.e...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <assert.h> #include "sds.h" #include "zmalloc.h" sds sdsnewlen(const void *init, size_t initlen) { struct sdshdr *sh; if (init) { sh = zmalloc(sizeof(struct sdshdr) + initlen + 1); } else { sh = zcalloc...
C
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <unistd.h> #define CAPACITE_ENTREPOT 10 #define INTERVALLE_INVENTAIRE 1 int capacite_max_entrepot (){ return CAPACITE_ENTREPOT; }; void *activite_entrepot(void *pdata) { int * stock = (int *)(pdata); while(1) { printf("Entrepo...
C
/* Name: main.c Purpose: Based on user options, display/add students/grades, or filter and store to files */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "file.h" int main() { char user_input; int ret_cod...
C
#include <string.h> #include <stdio.h> /*The strspn() function calculates the length (in bytes) of the initial segment of s which consists entirely of bytes in accept.*/ size_t strspn_our(const char *s, const char *accept){ char alphabet[255]; size_t len; memset(alphabet, 0, sizeof(a...
C
#include <stdio.h> //if you don't use scanf/printf change this include #include <sys/types.h> #include <sys/stat.h> #include <sys/file.h> #include <sys/ipc.h> #include <sys/shm.h> #include <sys/sem.h> #include <sys/msg.h> #include <sys/wait.h> #include <stdlib.h> #include <unistd.h> #include <signal.h> ...
C
#include "stats.h" scalar poisson_log_pmf (scalar lambda, long x) { return (scalar) x * logl (lambda) - lgamma ((scalar) x + 1) - lambda; } scalar poisson_pmf (scalar lambda, long x) { scalar out = expl (poisson_log_pmf (lambda, x)); #ifdef warn_nan if (out != out) { fprintf (stderr, "poisso...
C
int main() { char nome[80]; char curso[80]; // leitura usando o gets printf("Informe o seu nome: "); gets(nome); // leitura usando o scanf printf("Informe o curso: "); scanf("%s", curso); // exibio usando puts puts(nome); puts(curso); system("pause"); }
C
#include <stdio.h> #include <windows.h> #include <stdlib.h> #include <conio.h> #include <time.h> // We define N & M for the field of play, its height and width. /* Find the meaning for 20 and 40 - height & width? or coordinate & position?*/ #define N 20 // number of columns #define M 40 // number of rows int i,j,Fiel...
C
//CN Lab week 1, Q1 //by - Teja Juluru //created on 31/7/19 //TCP client server porgram using modular programming techniques //Server side program #include<stdio.h> #include<stdlib.h> #include<string.h> #include<sys/types.h> #include<sys/socket.h> #include<netinet/in.h> #define PORTNO 15000 #define BUFFER_LEN 256 in...
C
#include <stdlib.h> #include <string.h> #include "analytics.h" struct word_list { char **words; size_t count; size_t size; }; word_list_t word_list_create(size_t n) { struct word_list* wl; wl = malloc(sizeof(struct word_list)); wl->words = calloc(n, sizeof(char*)); wl->words[0] = NULL; ...
C
#define SDL_MAIN_HANDLED #include <SDL2/SDL.h> #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <time.h> #define QUEUE_SIZE 256 struct ThreadState { pthread_t thread_id; }; struct RGBA { unsigned char b, g, r, alpha; }; struct Vertex { int x, y; union { RGBA rgba; ...
C
/*------------------------------------------------------------------- * UW CSE 351 Summer 2013 Lab 5 Starter code: * single doubly-linked free block list with LIFO policy * with support for coalescing adjacent free blocks * * Terminology: * o We will implement an explicit free list allocator * o ...
C
#include <stdio.h> #include <unistd.h> #include <string.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int main(int argc, char *argv[]){ int pfd[2]; int pfd2[2]; int f2, i; int value; pipe(pfd); pipe(pfd2); int f = fork(); if(f == 0) { char bufIn[128]; cha...
C
#include<stdio.h> #include<stdlib.h> int main() { int two = 0, three = 0; printf("number square cube\n"); for (int i = 0; i <= 10; i++) { two = i*i; three = i*i*i; printf("%-7d%-7d%d\n", i, two, three); } system("pause"); return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define STUDENTS_SIZE 20 #define GRADES_SIZE 5 typedef enum { Automation, Electronics, Machine, Telecommunications, Informatics, ComputerSystems } Facluty; typedef enum { bachelor, master, doctor } Oks; typedef struct { char name[100]; char last...
C
#include <stdio.h> #include <stdlib.h> #include <getopt.h> int main(int argc, char **argv) { const char *usage = "Usage: server [-p port] /path/to/root"; int opt; int port = 8080; // the getopt is used to break up (parse) options in command lines // for easy parsing by shell procedures // // When getopt ...
C
#include <fcntl.h> #include <stddef.h> #include <stdint.h> #include <stdio.h> #include <string.h> #include <sys/mman.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include "vice.h" void vice_deinit(struct vice *vice) { munmap(vice->regs, 0x10000); close(vice->vice_fd); } unsigned vice_get_revi...
C
/****************************************************************************** #5 : Infix to postfix conversion in C *******************************************************************************/ #include <stdio.h> #include <stdlib.h> // /* == Please import Functions from : "#2 Linked List imp...
C
#include <sys/poll.h> #include <sys/select.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <string.h> #define err_exit(msg, rc) { perror(msg); exit(rc); } static int openfile(char *); static void showdata(char *, int); int main(int...