language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include "ft_stock_str.h" #include <stdio.h> #include <stdlib.h> struct s_stock_str *ft_strs_to_tab(int ac, char **av); int main(void) { int i; t_stock_str *stock; char **arr; arr = (char **)malloc(sizeof(char *) * 4); i = 0; while (i < 3) { arr[i] = (char *)malloc(sizeof(cha...
C
#include<stdio.h> int main() { int t,n,i,j,key,a[10],l,h,f=0; printf("Enter the number of testcases\n"); scanf("%d",&t); for(i=0;i<t;i++) { printf("\nEnter the number of elements in array and element to be searched\n"); scanf("%d %d",&n,&key); printf("Enter the elements of array\n"); for(j=0;j<n;j++) {...
C
#include "ets_sys.h" #include "osapi.h" #include "os_type.h" #include "user_interface.h" #include "driver/gpio16.h" #include "driver/buttons.h" extern float target_temperature; extern bool change_temp_mode; extern uint32 change_temp_mode_started; extern uint8_t pin_num[GPIO_PIN_NUM]; // GPIO_PIN_INTR_NEGEDGE - down ...
C
/* This program is used with traditional phase-shifting Unwraps high-frequencies phases using gradually higher frequencies Input 16bits high/low freq phase-maps, outputs the LUT */ #include <stdlib.h> #include <stdio.h> #include <omp.h> #include <string.h> #include <math.h> #include <time.h> #include "args.h" ...
C
//---------------------------------------------------------------------------------------------- // float sqrt(float x) // // Description: // // square root // // Input: // float x // // Output: // square root of x // //---------------------------------------------------------------...
C
/* util.c */ #include "SubMtxManager.h" #define MYDEBUG 0 /*--------------------------------------------------------------------*/ /* ----------------------------------------------- return a pointer to a SubMtx object that has been initialized with the input parameters created -- 98may02, cca ----...
C
#include <stdio.h> int main(void){ int i1=0, i2=1, n, res; scanf("%d",&n); for(;n;--n){ res=i2; i2+=i1; i1=res; } printf("%d\n",res); }
C
#include "holberton.h" #include <stdio.h> /** * main - natural_numbers * * Return: Always 0 */ int main(void) { int num1 = 1; int num2 = 1; int cont = 0; for(cont = 0; cont <= 50;cont++ ) { printf("%d\n", num); num= num+num; } return (0); }
C
#include <sys/stat.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include "dirent.h" #define T Dirent_T struct T { char name[FILE_MAXNAME]; char shortname[FILE_MAXNAME]; long ino; int type; int statreturn; }; T Dirent_new( char *name ) { struct stat stbuf; int res; re...
C
// Jordan Chalupka 0928528 #include "avl.h" int balanceFactor (BinNode * tree) { int bf = getHeight(tree->left) - getHeight(tree->right); return bf; } /* Left Left Rotate */ BinNode *avl_rotate_leftleft(BinNode *node) { BinNode *a = node; BinNode *b = a->left; a->left = b->right; b->right = a; return(b); ...
C
#ifndef __GET_KEY_PROC_H__ #define __GET_KEY_PROC_H__ /* 키보드 입력을 처리 해주는 함수 모음 */ /* 키보드 입력을 사용할 윈도우는 커서 위치를 저장하고 통신을 할 수 있는 아래의 변수를 반드시 가져야 한다. * int i_cursor_y; * int i_cursor_x; * int high_level; * int low_level; * 위의 변수 값을 참고하여 키보드 입력을 받고 지정해둔 기능에 맞게 수행하게 된다. */ void get_keyboard_input(char *high_l...
C
#include "dht11.h" #include <stdio.h> uint8 DHT11_ReadData(void) { uint8 i,temp=0; for(i=0;i<8;i++) { while(!rDHT11);//ÿһbitݶ50us͵ƽʱ϶ʼ Delay_us(33);//ȷʱ33us if(rDHT11)//λΪ1 { temp=temp<<1 | 0x01; while(rDHT11); } else//λΪ0 t...
C
/*====================================================================== modIBPRRIOAP(M,I,B,k; L,t) Integral bivariate polynomial real root isolation over an algebraic point Inputs M : the minimal integral polynomial of an algebraic number \alpha. I : an open standard logarithmic is...
C
int main(){ setlocale(LC_ALL, "portuguese"); float a, b, c; // Lados printf("Entre com o angulo A: "); scanf("%f", &a); printf("Entre com o angulo B: "); scanf("%f", &b); printf("Entre com o angulo C: "); scanf("%f", &c); if (a + b >= c && a + c >= b && b + c >= a)...
C
#include <stdio.h> #include <unistd.h> #include <string.h> #include <pthread.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include "nnbc.h" #include "storage.h" #include "subscribers.h" #include "globals.h" #include "netmap.h" #include "parse_config.h" float t1_threshold; float t2_threshold; int...
C
/** \brief Suma dos numeros float. * * \param float primer miembro de la suma. * \param float segundo miembro de la suma. * \return float resultado de la suma. * */ float suma(float numeroA, float numeroB) { float resultado=0.0; resultado=numeroA+numeroB; return resultado; } /** \brief Resta dos num...
C
#include<stdio.h> #include<pthread.h> FILE *fp; int readflag=0; int completed=0; void *thread1(void *arg) { fp = fopen("New.txt","r"); char ch; while(1) { if(completed==1) break; if(readflag==0) { ch = getc(fp); if(ch==EOF) { completed=1; break; } printf...
C
#include <stdio.h> #include <stdlib.h> int main(void) { int n, i, tmp, flag; while (scanf("%d", &n) != EOF && n != 0) { flag = 0; for (i = 2; i * i <= n; i ++) { tmp = i * i; if (n % tmp == 0) { flag = 1; break; } } if (flag == 1) { printf("Yes\n"); } else { printf("No\n"); } } ...
C
#include "bh-sd-gooroom.h" int main(int argc, char *argv[]) { int socket_fd; char buf[OUTPUT_BUF_SIZE]; struct sockaddr_in server_addr; int n, len; int signal; pid_t pid; int status; if ((socket_fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { fprintf(stderr, "socket creation failed...
C
#include <stdio.h> int main(void) { printf("%d %d %lfԴϴ.", 1, 2, 1 / 2); return 0; }
C
/********************************************** * file name: buffer.h * description: sample memory buffer * *********************************************/ // // remvoe the macro below may case issues when include<stdio.h> // #if (defined __USE_XOPEN || defined __USE_XOPEN2K8) #undef __USE_XOPEN #undef __USE_XOPEN...
C
#include <stdio.h> int main(void) { // your code goes here int t; scanf("%d",&t); while(t--) { long long int n; scanf("%lld",&n); long long int a[n],i,pos=0,neg=0,zer=0; for(i=0;i<n;i++) { scanf("%lld",&a[i]); } for(i=0;i<n;i++) { if(a[i]<...
C
#include <stdio.h> int isPalindrome(unsigned long n) { unsigned long nreverse = 0, orign = n; while (n > 0) { nreverse = nreverse * 10 + n % 10; n /= 10; } return(orign == nreverse); } int main(void) { unsigned long palindrome = 0, prod; int i1, i2; for (i1 = 99; i1 < 999; ++i1) { for (i2...
C
/* * Copyright 2015 International Business Machines * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by...
C
#include <stdio.h> void add(); int main () { printf("addition of two nos."); add(); return 0; } void add() { int a,b,c; printf("enter a and b"); scanf("%d%d",&a,&b); c=a+b; printf("%d",c); }
C
#include<stdio.h> #include<malloc.h> struct node { int id; struct node * next; }; struct node *start, *new_node, *ptr; int main() { int n,k, round = 0; printf("\nEnter the number of players: "); scanf("%d",&n); printf("\nEnter the value after which each member is eliminated: "); scanf("%d",...
C
#pragma once /** * Intrusive doubly-linked list. * * The list is looped, and when empty its head node must have both * pointers have the same value pointing to the head. */ struct list { struct list *prev; struct list *next; }; #define list_head(head) \ ...
C
#include<stdio.h> int divisible(int num1, int num2); int main() { int num1, num2; printf("Enter range numbers: "); scanf("%d%d", &num1, &num2); divisible(num1,num2); } int divisible(int num1, int num2) { int i, count1=0, count2=0; for (i = num1; i < num2; i++) { if (i % 5 == 0) ...
C
#ifndef SERVEUR_H /* Include guard */ #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdint.h> #include <unistd.h> #include <arpa/inet.h> #include <pthread.h> #include <signal.h> #include <semaphore.h> #include <dirent.h> #in...
C
// 7**0 = 1 - 1 // 7**1 = 7 - 7 // 7**2 = 49 - 9 // 7**3 = 343 - 3 // 7**4 = 2401 - 1 // 7**5 = 16807 - 7 // 7**6 = 117649 - 9 // 7**7 = 823543 - 3 // 7**8 = 5764801 - 1 // O ciclo se repete a cada a cada 4 pulos... // Então, temos a sequencia [ 1,7,9,3 ] (?). // O expoente % 4 no...
C
//二级指针字符串 #include<stdio.h> #include <string.h> void change(char **str); char str1[20] ="notepad"; char str2[20] ="calc"; int main() { char *p =str1; printf("p in main:p= %p,str1=%p\n",p,str1); //p in main: 00403008,00403008 change(&p); //change把p的指向给改变,等价于p=str2 printf("after change: p=%s,p=%p\n",p,p...
C
/***************************************************** *@file DirectionControl.c * *@core K60FX *@date 2019 ******************************************************/ #include "include.h" /**********ȫֱ********/ float Direction_P = 10; //P PƫӦ ת估ʱǹ˾ӦP float Direction_D = 10; //D float Direction_PZJ = 30; float Direc...
C
/* 27 - 29 */ #include <stdio.h> int main(void) { { unsigned char a = 0x46; // 01000110b unsigned char b = 0x44; // 01000100b unsigned char mask = 0x06; // 00000110b printf("a & mask %x, res %d\n", a & mask, (a & mask) == mask); printf("b & mask %x...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_backtraking_fillit.c :+: :+: :+: ...
C
#include "stdio.h" struct venky { int mar; float per; char gd; }; union siri { int mar; float per; char gd; }; main() { struct venky v; v.mar=500; v.per=300; v.gd='A'; printf("mar:%d\n per:%f\n gd:%c\n",v.mar,v.per,v.gd); printf("size of struct:%d\n",sizeof(struct venky)); printf("add ...
C
#include<stdio.h> #include<stdlib.h> int main() { char* pmem; printf("sizeof(int)의 길이는 %ld 입니다. \n",sizeof(int)); pmem = calloc(100,sizeof(int)); if(pmem == NULL) puts("메모리 할당에 실패하였습니다."); else{ puts("int형변수 100개 할당에 성공하였습니다."); printf("%ld \n",sizeof(pmem)); free(pmem); } }
C
* * * * * * * * Imprime o mesmo padrão, porém com dez linha e dezenove colunas #include <stdio.h> main () { int c,l, i; { for (l=1, l<=19; l**) putchar ('*'); putchar ('n'); } return=0; }
C
#include <stdio.h> #include <stdlib.h> int main() { int a; int b; int c; int d; scanf("%d %d %d %d", &a, &b, &c, &d); printf("%d \n",a); printf("%d \n",b); printf("%d \n",c); printf("%d \n",d); return 0; }
C
#include <stdio.h> #include <string.h> #include <microhttpd.h> #include <wait.h> #include "frontend.h" #include "httpserver.h" #include "types.h" #include "storage.h" #include "routes.h" #define ROUTES_COUNT 5 struct Route routes[ROUTES_COUNT]; int handle_add_channel(struct Request *request, struct Response *respons...
C
#include <std.h> inherit "/d/common/obj/weapon/dagger.c"; create(){ ::create(); set_id(({"dagger","quickdagger"})); set_name("platinum dagger"); set_obvious_short("%^BOLD%^%^WHITE%^A beautiful platinum dagger%^RESET%^"); set_short("%^BOLD%^%^CYAN%^Whir%^BOLD%^%^BLUE%^l%^BOLD%^%^CYAN%^wind%^RESET%^"); ...
C
#include <stdlib.h> #include <string.h> #include <stdio.h> //#include <gtk/gtk.h> //#include "Cuadros.h" #include "Arboles.h" #include "Arbol.h" #include "Proyecto.h" void Arbol1(int argc, char *argv[]) { gtk_init (&argc, &argv);//Se inicia el modo gtk // Se crea la ventana principal VPrincipal. VPrincipal = gtk_w...
C
#include "util.h" #include <dirent.h> #define EXIT 1 #define GETDENTS 141 #define STDERR 2 #define SYS_WRITE 4 #define STDOUT 1 #define STDERR 2 #define SYS_OPEN 5 #define O_RDONLY 0 #define DT_UNKNOWN 0 # define DT_FIFO 1 # define DT_CHR 2 # define DT_DIR 4 # define DT_BLK 6 # define DT_REG 8 # define DT_LNK 10 # ...
C
#include <stdio.h> #include <malloc.h> int _multiple(int n, int *a, int size) { int overflow = 0; for (int i = 0; i < size; i++) { int t = a[i] * n + overflow; a[i] = t % 10; overflow = t / 10; } if (overflow > 0) { while (overflow > 0) { a[size++] = overflow...
C
#include <stdio.h> int main() { float ResistenciaTotal; float resistencia1; float resistencia2; float resistencia3; float paralelo01; float VIn; float ITotal; float I1; float I2; float...
C
/* Write a function check(x, y, n) that returns 1 if both x and y fall between * 0 and n - 1, inclusive. The function should return 0 otherwise. Assume that * x, y, and n are all of type int. */ int check(int x,y,n) { if(x>0&&y>0&&x<n-1&&y<n-1) return 1; else return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <malloc.h> #include <fcntl.h> #include <unistd.h> #include <math.h> #include <GL/glut.h> #include <GL/rgb.h> #define STEPCOUNT 40 #define FALSE 0 #define TRUE 1 #define MAX(a, b) (((a) > (b...
C
#include "bit_array.h" #include <stdlib.h> inline void* create_bit_array(bit_array* array, uintmax_t size) { // TODO, CHECKING, MAYBE THIS IS A STUPID MISTAKE array->data = calloc(size, sizeof((size + 7) / 8)); array->size = size; return array->data; } inline void destroy_bit_array(bit_array* array) { free...
C
#include "types.h" #include "x86.h" #include "defs.h" #include "date.h" #include "param.h" #include "memlayout.h" #include "mmu.h" #include "proc.h" int sys_fork(void) { return fork(); } int sys_exit(void) { exit(); return 0; // not reached } int sys_wait(void) { return wait(); } int sys_thread_create(voi...
C
/* SYNOPSIS Solution for chapter 48. SOLUTION All of exercise of chapter 48 are skiped because we should avoid System V shared memory. System V shared memory doesn't complicate as message queues or semaphores, but it required message queues or semaphores to synchronize read/write. So avoid it. ...
C
/** * Structure declaration * A struct is a type consisting of a sequence of members whose storage is * allocated in an order sequence (as opposed to union, which is a type * consisting of a sequence of members whose storage overlaps). * The {type specifier} for struct is identical to the union type specifier * e...
C
#ifndef LISTA_ENCADEADA_H_ #define LISTA_ENCADEADA_H_ /*Lista Encadeada Genéria que recebe qualquer tipo de dados como parametro*/ #include <stdio.h> #include <stdlib.h> typedef struct lista_encadeada* Lista_Encadeada; Lista_Encadeada construtor_lista_encadeada (void); Lista_Encadeada destrutor_lista_encadeada (Lista_...
C
#include<stdio.h> #include<stdlib.h> #define SIZE(a) sizeof(a) / sizeof(a[0]) int main112() { char murder[4] = { 'a', 'b', 'c', 'd' }; char killer; int i; /* A˵ҡ B˵C C˵D D˵Cں˵ */ for (i = 0; i < SIZE(murder); i++){ killer = murder[i]; if ((murder[0] != killer) + (murder[2] == killer) + (murder[3] == k...
C
#ifndef BSTREE_H #define BSTREE_H //typedef struct tree tree; struct bstree{ char *value; int key; struct bstree *left; struct bstree *right; }; struct bstree *bstree_create(char *value, int key); void bstree_add(struct bstree *tree, char *value, int key); struct bstree *bstree_lookup(struct bstree *t...
C
#include <stdio.h> #include <unistd.h> void leer(int * fd); void escribir(int * fd); int main(int argc, const char * argv[]){ int tuberia[2]; pid_t pid; int n = atoi(argv[1]); int i = 0; for(;i<n;i++){ pid = fork(); pipe(tuberia); if (pid == -1){ printf("Error al crear el proceso hijo"); //exit...
C
#include<stdio.h> #include<stdlib.h> int main() { FILE *f1,*f2,*f3; char c; f1=fopen("1.txt","r"); f2=fopen("2.txt","r"); f3=fopen("3.txt","w"); if((f1==NULL)||(f2==NULL)||(f3==NULL)) { printf("error"); exit(0); } while((c=fgetc(f1))!=EOF) { fputc(c,f3); } while((c=fgetc(f2))!=EOF) { fputc...
C
#include <stdio.h> /* Example of using getchar and putchar */ main() { char c; printf("Please enter a character: "); c = getchar(); printf("Your character is: "); putchar(c); printf("\n\n"); }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_recursive_factorial.c :+: :+: :+: ...
C
#include<stdio.h> struct Ournode{ char x,y,z; }; int main() { struct Ournode p={'a','0','a'+2}; struct Ournode *q=&p; printf("%c\t%c",*((char *)q+1),*((char *)q+2)); return 0; }
C
#include <stdio.h> int main(void) { int num; printf(" Էϼ : "); scanf("%d", &num); num = num/10; switch (num) { case 10: case 9: printf("A\n"); break; case 8: printf("B\n"); break; default: printf("F\n"); break; } return 0; } /* Է¹ ׻ 100 ̹Ƿ ̸ 10 10 ˴ϴ. Է¹ ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* utilitaries_3.c :+: :+: :+: ...
C
#include<stdio.h> #include<string.h> int main(){ char num1[101],num2[101]; int i,c,length1,length2; int range=0; while(scanf("%s%s",num1,num2)!=EOF){ length1=strlen(num1); length2=strlen(num2); if(length1>length2){printf("LARGE\n");} else if(length2>length1){printf("LITTLE\n");} else{//ͬ for(i=0;i<length1;i...
C
#include<stdio.h> int main() { int blorf; blorf=22; printf("The value of blorf is %d.\n",blorf); printf("The value of blorf plus 16 is %d.\n",16+blorf); printf("The value of blorf times itself is %d.\n",blorf*blorf); return(0); }
C
int main () { x = 10; y = 2.5 / x; z = 2.5 + x; print(x, y, z); }
C
/******************************************************** * RSBS WS 13/14 - Blatt 09 Aufgabe 3 * * * * Author : Michael Krane 2233018 * * * * Purpose: Analyse der ELF-Da...
C
#include <sys/types.h> #include <sys/ipc.h> #include <sys/sem.h> #include <sys/shm.h> //#include "shmem.h" #include <stdio.h> #include <stdlib.h> #define MAXBUFF 80 #define PERM 0666 /*Структура данных в разделяемой памяти*/ typedef struct mem_msg { int segment; char buff[MAXBUFF]; } Message; ma...
C
/* Disciplina: Algoritmos Computacionais (matutino) Prof.: Orlewilson B. Maia Autor(a): Seu nome Data: 21/05/2018 Descrio: Ler N valores informado pelo usurio, calcular soma e mdia */ // Bibliotecas #include <stdio.h> // Programa Principal int main() { // variveis int qtdValores, // quantidade de...
C
int main(int argc, char **argv) { /* This is essentially the same main function from readdemo.c */ libtrace_t *trace = NULL; libtrace_packet_t *packet = NULL; /* Ensure we have at least one argument after the program name */ if (argc < 4) { fprintf(stderr, "Usage: %s ...
C
#include<stdio.h> main() { int num[]={24,34,12,44,56,17}; display(num,6); } display(int *j,int n) { int i; for(i=0;i<n;i++) { printf("%d",*j); j++; } }
C
#include "hash_tables.h" #include <string.h> #include <stdlib.h> #include <stdio.h> /** * hash_table_set - sets hash table * @ht: hash table * @key: key * @value: value * * Return: 1 if successful, 0 if fails */ int hash_table_set(hash_table_t *ht, const char *key, const char *value) { unsigned long int idx; ...
C
#include "filereader.h" char* readFileBytes(const char *name) { FILE *fl = fopen(name, "r"); fseek(fl, 0, SEEK_END); long len = ftell(fl); char *ret = malloc(len); fseek(fl, 0, SEEK_SET); fread(ret, 1, len, fl); fclose(fl); return ret; } int writeFileBytes(char* fileBytes, char* fileNa...
C
#include <stdio.h> #define MAX 100 #define NOT_CALCULATED (-1) #define q (1 - (p)) /* Вероятност B да спечели отделен мач */ const float p = 0.5; /* Вероятност A да спечели отделен мач */ const unsigned n = 5; float PS[MAX][MAX]; float pDyn(unsigned i, unsigned j) /* Динами...
C
#include <pthread.h> #include <stdio.h> enum { TC = 10 }; void* cal (void* ptr) { int c = *(int*) ptr; printf("%d\n",c); return NULL; } int main() { int counts[TC] = {0}; pthread_t threads[TC] = {0}; size_t count = 0; while (count < TC) { counts[count] = count; pthread_...
C
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <string.h> int main() { char str[1000000]; int sum = 0; gets(str); char *ptr = strtok(str," "); while (ptr != NULL) { //printf("%s\n", ptr); ptr = strtok(NULL, " "); sum++; } printf("...
C
/*print chord formed on intersection of line and circle*/ #include<stdio.h> #include<math.h> void main() { int h, k, r,s ; printf ("please enter thr coordinates of center"); scanf("%d%d",&h,&k); printf("please enter the radius of circle and value of x for eqn x=s"); scanf("%d%d",&r,&s); float d...
C
#define period 10 //const int leftMotorPin = 9; //const int rightMotorPin = 8; // //const int forwardMotorPin = 10; //const int backwardMotorPin = 11; int pwm_a = 3; //PWM control for motor outputs 1 and 2 int pwm_b = 9; //PWM control for motor outputs 3 and 4 int dir_a = 2; //direction control for motor outputs 1...
C
#include <stdio.h> // without argument with return value int takenumber() { int n; printf("enter a number:\n"); scanf("%d",&n); return n; } int main() { int c; c=takenumber(); printf("The entered number is %d",c); return 0; }
C
/*NOTE : priority of dot(.) operator is more than dereferencing (*) operator and address (&) operator*/ #include<stdio.h> int main() { int i,j; struct stu { char name[20]; float marks[2]; int rollno; }; struct stu s1[2],*ptr; ptr=s1; printf("Enter the student details :\n"); for(i=0;i<2;i++) { printf("E...
C
#include <stdio.h> struct entry { int value; struct entry *next; }; void insertEntry(struct entry *toInsert, struct entry *after) { toInsert->next = after->next; after->next = toInsert; } int main (int argc, char *argv[]) { void insertEntry(struct entry *toInsert, struct entry *after); struc...
C
#include "lb_matrix.h" #include <stdlib.h> // Assume A.num_cols == B.num_rows // C.num_rows == A.num_rows // C.num_cols == B.num_cols void lbmm(Matrix A, Matrix B, Matrix result) { int col,row,offset,vec_length; double vec_sum; vec_length = A.num_cols; for(col = 0; col < B.num_cols; col++) { for(row = 0; ro...
C
#include<stdio.h> int main() { char str[100]; int i; printf("请输入一行英文\n"); gets(str); for(i=0;str[i]!='\0';i++) { if(str[i]>=97 && str[i]<=122) { str[i]-=32; } } printf("the sorted words:\n"); for(i=0;str[i]!='\0';i++) { printf("%c",str[i]); } printf("\n"); }
C
#include "apue.h" #include <errno.h> #include <sys/wait.h> void pr_exit(int status) { if (WIFEXITED(status)) printf("normal termination , exut status = %d\n", WEXITSTATUS(status)); else if (WIFSIGNALED(status)) printf("normal termination , exut status = %d\n", WTERMSIG(status) #ifdef WCOREDUMP...
C
/** * @file cstr.c * @author ln * @brief the c string process **/ #include "cstr.h" #ifdef __cplusplus extern "C" { #endif /** * @brief Convert a string to lowercase * @param s String to convert * @return pointer to the new string **/ char* strlwr(char *s) { char *p = s; if (p) { ...
C
/*! \file thread.h * * Declarations for the kernel threading functionality in PintOS. */ #ifndef THREADS_THREAD_H #define THREADS_THREAD_H #include <debug.h> #include <hash.h> #include <list.h> #include <stdint.h> #include "synch.h" /* Open file. This is for a linked list of open files in each thread. */ struct s...
C
#include <stdio.h> /*Exercise4 (M) Write a program that calculated are of two squares (A and B). After this the program will tell how many squares B can fit in square A. Print the result of the calculations to the screen. ... This program calculates how many of square A can fit into square B */ int main(void) ...
C
// Program in C to create a Doubly Circular Linked List #include <stdio.h> #include <stdlib.h> // Structure of a node struct node { int data; struct node *previous; struct node *next; }; void printLinkedlist(struct node *p, struct node *start); void printLinkedlistReversed(struct node *p, struct node *start); ...
C
//***************************************************************************** // // Name(s): Justin Cox & Tyler Travis // // //***************************************************************************** #include <inc/tm4c123gh6pm.h> #include <stdint.h> #include <stdbool.h> #include <inc/hw_memmap.h> #include <driv...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <ctype.h> #include <math.h> int main() { char inputStr[14]; char outIntPart[61], outFracPart[61]; char digits[] = "0123456789abcdef"; int b1, b2, i, dotCounts = 0, frac = 0; int scannedCounts; scannedCounts = scanf("%d%d%13s", ...
C
/* * median.c */ #include "Funcs.h" #define DEFINE_MEDIAN_1D(TYPE_NAME,TYPE)\ static int cmp_##TYPE(a,b) TYPE *a,*b; {return *a - *b;}\ static void median_##TYPE(dest,src,median)\ image dest;\ image src;\ register long median;\ {\ register TYPE **src_data;\ register TYPE **dest_data;\ regis...
C
#include <sys/time.h> //struct timeval #include <stdlib.h> //rand, srand, RAND_MAX #include <stdio.h> //fprintf, stderr #include <time.h> //time #include "utils.h" long time_diff_us(struct timeval end , struct timeval start) { return (end.tv_sec - start.tv_sec) * 1000000 + end.tv_usec - start...
C
/************************************************************************* > File Name: tcp_client.c > Author: jack > Mail: hansheng.jiayou@qq.com > Created Time: 2018-03-20 14:47:45 ************************************************************************/ //此程序的作用为验证-面向连接的套接字 //“传输的数组不存在边界” #include<stdio.h> ...
C
#include <stdio.h> #define MAX_N (1100) int prime[300], prime2[300]; int n; int init_prime() { int i, j; prime[0] = 1; prime2[0] = 1; prime[1] = 2; prime2[1] = 4; n = 2; for(i = 3; i < MAX_N; i += 2) { for (j = 1; prime2[j] <= i; j++) if (i % prime[j] == 0) break; if (prime2[j] > i) { ...
C
#include<stdio.h> #include<conio.h> int main() { int a[10],i,item,n,pos; printf("Enter the no of elements of array:"); scanf("%d",&n); printf("Enter the elements of array:"); for(i=0;i<n;i++) scanf("%d",&a[i]); printf("Enter the value of the item and position to be inserted in array:"); ...
C
/* ** EPITECH PROJECT, 2019 ** MyFTP ** File description: ** Helper function */ #include <stdio.h> void print_helper(void) { printf("USAGE: ./myftp port path\n"); printf("\tport\tis the port number on which the server socket listens\n"); printf("\tpath\tis the path to the home directory for the anonymous"...
C
// Fibonacci recursion // 通过算法分析,发现其实 Fibonacci数列其实并不适合用递归啊! // 因为每次调用求 Fibonacci(num-1) 对 Fibonacci(num-2) 多算了一次,因此递归会霸占更多的内存, // 程序会变慢,到后面会发现时间复杂度将会呈指数增长。 // 不过题目要求,没办法。。。 // 其实通过分析发现,可以用for用一个buffer数组储存。 // from Eajack <Note> // 2016.11.17 #include <stdio.h> int Fibonacci(int num); int main() { int i,len; while(l...
C
#include <stdio.h> int swap(int *a, int *b); int main() { int a = 2, b = 5; printf("두 변수의 값을 바꿔주는 함수\n"); printf("바꾸기 전 a : %d, b : %d\n", a, b); swap(&a, &b); printf("바꾼 후 a : %d b : %d\n", a, b); return 0; } int swap(int *a, int *b) { // XOR Swap : https://en.wikipedia.org/wiki/XOR_swap_algorithm if (a != b...
C
/************************************************************************* > File Name: 1.c > Author: > Mail: > Created Time: 2016年04月26日 星期二 09时22分50秒 ************************************************************************/ #include<stdio.h> #include<stdlib.h> #include<time.h> int main(void) { int a[10]; ...
C
////////////////////////////////////////////// // AVR UART LIBRARY // FOR ATMEGA8 // // ONLY IMPLEMENTS THE ASYNCHRONOUS MODE // // DECEMBER 26, 2016 // // ANKIT BHATNAGAR // ANKIT.BHATNAGARINDIA@GMAIL.COM ////////////////////////////////////////////// #include "AVR_UART_ATMEGA8.h" int8_t AVR_UART_Init(uint16_t baud,...
C
#include <stdio.h> #include <stdlib.h> #include <GL/glut.h> void keyboard(unsigned char key, int x, int y) { if (key == 27) exit(0); } void display() { glClear(GL_COLOR_BUFFER_BIT); glutSwapBuffers(); } int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_DE...
C
#include <linux/kernel.h> #include <linux/init.h> #include <linux/module.h> #include <linux/list.h> #include <linux/types.h> #include <linux/slab.h> #define SETMEMORY(person) person = kmalloc(sizeof(*person),GFP_KERNEL); static LIST_HEAD(birthday_list); struct birthday { int day; int month; int year; char *name;...
C
/* ** bite_c_4_2 ** 2018_10_31 ** 0999֮Сˮɻ */ #include "stdio.h" #include "stdlib.h" #include "math.h" int main() { int i = 0; int units = 0; int tens = 0; int hundreds_digit = 0; int flag = 0; printf("ˮɻ: \n"); for (i = 0; i < 1000; i++) { if (i < 100) { continue; } hundreds_digit = i / 100; ten...