language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include "libmx.h" char *mx_file_to_str(const char *file) { int read_file = open(file, O_RDONLY); if(read_file < 0) return NULL; //чтение - запись int i = 0; int size_file = 0; char buffer[1]; while(read(read_file, buffer, 1)) { size_file++; } if (close(read_file) < 0) return NULL; cha...
C
#include <stdio.h> void fill_numbers(int n, int* numbers); void move_numbers(int n, int* numbers); void delete_numbers(int n, int* numbers); int main() { int n = 0; scanf("%d", &n); int numbers[128] = {0}; fill_numbers(n, numbers); while(numbers[2] != 0) { delete_numbers(n, numbers); ...
C
/* * File: ast.h * Project: C--_Compiler * File Created: 2020-02-22 * Author: Zangwei Zheng (zzw@smail.nju.edu.cn) * ----- * Copyright 2020 NJU, Zangwei Zheng */ #ifndef _AST_H #define _AST_H typedef struct abstract_syntax_tree{ char name[64]; char original_val[128]; char val[128]; int lineno; ...
C
/* ** move.c for tekadv in /home/maxence.fourrier/Documents/Project_C/tekadv/src ** ** Made by maxence.fourrier ** Login <maxence.fourrier@epitech.eu> ** ** Started on Mon Sep 11 13:44:10 2017 maxence.fourrier ** Last update Sun Oct 8 11:05:30 2017 maxence.fourrier */ #include "explo.h" sfVector2f get_dir_with_...
C
#include <stdio.h> #include <stdint.h> #include "qrcode.h" void qrcode_print(const QRCode *qrcode) { printf("\x1b[1;47m "); for (uint8_t x = 0; x < qrcode->size; x++) printf(" "); printf(" \x1b[0m\n"); for (uint8_t y = 0; y < qrcode->size; y++) { printf("\x1b[1;47m \x1b[40m"); ...
C
#include <stdio.h> // printf #include <stdlib.h> // malloc /** * Note: The returned array must be malloced, assume caller calls free(). */ /* 本题难点在对函数参数的理解上 * 建议nums加const修饰,表示入参不可修改 * returnSize这个应该是出参 */ int* twoSum(int* nums, int numsSize, int target, int* returnSize){ for(int i=0;i<numsSize-...
C
/** * \file gpio_hal.h * \copyright Copyright (c) 2017 Verizon. All rights reserved. * \brief Hardware abstraction layer for GPIO pins * \details This header defines a platform independent API to read and write * GPIO pins. It also offers a utility routine to control the power to the GPIO * submodule. GPIO interr...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* print_path.c :+: :+: :+: ...
C
#include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <time.h> void *my_entry_function(void *param) { int* value = (int*) param; while (--(*value)) /* NOP */ ; printf("Finished decrementing x\n"); return NULL; } int main() { srand(time(NULL)); int x = rand() % (1000 * 1000); //...
C
#include<stdio.h> int main() { int a[5], i, j, temp; printf("Enter 5 Element: \n"); }
C
#include <stdio.h> #include <stdlib.h> struct student { int number;//学号 char name[1024];//姓名 int dailyScore;//平时成绩 int generalSocre;//实验成绩 int finalSocre;//期末成绩 int score;//总成绩 int place;//名词 }; void main() { struct student stu[0]={2017000001 "姚期智" 90 85 98 0 0}; struct student stu[1]={2017000002 ...
C
/* ** EPITECH PROJECT, 2018 ** nf.sh ** File description: ** nf */ #include <unistd.h> #include <stdlib.h> int get_modulo(int len_nb) { int modulo = 1; for (int i = 0; i < len_nb; i++) modulo *= 10; return (modulo); } int my_power(int index, int base) { int value = 1; for (int i = 0; i ...
C
/* * COAL Video Lecture: 45 * Programmer: Arif Butt * ex1.c: A sample C program that calls an assembly function from proc1.o * compile: gcc -c ex1.c * link: gcc ex1.o proc1.o -o myexe * usage: ./myexe */ #include <stdio.h> #include <stdlib.h> extern long maxofthree(long, long, long); int main() { p...
C
#include <stdio.h> int main() { long long sumOfSquares = 0; long long squareOfSums = 0; int i; for (i = 1; i <= 100; i++) { sumOfSquares += i*i; squareOfSums += i; } squareOfSums *= squareOfSums; squareOfSums -= sumOfSquares; printf("%lld\n", squareOfSums); return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <windows.h> int bus,kelas,i,n; //Deklarasi untuk Outpus Pesan char Nama[100][100],Jenis[100][100],Bus[100][100],Jalur[100][100]; int NoKursi[100],Nik[100]; //Deklarasi Login/Registrasi struct akun{ char nama[100], username[100], password[100]; ...
C
#include <stdio.h> #include <stdlib.h> double convert_age(int years) { double cf = 3.156e7; return (cf * years); } int main(int argc, char *argv[]) { if (argc != 2) { printf("Hey, pass an integer as argument.\n"); return 1; } int years = atoi(argv[1]); printf("Your age in secon...
C
/*--------------------------------------------------------------------------------------- * FileName:Knapsack.c * author:doodlesomething@163.com * date:1-5-2014 * version:1.0 * description:0-1背包问题 -------------------------------------------------------------------------------------------*/ #include <stdio.h> in...
C
/* * CS 261 Assignment 5 * Name: Christian Roccanova * Date: 8/5/2017 */ #include "dynamicArray.h" #include "task.h" #include <stdlib.h> #include <string.h> #include <stdio.h> /** * Loads into heap a list from a file with lines formatted like * "priority, name". * @param heap * @param file *...
C
/****************************************************************************************************/ /* @FileName : spi.c */ /* @Author : zhengbaiqiu */ /* @Version : v1.0 */ /* @Date : 2019.11.12 */ /******************************************...
C
#include <stdio.h> void lervetor(int vet[],int n){ for(int i=0;i<n;i++){ scanf("%d",&vet[i]); } } void imprimevetor(int vet[],int n){ for(int i=0;i<n;i++){ printf("%d ",vet[i]); } printf("\n"); } void somavet(int v1[], int v2[], int n){ int v3[n]; for(int i=0;i<n;i++){ ...
C
# include <stdlib.h> # include <stdio.h> # include <math.h> # include "cube_integrals.h" int main ( ); void test01 ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: M...
C
#include <stdio.h> #include <locale.h> int main() { setlocale(0,"Russian"); int A,k,l,m; printf("Введите трехзначное число: "); scanf("%d", &A); printf("Цифры данного числа образуют возрастающую или убывающую последовательность\n"); if (A>99 && A<1000){ k=A/100; l=A%100; m=l%10; ...
C
#include<stdio.h> #include<stdlib.h> #include<time.h> int** maze; void print_maze(void) { int i, j, k = 0; int row, col; int view_i, view_j, d, chk_cnt; int move[4][2] = { {-2,0},{2,0},{0,-2},{0,2} };//¿ struct room { int r; int c; }*unknown; struct candidate_room { int r; int c; int d; }*candida...
C
/* ********************************************************************************************************* * * 模块名称 : ADS1256 驱动模块(8通道带PGA的24位ADC) * 文件名称 : bsp_ads1256.h * * Copyright (C), 2013-2014, 安富莱电子 www.armfly.com * ******************************************************************************...
C
/** * common.h * * Some commonly used defines and configuration options. * Mostly flags to toggle debug code or to tweak the * search algorithm. * */ #ifndef _COMMON_H_ #define _COMMON_H_ /******************************************************************************************* * Specifics for Windows and *...
C
#include <bmp_header.h> #include <carrier.h> #include <encrypt.h> #include <hidden_file.h> #include <jobs.h> #include <lsb.h> #include <payload.h> #include <stdio.h> #include <testing_suite.h> #include <string.h> #include <unistd.h> #include <arpa/inet.h> #include <rc4.h> void lsb1_insert_0(); void lsb4_insert_1(); vo...
C
#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <json.h> #include <nemoattr.h> #include "util.h" #define BUF_SIZE 100 static bool _json_find(struct json_object *obj, const char *names, struct nemoattr *attr) { bool ret = false; char *_names = strdup(names); char *...
C
/** * @file integrate_orbit.c * @brief Functions to perform the integration of the galaxy orbit */ #include "allvars.h" #include "readparameterfile.h" #include "proto.h" /** Minimum allowed subhalo mass (in code units). */ #define MINSUBMASS 1.0e-7 /** Minimum value allowed for code units. */ #define MINUNITS 1.0e...
C
#include "btree.h" #include <stdio.h> #include <stdlib.h> #include <string.h> void setup(btree_tree *tmp) { uint32_t data_idx; /* Testing with full root node */ btree_insert(tmp, 'F', &data_idx); btree_insert(tmp, 'Q', &data_idx); btree_insert(tmp, 'Z', &data_idx); btree_insert(tmp, 'E', &data_idx); btree_inse...
C
# include <stdio.h> int main(){ char str[1000], Stack[10]; int i, StackN = 0, bracket = 0, ErrorCheck = 0; gets(str); for (i = 0 ; str[i] != '\0' ; i++){ if (str[i] == '[' || str[i] == '{' || str[i] == '(' || str[i] == ')' || str[i] == '}' || str[i] == ']'){ bracket++; } if (StackN == 0){ ...
C
/* ,* Copyright © 2013, Malcolm Sparks <malcolm@congreve.com>. All Rights Reserved. ,* ,* A program to convert USB firing events from the Dream Cheeky 'Big Red Button' to MQTT events. ,*/ #include <fcntl.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #define LID_CLOSED 21 #define BUTTON_PRESSED 22 #def...
C
#include<stdio.h> int main() { int n,f1=0,i,sum=0,f2=1; scanf("%d",&n); for(i=2;i<=n;i++) { sum=f1+f2; f1=f2; f2=sum; } printf("%d",f2); }
C
#include<stdio.h> #include<string.h> main() { int a=-4%3; printf("%d",a); //int a; //scanf("%2d",&a); //printf("%4d",a); //char s[]="this is garvit"; //char *c=strstr(s,"is"); //printf("%s",c); //int a=getch(); //printf("U pressed %c",a); //int a=sizeof(int); //printf(...
C
/* * Date: 2018-11-08 * * Description: * Given a binary array, find the maximum number zeros in an array with one flip * of a subarray allowed. A flip operation switches all 0s to 1s and 1s to 0s. * * Approach: * - Count number of 0s in original array, call it orig_zeros. * - Consider all subarrays and find su...
C
/* ==================================================================== * This file is part of Polylogarithm. * * Polylogarithm is licenced under the MIT License. * ==================================================================== */ #pragma once #ifdef __cplusplus extern "C" { #endif /** Clausen function wit...
C
/* get_passwd.c * part of watchlist_monitor */ #include "watchlist_monitor.h" int get_passwd(char * password) { struct termios oflags, nflags; // disable echo tcgetattr(fileno(stdin), &oflags); nflags = oflags; nflags.c_lflag &= ~ECHO; nflags.c_lflag |= ECHONL; if (tcsetattr(fileno(stdin) ,TCSANOW, &nf...
C
#include <stdio.h> #include <string.h> int main() { char a[100],b[100],c[100]; int i; printf("\nEnter any thing"); gets(a); printf("\nEnter any thing"); gets(b); for(i=0;i<strlen(a);i++) { c[i]=a[i]; } for(i=0;i<strlen(b);i++) { c[i+s...
C
#include <stdio.h> int main() { printTemperatureChange(); return 0; } /** * print C = (5/9)(F-32) ϶Ⱥ϶ȶ */ int printTemperatureChange(){ int fahr, celsius; int lower, upper, step; lower = 0;//¶ȵ upper = 300;//¶ȵ step = 20;// fahr = lower; while (fahr <= upper){ celsius = 5 * (fahr - 32) / 9; printf("%...
C
/* * ascensore.c * * Created on: 23 dic 2016 * Author: Daniele */ #include <stdlib.h> #include <conio.h> #include <dos.h> #include <stdio.h> void main(void) { int pI, v=0, row=25, pF; clrscr(); //ciclo che disegna quadro ascensore for (v=0;v<10;v++) { ...
C
#ifndef MERGESORT_H #define MERGESORT_H // Includes #include <assert.h> #include <stdio.h> #include <stdlib.h> // Structs typedef struct node{ int data; struct node* next; } Node; // Function declarations // @description: merges two sorted lists in ascending order and returns a pointer to the head...
C
// Write the following parameterized macros. // MEDIAN(x,y,z) - Finds the median of x, y, and z #include <stdio.h> #define MAX(x,y) ((x>y) ? (x):(y) ) #define MIN(x,y) ((x<y) ? (x):(y) ) #define MEDIAN(x,y,z) MIN(MIN(MAX(x,y),MAX(y,z)),MAX(z,x)) int main (void) { int x, y, z; printf("Enter three integer: ");...
C
#include<stdio.h> #include<libvirt/libvirt.h> static int USAGE_THRESHOLD = 60; struct DomainsList{ virDomainPtr *domains; int num_domains; }list; struct DomainStats{ virDomainPtr domain; double usage; long unsigned vcpu_time; int vcpu_id; }; int num_cpus=0; virDomainPtr *dom; void pinCpus(virDomainPtr *doma...
C
/* Program to copy n chars of first string to end of another String*/ #include <stdio.h> #include <stdlib.h> #include <string.h> void main() { int no; char *str1,*str2; void xstrncat(char* str1,char* str2,int no); str1=(char*)malloc(1000); str2=(char*)malloc(1000); // Get the Strings from the user printf("\...
C
#ifndef __LISTA_H #define __LISTA_H /*----------------------------------------------------------------- TAD Lista ------------------------------------------------------------------- */ typedef int TipoL; typedef struct ListaNodo { TipoL info; struct ListaNodo *ant, *sig; } ListaNodo, *pListaN...
C
/** Extremely simple singly-linked list of ints. Everything is IN the list, no external pointers. */ #ifndef INLIST_H #define INLIST_H #include <stdbool.h> #include <stdlib.h> struct inlist_item { int data; struct inlist_item* next; }; struct inlist { struct inlist_item* head; struct inlist_item...
C
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #define flags ((volatile char*)(0x1000)) void inline sieve(void) { int i, prime, kv, count, iter, size; size=600; for (iter = 1;iter < 10;iter ++) { count = 0; for (i = 0; i <= size; i++) { flags[i] = 1; } ...
C
#include<stdio.h> #include"stack.h" #include"dirlist.h" #define V 8 link_t adj[V]; int visited[V]={0}; void visit(int vertex) { printf("%d ",vertex); } void Push(link_t head) { if(head==NULL) return; Push(Next(head)); if(visited[Item(head)]==0) stackPush(Item(head)); } void traverse(int k,void (*visit)(i...
C
/* run.config OPT: -wp-no-print -wp-rte -no-warn-signed-overflow */ /* run.config_qualif OPT: -then -wp-rte -no-warn-signed-overflow -wp */ // note: exo hors vérification de l'absence de débordements /* ************/ /* Solution de TP donné par Julien à L'IFIPS */ /* ************/ /* Un sous-tableau [b] d'un ...
C
#include<stdio.h> #include<sys/time.h> #include<math.h> #define max 179424673 double getTime(int); main() { double start,stop,elapsedTime; int n; long int count=0,cnt=0,i,j,k; static long int prime[max],p=2; start=getTime(-6); printf("%lf\n",start); prime[0]=prime[1]=1; for...
C
/** * This file is part of the FabricDB library * * Author: Mark Wardle <mark@themarkside.com> * Created: March 29, 2015 * Updated: March 29, 2015 */ #include <stdio.h> #include <assert.h> #ifndef _FABRIC_TEST_ALL__ #include "Fabric.c" #endif typedef struct EMapDummy { uint32_t id; uint32_t value; } EMa...
C
#include <stdio.h> #include <stdlib.h> #include <assert.h> struct elt { struct elt *next; int value; }; typedef struct elt *Stack; #define STACK_EMPTY (0) void stackPush(Stack *s, int value) { struct elt *e; e = malloc(sizeof(struct elt)); assert(e); e->value = value; e->next = *s; ...
C
#ifndef _BMP_H #define _BMP_H /** * Return reversed string. * * Function returns a pointer to the reversed string, which has been created from the input parameter. * If the input string is NULL or memory could not be allocated, function returns NULL. * * @param text - input string * @return reversed representat...
C
/************************************************************************** *************************************************************************** W E G A - Quelle (C) ZFT/KEAW Abt. Basissoftware - 1988 Programm: format.c Bearbeiter : P. Hoge Datum : 30.11.89 Version : 1.6 *************************...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char x[101],y[101]; int a,b; scanf("%s %s",x,y); a=strlen(x); b=strlen(y); if(a>b) { printf("%s",x); } else if(a==b) { printf("%s",x); } else { printf("%s",y); } r...
C
#define print(a) printf("The value of " #a " is %d\n", a); #include <stdio.h> int main() { int num = 7; print(num) return 0; }
C
#include <stdio.h> int main( void ) { int integer1; /* first number to be input by user */ int integer2; /* second number to be input by user */ int result; /* variable in which result will be stored */ printf( "Enter first integer:\n" ); /* prompt */ scanf( "%d", &integer1 ); /* read an integer *...
C
#include <stdio.h> /** * main - entry point * Return: 0 */ int main(void) { int x; char y; for (x = 0; x < 16; x++) { if (x < 10) putchar(x + 48); else { y = 97 + x % 10; putchar(y); } } putchar('\n'); return (0); }
C
#include <stdio.h> //int main() { // //! showMemory(cursors=[matrix[0], matrix[1]], start=65520) // //! matrix = showArray2D(matrix, rowCursors=[line], colCursors=[col]) // int matrix[2][3]; // int line, col; // for(line = 0; line < 2; line++){ // for(col = 0; col < 3; col++){ // scanf(...
C
/*2) Elaborar um programa que determine a potncia de um nmero. O usurio informa a base e o expoente e o programa informa o resultado da base elevada ao expoente. No usar funes prontas do C para fazer o clculo da potncia. */ #include <stdio.h> int main(void) { int num,pote,i,produto=1; printf("Informe o valor...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* printf.c :+: :+: :+: ...
C
/*3) Faca um programa para calcular a quantidade necessria de latas de tinta para pintar uma parede com X metros de largura por H metros de altura. Tambm informada a altura e largura da porta e das janelas e a quantidade de janelas. As janelas possuem o mesmo tamanho. O usurio informa o consumo de tinta por metro quad...
C
#include "../inc/libmx.h" int mx_count_words(const char *str, char c) { int count = 0; int count_s = 0; if(str == NULL) { return -1; } for(int i = 0; i < mx_strlen(str); i++) { if(str[i] == c) { count_s = 0; } else if(count_s == 0) { count++; count_s = 1; } } return count; }
C
#include<stdio.h> void main() { char **arr; char* s[50], temp[50]; int n, i, j, l; printf("enter the number of strings\n"); scanf("%d", &n); arr = (char **)malloc(n * sizeof(char *)); printf("enter %d strings\n", n); for (i = 0; i < n; i++) { scanf("\n%[^\n]s", s); l = strlen(s) + 1; arr[i] = (char *)ma...
C
#include <stdio.h> main() { int c,i,j; int nc[26]; for(i=0;i<26;i++) nc[i] = 0; while((c = getchar()) != EOF){ if('a' <= c && c <= 'z'){ nc[c - 'a']++; } } for(i=0;i<26;i++){ printf("%c:\t",'a'+ i); for(j=0;j<nc[i];j++){ prin...
C
#include <stdlib.h> #include "list.h" #include "dbg.h" List* list_create() { return calloc(1, sizeof(List)); } void list_destroy(List* list) { LIST_FOREACH(list, first, next, cur){ if(cur->prev) { free(cur->prev); } } free(list->last); free(list); } void list_...
C
#include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <sys/time.h> #include <sys/select.h> #include <fcntl.h> #include <ctype.h> #define MAX_BUFFER_LENGTH 100 #define B...
C
/** * @file SPI_Controller.h * @author Group 1: Christian Despatie, Lena Hsieh, Surbhi Gupta & Kishen Shakespeare * @version 1.0 * * @brief Functions to initialize SPI configuration * */ #ifndef __SPI_CONTROLLER_H #define __SPI_CONTROLLER_H #include <stm32f4xx.h> #include <stm32f4xx_spi.h> /** * @brie...
C
//biblioteca.c #include <stdio.h> #include <stdlib.h> int numeroVezesC(char *linha1,char *linha2, int tam1, int tam2){ int cont=0,i=0,j=0, n=0; char aux[tam1]; // string auxiliar para fazer comparações while (j != tam2){ n++; while (i!=tam1){ aux[i]=linha2[j]; j++; i++; } j=n; //para garantir que...
C
static WinBuf * new_WinBuf(int hi, int wi) { WinBuf *wb; int size, y, x; char *mem, *chars, *colors, *attrs; size = sizeof(WinBuf) + hi * wi * 3 + sizeof(char *) * hi * 3; mem = (char *) calloc(size, 1); wb = (WinBuf *) mem; wb->hi = hi; wb->wi = wi; chars = (char *) (mem + sizeof(WinBuf...
C
Status ListDelete(SqList *L, int i, ElemType *e){ int k; if (L -> length == 0) { return ERROR; } if (i<1 || i> L->length) { return ERROR; } *e = L ->data[i-1] if (i< L->length) { for ( k = i; k < L->length; k++) { L -> data[k-1] = L-> data[k]; } } L->length--; return OK; }
C
/* Author: James Ridey 44805632 * james.ridey@students.mq.edu.au * Creation Date: 10-08-2016 * Last Modified: Mon 15 Aug 2016 05:59:06 PM AEST */ #include <stdlib.h> #include "file.h" Data* read_file(FILE* file, Array* array) { short tmp; if(!fread(&tmp, sizeof(short), 1, file)) return NULL; Data* d...
C
/* 十进制-二进制 函数递归实现*/ /* 十进制变二进制,如果是奇数最后以为必定是1,偶数必定是0*/ #include<stdio.h> void ten_two( unsigned long shi ); int main( void ) { unsigned long shi; printf( "请输入一个十进制的数( q to quit ):" ); while( scanf( "%lu", &shi ) == 1 ){//scanf读入一个数 printf( "转换成二进制数是:"); ten_two( shi );//调用函数进行运算 printf( "\n" ); printf( "请输入一个...
C
#include<stdio.h> main() { char s[20],d[20],i; printf("enter string\n"); scanf("%s",s); printf("before...%s",s); for(i=0;s[i];i++) d[i]=s[i]; d[i]=s[i]; printf("after....%s\n",d); }
C
int f(int n) { if (n==0) { cout <<n<<endl; return 0; } if (n<0) { cout <<'-'; return f(-n); } cout <<n%10; if (n/10!=0) return f(n/10); else cout<<endl; } int main() { int n; while(cin>>n) { while (n%10==0&&n!=0) { n/=10; } f(n); } return 0; }
C
int strcmp_ci(char* str1, char* str2) { int str1_size = f_strlen(str1); int str2_size = f_strlen(str2); while( (*str1 != '\n') && (*str1 != '\0') && (*str2 != '\n') && (*str2 != '\0')) { if( (*str1 >= 'A' && *str1 <= 'Z')) { if(!(*str2 >= 'A' && *str2 <= 'Z')) *str2 = *str2 - 32 ; } else if(*s...
C
/** * @file I2C1.c * @author Seb Madgwick * @brief I2C master library for dsPIC33EP. * * Communication may be achieved using either blocking functions or by composing * and then executing an interrupt serviced script. * * I2C1_INTERRUPT_PRIORITY may be changed as required by the application. */ //------------...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> #define bool int #define false 0 #define true 1 #define MAX 64 int n, sum, max; int a[MAX]; int v[MAX]; int origin; bool f; int cmp(const void *a, const void *b) { return -(*(int *)a - *(int *)b); } void def(int d, int len, int u) { int i; if(f) retu...
C
#include "holberton.h" /** * factorial- Short description, single line * @n: Description of parameter n * Return: 0 */ int factorial(int n) { if (n >= 0 && n <= 1) { return (1); } else if (n < 0) { return (-1); } else { return (n * factorial(n - 1)); } }
C
#include <stdio.h> #include <string.h> int main(void) { char name[100], first_name[100]; gets(name); for (int i = 0, n = strlen(name); i < n; i++) { if (name[i] == ' ') { first_name[i] = '\0'; break; } first_name[i] = name[i]; } printf("%s...
C
#include <stdio.h> #include <stdlib.h> int main() { int n, p, d, i; while(1){ printf("Digite o tamanho do seu cafufa: \n"); scanf("%d", &n); printf("Digite os numeros cafufados: \n"); scanf("%d %d", &p, &d); if(!n && !p && !d) return 0; for(i = 1; i <= n; i++){ if(i%p==0 || i%d==0 || i%10==p || i%1...
C
#include <std.h> inherit DAEMON; int check_activity(string str); void move_rubble(string ext, object tp); int cmd_dig(string str){ string *buried_exits; object ob; if(!str){ tell_object(TP, "You dig a hole in the ground."); tell_room(ETP, TPQCN+" digs a hole in the ground.", TP); return 1; } ...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/wait.h> #include <sys/time.h> #include <pthread.h> #include <fcntl.h> #define BUF_SIZE 200000010 char *cmd; //argv int **arr; int m = 0; int n = 0; int **arr2; int *part; //파트 분배 int gen = 0; //세대 수 int *thread_n; pthread_t *...
C
#include<stdio.h> #include<conio.h> long int factorial(int n); void main(){ int n; long int fact; clrscr(); printf("Enter a number: "); scanf("%d", &n); fact = factorial(n); printf("%d! = %ld", n, fact); getch(); } long int factorial(int n){ if(n == 0) return 1; else return n * factorial(n - 1); }
C
#include "resources.h" #include <math.h> #include <ncurses.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #define ENOUGH 64 #define DELAY 15000 #define WIDTH getmaxx(stdscr) #define HEIGHT getmaxy(stdscr) int main() { char sheepstr[ENOUGH]; // Setup ncurses initscr(); curs_set(false...
C
// wap to input marks of students in 3 subjects --> eng, maths, science. // calculate the total marks, percentage and grade // print --> total marls, percentage and grade // grade --> percentage --> greater than 80 --> A grade // greater than 60 and less than 80 --> B grade // greater than 50 and less t...
C
#include <stdio.h> #include <stdlib.h> int main () { int N, S, i=1; printf("Saisir le nombre N : "); scanf("%d",&N); S=0; for(i=0;i<=N;i++) S=S+i; printf("La somme S = %d\n",S); return 0; }
C
int main(){ int a, b, x; printf("Digite o valor para 'a':"); scanf("%d", &a); b = 3; x = a+b; printf("a soma de %d mais 3 é: %d", a, x); return 0; }
C
#include <stdio.h> #include <stdbool.h> #include <stdlib.h> #include "dlist.h" #include "utils.h" dnode* dnode_create(int data, dnode* prev, dnode* next){ dnode*p = (dnode*)malloc(sizeof(dnode)); p->data= data; p->prev = prev; p->next = next; return p; } dlist* dlist_create(void){ dlist *p= (d...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "../headers/lib.h" cmd create_command(char *name, char **args){ cmd c = malloc(sizeof(command)); if(c == NULL) return NULL; c->name = strdup(name); c->args = args; int nbArgs = 0; while(*(args+nbArgs)!=NULL){ nbArgs++; ...
C
#include <fcntl.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <string.h> void touch_copied_byte(char * other_buff) { if (other_buff == NULL) { printf("Other buff is null!"); return; } //In the testcase, don't process this. We should see the label as canonical /...
C
/* 给出一个大于或等于3的正整数,判断它是不是一个素数 */ #include <stdio.h> #include <math.h> main() { int n, i, judge; judge = 1; scanf("%d", &n); for (i = 2; i < sqrt(n) + 1; ++i) { if (n % i) continue; judge = 0; break; } if (judge) printf("%d is a prime number\n", n); ...
C
#include <stdio.h> #include <stdlib.h> int a1; int a2; int a3; int result; int main() { printf("Enter port value\n"); scanf("%d", &a1); printf("Enter RPM\n"); scanf("%d", &a2); printf("Enter line frequency (60/50) \n"); scanf("%d", &a3); result = calculatevalue(a1,a2,a3); printf("%d\n", ...
C
#include<stdio.h> #include<unistd.h> #include<string.h> #include<sys/wait.h> int main() { pid_t ret; int status_shell; int cmd_exec; char common[10]; printf("Enter your command:"); scanf("%s", common); ret=fork(); if(ret<0) { perror("fork"); exit(1); } if(ret==0) { cmd_exec=execlp(common,common); if(cmd_exec<0) { p...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <sys/stat.h> #include <sys/types.h> #include <string.h> #include <pthread.h> /**********************全局变量定义区*****************/ int fd_fifo; //创建有名管道,用于向mplayer发送命令 int fd_pipe[2]; //创建无名管道,用于从mplaye...
C
#include <stdio.h> #include <stdlib.h> #include "my_binary_search_tree.h" typedef struct TreeNode { ElementType e; SearchTree left; SearchTree right; } aNode; /** * 置空 */ SearchTree make_empty(SearchTree ST) { if (ST) { make_empty(ST->left); make_empty(ST->right); free(ST...
C
/* M1 Informatique IM2AG-UGA Tp SipHash: Borne Jonathan - Duverney Thomas Coll_search_stats: Description: Mesure du nombre d'itérations de la fonction brentrec néccessaires au calcul d'une collision de la fonction siphash_fix_32. Calcule une collision pour 1000 clés différentes et écrit dans le fichier Collis...
C
#include "clar_libgit2.h" #include "config_backend.h" #include "config.h" #include "path.h" static git_config *cfg; void test_config_readonly__initialize(void) { cl_git_pass(git_config_new(&cfg)); } void test_config_readonly__cleanup(void) { git_config_free(cfg); cfg = NULL; } void test_config_readonly__writing_...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> void func(char **a, int n) { int i, j, count, k, l,s1,s2, res, temp=0; int **b=malloc(n*sizeof(int*)); for (i=0;i<n;i++) b[i]=calloc(n,sizeof(int)); for(i=0;i<n;i++){ s1=strlen(a[i]); for(j=0;j<n;j++){ if(j==i) continue; s2=strlen(a[j...
C
#include <stdio.h> #include "libft.h" #include "ft_stack.h" int ft_greater_markup(t_stack *a, int i); int ft_find_greater_markup(t_stack *a); void ft_greater_markup_marks(t_stack *a, int markup_head_i); void ft_greater_markup_test(t_stack *a) { int i; i = a->top + 1; while (--i >= 0) { ft_putstr("Head "); ...
C
/* x14-processes/valentine.c */ /* Copyright (c) 2020 J. M. Spivey */ #include "hardware.h" #include "microbian.h" #include "lib.h" /* heart -- filled-in heart image */ const unsigned heart[] = IMAGE(0,1,0,1,0, 1,1,1,1,1, 1,1,1,1,1, 0,1,1,1,0, 0,0,1,0,0); /* small -- small...