language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <malloc.h> #include <sched.h> #include <synch.h> #include <callo.h> #include <string.h> #include <types.h> #include <conf.h> #include <buf.h> #include <proc.h> void util1(void) { struct buf *buf; int i; printf("UTIL1 : Demande de [%d, %d] ...
C
///////////////////////////////////////////////////////// // File Name : gen_file.c // // Date : 2020/10/23 ~ 2020/11/05 // // OS : Ubuntu 16.04.3 LTS // // Student Name : Seung Hoon Jeong // // Student ID : 201570700...
C
#include <stdio.h> #include <sys/socket.h> #include <arpa/inet.h> #include <string.h> #include <stdlib.h> #include <unistd.h> /*********** Client APIs ************ # int socket(int protocolFamily, int type, int protocol) @Params: ProtocolFamily = PF_INET; type = SOCK_STREAM; protocol = IPPROTO_TCP @Re...
C
/* ** EPITECH PROJECT, 2019 ** pop ** File description: ** delete peek in stack */ #include "new.h" #include <stdlib.h> char pop(stack_t **head) { stack_t *node; char previous_data = (*head)->data; if (*head == NULL) { exit(1); } else { node = *head; *head = (*head)->next;...
C
#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> #include"game.h" #include<stdlib.h> #include<time.h> //Ϸпչʤ㷨3*3 void game()//Ϸ { char board[ROW][COL] = {0}; init_board(board, ROW, COL);//ʼȫΪո display_board(board, ROW, COL);//ʾ̣ char ret = 'a'; while (1) { // PlayerMove(board, ROW, COL); display_board(b...
C
#include <stdio.h> #include <stdbool.h> int main() { bool shaunIsFast = true; //else true printf("How fast tho (1 is flash, 0 is slowpo)? %i\n ", shaunIsFast); printf ("%i\n", shaunIsFast + 11); return 0; }
C
/* * File: main.c * Author: peter * * Using threads to solve producer consumer problem * Interprocess Communication, p.133 * Tanenbaum A., S., "Modern Operating Systems, 3rd edition" * * Created on June 7, 2014, 6:38 PM */ #include <stdio.h> #include <stdlib.h> #include <pthread.h> #define MAX 100 pthre...
C
#include <stdlib.h> #include <string.h> #include <errno.h> #include "parser.h" #include "config.h" char * epurate_string(const char *to_epurate) { char *epurated; char *tmp; if (to_epurate == NULL) return NULL; epurated = malloc(sizeof(char) * strlen(to_epurate) + sizeof(char)); tmp = epurated; if (epurate...
C
//ʵʹabʾcʱ临ӶȴN3͵N2ﲻ֮ͽװ #include<stdio.h> #include<string.h> #include<stdlib.h> int main(void) { int *book,i,m, n, x, y, z,sum=0; book = (int*)malloc(sizeof(int) * 1111);//һ£24»ܴ1111 printf_s("жٸ"); scanf_s("%d",&m); n = m - 4;//ںź͵ȺҪռĸ //õ1-9ijʼ for (i=0;i<=9;i++) { printf_s("book[%d]Ҫٸ:",i); scanf_s("%d"...
C
/* Includes */ #include <avr/io.h> #include "direction.h" #include "modeswitches.h" #include "cleaner.h" #include "main.h" #define F_CPU 1000000UL #include <util/delay.h> int main(void) { // Setup I/O MainInitialize(); // Main program loop while(1) { // Clean x axis MainCleanerX(D...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* cosa.c :+: :+: :+: ...
C
#pragma once #include "../imagelib/image.h" #define PRIME 997 #define RADIX 3 #define BLACK 0 #define WHITE 127 #define GRAY 64 /* Definimos este operador para imitar el operador módulo de Python (%), de tal manera que se comporte bien con números negativos también. Basado en: https://www.lemoda.net/c/modulo-operat...
C
#include <stdio.h> #include <stdlib.h> void hello (int a) { std::cout << "Hello World!" << std::endl; } void show(int x[][9] , int m , int n){ for (int i = 0; i < 9; ++i) { for (int j = 0; j < 9; ++j) { printf("%d ",x[i][j]); } printf("\n"); } printf("\n"); } void ...
C
#include<stdio.h> #include<stdlib.h> #include<fcntl.h> #include<unistd.h> #include<string.h> int main() { int fd,ret; char b[10]; memset(b,0,sizeof(b)); fd=open("/dev/hrt_1",O_RDWR); printf("%d",fd); if (fd < 0) { printf("Open Errrrr"); return -1; } ret=write(fd,&b,sizeof(b)); printf("%d",ret); if (ret < 0 ) { p...
C
#include <stdio.h> #include <stdlib.h> typedef struct lista{ int num; struct lista* prox; }lista; typedef struct pilha{ int quantidade; lista* topo; }pilha; pilha * cria(){ pilha*p=(pilha*)malloc(sizeof(pilha)); p->topo=NULL; return p; } void insere_pilha(pilha*p, int valor) { l...
C
void insertionSort(long arr[], long n); long test() { long a[5]; a[0] = 5; a[1] = 4; a[2] = 3; a[3] = 1; a[4] = 2; insertionSort(a, 5); if (a[0] == 1 && a[1] == 2 && a[2] == 3 && a[3] == 4 && a[4] == 5) { return 1; } else { return 0; } } void insertionSort(long arr[], long n) { lon...
C
/*Разширяване на заделена памет с realloc Напишете програма, която пита потребителя колко памет иска и заделя съответния блок памет. След това попитайте потребителя за нов размер и използвайте функция, която прави това.*/ #include <stdio.h> #include <stdlib.h> int funRealloc(int *ARR); int main(){ unsigned uSize...
C
#include <stdio.h> #include <conio.h> #include <string.h> #define MAXSTACK 25 #define TRUE 1 #define FALSE 0 struct stack { char expr[MAXSTACK]; int top; }; int empty(struct stack*); /* function prototype for empty; returns TRUE if stack is empty, FALSE otherwise */ void initStack(struct...
C
#include <stdio.h> #include <stdlib.h> struct element { int value; struct element *next; }; int main(void) { int values[10] = { 2, 4, 5, 6, 7, 8, 9, 1, 3, 0}; struct element *q = malloc(sizeof(struct element)), *cur = q, *temp; for (int i = 0; i < 9; ++i, cur = cur->next) cur->value = values[i], cur->next =...
C
#include <stdio.h> int main() { int n,a[50],b[50],n1,n2,larg[50],i,j,k; scanf("%d",&n1); for(i=0;i<n1;i++) { scanf("%d",&a[i]); } scanf("%d",&n2); for(i=0;i<n2;i++) { scanf("%d",&b[i]); } for(i=0;i<n1;i++) { larg[i]=a[i]; } n=n1+n2; for(i=...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #include "irregular.h" void sep() { printf("+%.*s+", WORD_SIZE + 2, "-------------------------------------------------------------------" ); printf("%.*s+", WORD_SIZE + 2, "-------------------------------------------------------------------" ); p...
C
/* You have to print the character, ch, in the first line. Then print s in next line. In the last line print the sentence, sen. Sample input: C Language Welcome To C!! Sample output: C Language Welcome To C!! */ #include <stdio.h> #include <string.h> #define MAX_LEN 100 ...
C
#include<stdio.h> #include<conio.h> #include<string.h> struct emp { int id; char name[20]; float sal; float ded; float bon; }; struct dep { char name[20]; struct emp e[3]; }; void main() { struct dep d1; float net[3]; int i; clrscr(); printf("\nenter the dept name:"); scanf("%s",&d1.name); for(...
C
#include "includes.h" #include <stdarg.h> #include "JLINKDCC.h" #define LCDNUM_ONLY_1 1 #define LCDFUNC_WRITE_LCD 0x61 #define LCDFUNC_CLEAR_LCD 0x62 #define LCD_PERLINE_MAX 24 #define LCD_LINE_MAX 2 const U8 ClearLineData[] = "00"; void LCD_DisplayALine(U8 line, U8 * str); void LCD_Clear(U8 lin...
C
#include <stdio.h> /* * C ѧϰ֮· * 2021-8-4 * Ҫѧϰָ롣 */ const int MAX = 3; const int LENGTH = 10; struct Stu{ char name[20]; short age; char sex[5]; }; void fun1(void); void fun2(void); void fun3(void); void fun4(void); void fun5(void); void fun6(void); void print1(struct Stu tmp); void print2(struct S...
C
/* @(#)w_jn.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * * Developed at SunPro, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this * software is freely granted, provided that...
C
#include "binary_trees.h" /** * binary_tree_height - Find the height of the longest branch in a binary tree * @tree: The tree to find the height of * Return: left_height if left branch is bigger, right_height if right branch * is bigger, 0 if tree is NULL or tree is a leaf **/ size_t binary_tree_height(const bina...
C
#include <stdio.h> #include <stdlib.h> float** converte_a (int m, int n, float* mat); void ler_matriz(int m, int n, float* mat); void imprime_matriz(int m, int n, float** mat); void libera(int n, float **mat); void main(void) { int linhas, colunas, i, j; scanf("%d%d", &linhas, &colunas); float* mat; float** mat...
C
#ifndef COOP_SHAPES_H #define COOP_SHAPES_H struct Shape; struct IShape { void (*destruct)(struct Shape *self); const char *(*get_type)(const struct Shape *self); int (*get_area)(const struct Shape *self); }; struct Shape { const struct IShape *vptr; int a; int b; }; struct Rectangle { ...
C
/* * Created 190309+0800 lynnl */ #include <stdio.h> #include <string.h> #include "lpm.h" #include "utils.h" #ifndef u8 #define u8 unsigned char #endif #define HEX_MAGIC 0xfadefacedeadbeef #define LOG(fmt, ...) (void) fprintf(stderr, fmt "\n", ##__VA_ARGS__) static void test1(void) { rax *rax =...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.c :+: :+: :+: ...
C
//Function declaration double **createMat(int m,int n); void readMat(int m,int n,double **p); void print(int m,int n,double **p); //End function declaration //Defining the function for matrix creation double **createMat(int m,int n) { int i; double **a; //Allocate memory to the pointer a = (double **)malloc(m * ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_pri_size_width.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> /*15. Scrivere una funzione che restituisca true se la stringa passata come parametro palindroma, false altrimenti.*/ #include <stdbool.h> #include <string.h> #define DIM 20 _Bool check_stringa_palindroma(char stringa[]); int main() { char s1[DIM+1] = "albicocche"...
C
/*! * \file gc.c * * \author Celine Dion * \date 2012-10-26 * * Functions needed to perform garbage collection */ #include "gc.h" #include "priv_imalloc.h" #include <stdio.h> //! Checks if the pointer is pointing within the adress space. /*! * Returns true if pointer ptr is within the addresspace on the heap t...
C
#include "holberton.h" /** * print_chessboard - This function will print out a chessboard * @a: is the array we will be using * */ void print_chessboard(char (*a)[8]) { int j; int d; for (j = 0; j < 8; j++) { for (d = 0; d < 8; d++) _putchar(a[j][d]); } }
C
#include "holberton.h" #include <stdio.h> /** * main - program which prints number of arguments * * @argc: int, number of arguments * @argv: array of pointer to these arguments * * Return: int, 0 (Success) */ int main(int argc, char *argv[]) { printf("%d\n", argc - 1); (void) argv; return (0); }
C
#include<stdio.h> int first = 0; int second = 1; int fibonacci_rec(int n) { if(n == 0) return first; if(n == 1) return second; else return fibonacci_rec(n-1) + fibonacci_rec(n-2); } int main(int argc, char const **argv) { int i; for(i = 0; i < 20; ++i) printf("%d-...
C
#include<stdio.h> int func1() { int a,b; b = 3; a = b; b = b * 2; printf("a = %d\n",a); printf("b = %d\n",b); return 0; } int func2() { int r; float c,s; r = 5; c = 2 * 3.14 * r; s = 3.14 * r * r; printf("半径为%d的圆,周长是%.2f,面积是%.2f\n",r,c,s); return 0; } in...
C
#include <sys/types.h> #include <unistd.h> #include <stdio.h> #include <string.h> int main(int argc, char *argv[]) { char buf[100]; size_t size = read(0, buf, 100); if (size > 0 && buf[0] == 'h'){ if (size > 1 && buf[1] == 'a'){ if (size > 2 && buf[2] == 'c'){ if (size > 3 && buf[3] == 'k'){ ...
C
/* LeetCode 796. Rotate String Glennshih@20180316 coding in C language */ #include <stdio.h> #include <string.h> #include <stdbool.h> bool rotateString(char* A, char* B) { char tmp; int len_char_a, char_a_position, rotate_left_times, judge=0; len_char_a = strlen(A); //maximun rotate left by (len...
C
#include <stdio.h> double fun (int i) { volatile double d[1] = {3.14}; volatile long int a[2]; a[i] = 1073741824; return d[0]; } int main(int argc, char const *argv[]) { printf("%f\n%f\n%f\n", fun(0), fun(1), fun(2)); printf("%f\n", fun(3)); printf("%f\n", fun(4)); return 0; } // 3....
C
#include <stdio.h> #include <stdlib.h> #include "../brk.h" #include <unistd.h> #include <time.h> #include <malloc.h> #define MIN_ALLOC (1) #define MAX_ALLOC (16368) int get_random_size() { return MIN_ALLOC + (rand() % (MAX_ALLOC - MIN_ALLOC)); } int main(int argc, char *argv[]) { long num; long i; int size; ...
C
// MyLib.c #include <stdio.h> void foobar (int i) { printf ("Printing from MyLib.so %d\n", i); printf ("This is revised.\n"); }
C
float Median_filter(int data,int measureNum,int *Filterdata) { unsigned int i = 0; unsigned int j = 0; int temp; unsigned int MAX_error_targe = 0; int MAX_error1; for(i=0;i<measureNum-1;i++) { Filterdata[i]=Filterdata[i+1]; } Filterdata[measureNum-1] = data; for(i = 0 ; i < measureNum-1 ; i++) ...
C
/* * Author: Xiru Zhu * Date: July 4 2016 * Updated: Jan 6 2017 * * Notes: * To initialize this system, * create a separate pthread and then run jdata_event_loop * This should initialize jdata system. */ #include "jdata_updated.h" char app_id[256]; //redis server connection parameters char *redis_serv_IP...
C
/* ======================================== * * Copyright YOUR COMPANY, THE YEAR * All Rights Reserved * UNPUBLISHED, LICENSED SOFTWARE. * * CONFIDENTIAL AND PROPRIETARY INFORMATION * WHICH IS THE PROPERTY OF your company. * * ======================================== */ #include "project.h" #includ...
C
#include <stdio.h> int main() { //input the number of rows and coloumns from the user int r,c; printf("Please enter the number of rows. \n"); scanf("%d",&r); printf("Please enter the number of coloumns. \n"); scanf("%d",&c); //the loop to print the hollow rectangle int i,j; for (i=1 ...
C
#ifdef USE_08_02 static float single_tax_standard[] = { 0,23350,56550,117950,256500,0xffffffff}; static float tax_fee[] = { 0,3502.50,12798.50,31832.50,81710.50 }; static float tax_percentage[] = { 0.15,0.28,0.31,0.36,0.396 }; float single_tax(float income) { int index; for (index = 0; single_tax_standard[index...
C
#ifndef __LINKED_LIST_H #define __LINKED_LIST_H #include<stdbool.h> #include<malloc.h> /* * 链表从下标0开始计算下标,但下标为0的结点是用于代表链表的头结点, * 其值并无实际意义, 故有效的链表结点下标大于等于1 */ typedef struct linked_list_node{ int val;//节点值 struct linked_list_node* next;//下一节点 }linked_list_node, *linked_list;// 定义链表的结点 /* *...
C
#include <xc.h> #include "Thermometer.h" #include "BitUtillities.h" #include "Delays.h" static void thermometer_write_byte(uchar val) { uchar byBitValue; for(uchar i = 0; i < 8; i++) { byBitValue = (val >> i) & 1; //shift the lowest bit ...
C
/* * $Id: port_fifo.c,v 1.4 2007/03/19 20:43:32 lizhijie Exp $ */ #include <cmnOsPort.h> /* always use this method to initiate cmn_fifo_t.*/ void cmn_fifo_init (int _maxSize, cmn_fifo_t **_ff) { cmn_fifo_t *ff = NULL; ff = cmn_malloc(sizeof(cmn_fifo_t) ); *_ff = ff; if(_maxSize < 0 ) { _maxSize = 1; } ff...
C
/************************************************ * filename: 2d_array.c * Exercise: Module 5, Exercise 2 * Name: Kelly Lougheed * Date Created: November 15, 2017 * * Description: Program that takes in five * integers, stores them and their squares in a * 2D array, and prints the contents of the array. ****************...
C
#include<stdio.h> #include<stdlib.h> struct node{ int data; struct node *next; }; static struct node * head=NULL; //Function to Insert At Beginning void insertAtStart(int data){ struct node *p; if(head==NULL){ p=(struct node *)malloc(sizeof(struct node *)); p->data=data; p->next=NULL; head=p; } else{ p=(struct node*)...
C
#include<errno.h> #include<stdio.h> #include <string.h> int main() { FILE* fd; fd=fopen("/etc/shadow","w"); if(fd==NULL) { printf("Failed=%d\n",errno); printf("%s\n",strerror(errno)); } else { fclose(fd); } return 0; }
C
#include"findshow.h" #include<stdio.h> #include<stdlib.h> #include"interface.h" #include"show.h" #include"otherfunc.h" #include"findfunc.h" #include"record.h" #include"gobal.h" #include<windows.h> #include"date.h" int find() { int findinput; scanf("%d",&findinput); switch (findinput) { case 1: ...
C
#ifndef RANDOMIZER_H #define RANDOMIZER_H #include "color_util.h" #define BUCKET_SIZE 100 #define WEIGHT 50 struct ColorBucketItem { Uint32 color; ColorBucketItem* next = nullptr; }; struct ColorBucket { int bucket_size; int weight; ColorBucketItem* head = nullptr; ColorBucketItem* tail = nullptr; ColorBuck...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> /*/ @type: Function - int main() @title: Seleao em Vetor I @author: Rafael Lima Coelho @since: 23-10-2019 @version: RLC.1.0.URI @description: Faa um programa que leia um vetor A[100]. No final, mostre todas as posies do vetor que armazenam um valor menor...
C
#include <cs50.h> #include <stdio.h> const int TOTAL = 3; int main (void) { int scores[TOTAL]; for (int i = 0; i < TOTAL; i++) { scores[i] = get_int("Score: "); } printf("Average: %f\n", average(TOTAL, scores)); } float average(int lenght, int array[]) { int sum = 0; for (int ...
C
#include "push_swap.h" void free_allocated(t_info *info) { t_args *list; t_args *tmp; list = info->a; while (list) { tmp = list; list = list->next; free(tmp); } list = info->b; while (list) { tmp = list; list = list->next; free(tmp); } free(info); } void check(char *line, t_info *info) { if (...
C
#include<stdio.h> struct student { char name[100]; int reg; int sub[20]; float avg; }; void average(struct student s[],int m,int n); void input(struct student s[],int m,int n); void output(struct student s[],int m,int n); void main() { struct student s[20]; int n,m,i,j=0; float p; printf("enter no. of students: "); sca...
C
#include <math.h> #include <stdlib.h> #include <stdio.h> #include <stdint.h> #include <mpi.h> void *pgm_read(const char *p) { FILE *file = fopen(p, "r"); if (!file) return 0; size_t w, h; void *buf = 0; if (fscanf(file, "P5\n%zu %zu\n255\n", &w, &h) < 2) goto err; if (!w || !h || w > SIZE_MAX/h) goto err...
C
#include <stdio.h> int main( int argc, char **argv ) { char scratchpad[1024]; while( fgets( scratchpad, 1024, stdin ) != NULL ) { fprintf( stdout, "I just got a line, and it's: %s", scratchpad ); if( scratchpad[0] == 'q' ) { break; } } fprintf( stdout, "p...
C
#include "pointTest.h" void testMultiplePointParameters() { Point point1 = {1, 2, 3}; assert(multiplePointParameters(&point1) == 6); Point point2 = {100, 10, 1000}; assert(multiplePointParameters(&point2) == 1000000); } void testCopyPoint() { Point point1 = {15, 24, 38}; Point *point2 = copyPo...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strcmp.c :+: :+: :+: ...
C
/******************************** * Snapshot.c * ********************************* * Mark Kennedy: kenned31 * * Jordan Ebel : ebel1 * ********************************* * Description * * * * .............. * ********************************/ #include <stdio.h> #include <stdlib.h> #include <pthread....
C
#include<stdio.h> int main() { int ans,n[30],key,num,i; scanf("%d",&num); printf("Enter the key:"); scanf("%d",&key); for(i=1;i<=num;i++) { scanf("%d",&n[i]); } i=key; ans=n[i]; printf("%d",ans); }
C
#include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <fcntl.h> int main() { FILE *f = fopen("redirect.txt", "w"); if (f == NULL) { printf("Error opening file!\n"); exit(1); } /* print some text */ const char *text = "A simple program output."; fprintf(f, "%s\n", text); fclose(f); }
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 "helper.h" static char msg[250]; void checkArguments(int argc, char **argv, args *givenArgs) { int opt,res; //initialize all values to zero givenArgs->bArg = 0; givenArgs->cArg = 0; givenArgs->nArg = 0; givenArgs->tArg = 0; givenArgs->vArg = 0; if (argc < 13) { sh...
C
#include <stdio.h> #include <unistd.h> #include <limits.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/msg.h> #include <string.h> #include <stdlib.h> #define SIZE 128 struct message { int type; char *content; }; int factorial(int n) { if (n == 0 || n == 1) { return 1; } ...
C
#include<stdio.h> #include<string.h> int main() { int i,j,l1,l2,x; char a[1000],b[1000]; while(gets(a)&&gets(b)) { l1=strlen(a); l2=strlen(b); if(l1<l2) x=l1; else x=l2; for(i=0;i<x;i++) { printf("%c%c\n",b[i],a[i]); } if(x==l2)...
C
#include <stdio.h> #include <stdlib.h> struct node *f = NULL; struct node *r = NULL; struct node { int data; struct node *next; }; void linkedlisttransversal(struct node *ptr) //for traversing { printf("traversing the queue\n"); while (ptr != NULL) { printf("element %d\n", ptr->data); ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "LinkedList.h" #include "SNAP.h" int hash_Id(int id) { return (id % 1009); } typedef struct SNAP * SNAP; SNAP new_SNAP(int s, char *n, char *a, char *p) { SNAP this = (SNAP) malloc(sizeof(struct SNAP)); this->StudentId = s; this->name = n; this...
C
/* Serial program for matrix-matrix product. * * VVD * name: Ioannis Chouliaras * AM : 2631 */ #include <stdio.h> #include <stdlib.h> #include <omp.h> #define N 1024 int A[N][N], B[N][N], C[N][N]; /* Functions */ int readmat(char *fname, int *mat, int n), writemat(char *fname, int *mat, int n); void parallel_w...
C
/* * Q. Allocate 2 kernel buffers of 1024 bytes each DEVBUFA, DEVBUFB. Implement a char driver that maps DEVBUFA to /dev/bufa and DEVBUFB to /dev/bufb. Driver shud provide support for read, write operations. * In this module we creating a driver having 2 buffers and supports 2 minor numbers * This approac...
C
#include "syscall.h" int f(int n) { if (n < 2) return n; return f(n-1) + f(n-2); } int g(int n){ if (n == 0) return 0; return g(n-1) + 1; } int main(void) { int x = g(44); Write(x == 44 ? "FIBOOKA\n" : "FIBOMAL\n", 8, CONSOLE_OUTPUT); Exit(0); // Not reached. }
C
#include <stdio.h> #include <stdlib.h> char *read(int len, char *file_name); void write(char *file_name, char *output); int main() { char *input = read(0, "message_file.txt"); printf("input = \n|%s|\n", input); // | is to handle trailing characters? write("output_file.txt", input); free(input); input = NU...
C
#include<stdio.h> int sum(int a,int b){ return a+b; } void greet(){ printf("Hello world my user good morning\n"); } int main(){ printf("The sum of 1 and 2 is %d\n",sum(1,2)); int(*fptr)(int,int); fptr=&sum; int d=(*fptr)(4,6); printf("The value of d is %d",d); return 0; }
C
#include "escape.h" #include <assert.h> #include <stdio.h> #include <string.h> #define likely(x) __builtin_expect((x),1) #define unlikely(x) __builtin_expect((x),0) /* * The following characters will not be escaped: * * -_.+!*'(),%#@?=;:/,+&$ alphanum * * Note that this character set is the additio...
C
#include<stdio.h> int main() { int input,sum=0,rem=0; printf("enter the input:"); scanf("%d",&input); while(input!=0) { rem=input%10; sum=sum+rem; input=input/10; } printf("sum of input is %d",sum); return 0; }
C
#include<stdio.h> #include<stdlib.h> #include<stdbool.h> //-------------declearing the node -------------------- typedef struct node { int data; struct node*left,*right; }node; //function to insert the elements---------------------------- void insert(node*root,int x) { node*newnode=(node*)malloc(sizeof(node));...
C
#include <stdio.h> int main (){ int a; printf("ingrese un numero entero\n"); scanf("%d", &a); printf("el numero %d vale:\n", a); printf("en decimal: %d\n", a); //%d lee en decimal printf("en hexadecimal: %x\n", a); //%x lee en hexadecimal printf("en octal: %o\n", a); //%o lee en octal re...
C
#include "config.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <getopt.h> #include "fastphoto.h" #include "memory.h" #include "resize.h" static void version (void) { printf ("FastPhoto " VERSION "\n"); } static void usage (void) { printf ("Usage: fastphoto [options] infile [outfil...
C
#include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <sys/stat.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> #include <string.h> struct shared_struct { int x, y; char wtf; }; int main(){ const char pathname[] = "home/partyk/Downloads"; int proj =...
C
#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { if (argc != 2) { printf("Usage: ./recover image\n"); return 1; } FILE *file = fopen(argv[1], "r"); if (!file) { printf("the file could no be open\n"); return 1; } unsigned char bu...
C
#include <stdio.h> #include <stdint.h> #include <stdlib.h> void print_arch_data() { system("lscpu | awk '/Archi*/{print $NR $NF}'"); printf("Size of char: %d\n",sizeof(char)); printf("Size of int: %d\n",sizeof(int)); printf("Size of float: %d\n",sizeof(float)); printf("Size of double: %d\n",sizeof(double)); pr...
C
#include <unistd.h> #include <stdio.h> #include <sys/socket.h> #include <sys/types.h> #include <stdlib.h> #include <netinet/in.h> #include <string.h> #include <time.h> #include <arpa/inet.h> #define PORT 8080 #define BUFSIZE 1024 #define NUMER_KLIENTA 8 //ilosc cyfr numeru klienta int check_user(char *, double *,s...
C
#include <stdio.h> #define MAXLINE 1000 /* maximum input line size */ /* Write a program to remove trailing blanks and tabs from each line of input, and to delete entirely blank lines*/ int main(){ //read each line (check for input) int c, pb, pt, pn; // pb = pastBlank, pt = pastTab, pn = pastNewLine pb = pt ...
C
#include<stdio.h> #include<stdlib.h> struct player{ int tall; int num; }; int compare(const void *a,const void *b); int main() { int t; scanf("%d",&t); int i; for(i=0;i<t;i++){ int n,m; scanf("%d %d",&n,&m); struct player p[n]; int q[m]; int j; for(j=0;j<n;j++){ scanf("%d",&p[j].tall); p[...
C
#include"game.h" #include<stdio.h> #include<stdlib.h> #include<time.h> #define _CRT_SECURE_NO_WARNINGS 1 void InitBoard(int board[ROW][COL], int row, int col) { int i =0; int j = 0; for(i=0; i<row; i++) { for(j=0; j<col; j++) { board[i][j] = ' '; } } } void DisplayBoard(char board[ROW][COL], int row, int ...
C
#include<stdio.h> #include<math.h> void main() { int i=0,j=0,temp,sum,r,a[50]; long long int n; printf("ENTER ANY DECIMAL NUMBER:\n"); scanf("%lld",&n); printf("\nOCTAL NUMBER:\n"); while(n!=0) { r=n%8; a[j]=r; n=n/8; i++; j++; } temp=i; for(j=i-1;j>=0;j--) { printf("%d",a[j...
C
#include<stdio.h> #include<conio.h> sum(int); void main() { int n=0,f=0; printf("Enter the number : "); scanf("%d",&n); f=sum(n); printf("Sum = %d",f); } sum(int n) { if(n==1) return 1; else return (n+sum(n-1)); }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* parse_rooms.c :+: :+: :+: ...
C
#include <stdio.h> int main(void) { float a,b,x; printf("Informe os valores de a e b: "); scanf("%f%f", &a, &b); x=-b/a; printf("Resultado da equação de primeiro grau: %.2f\n", x); return 0; }
C
#pragma warning(disable:4996) #ifndef HUFFMANCODE_H_ #define HUFFMANCODE_H_ #include <stdio.h> #include <stdlib.h> #include <string.h> #define OK 1 #define ERROR 0 #define TRUE 1 #define FALSE 0 typedef int Status; typedef struct { unsigned long weight; unsigned int parent, lchild, rchild; }HTN...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #define MAX 99 int nhapmang(int *a, int n) { int number; char c; scanf("%d%c", &number, &c); if((int)c==32) { a[n]=number; nhapmang(a, n+1); } else if((int)c==10) { a[n]=number; a=(int*)realloc(a, sizeof(int)*(n+1)); return n+1; } else return 0; } int ...
C
#ifndef _HTTPD_SERVER_UPLOAD_H_ #define _HTTPD_SERVER_UPLOAD_H_ #include <esp_err.h> #include <esp_http_server.h> #ifdef __cplusplus extern "C" { #endif #define UPLOAD_BUF_LEN 2048 #define BOUNDARY_LEN 70 //as described in RFC1341 /** * @brief Find boundary string in request header * * @req The request bei...
C
#ifndef PROTOCOLE_H #define PROTOCOLE_H // Type de requete #define CONNECT 1 #define DECONNECT 2 #define TIR 3 #define SOUSMARIN 4 #define BATEAU_COULE 5 // Sens de deplacement des bateaux #define DROITE 1 #define GAUCHE 2 #define HAUT 3 #define BAS 4 struct Bateau { int type; i...
C
#include <stdio.h> #include <conio.h> #include <string.h> #define max_stack 10 struct stack //Mendefinisikan stack dengan menggunakan struct { int top;//pendeklarasian variable untuk dipanggil pada fungsi void int data [15];//Membuat variable array sebagai implementasi stack }; struct stack tumpuk; void push...