language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include "cq.h" #include <stdio.h> int main(void) { puts("\n============================== Processor Info " "===============================\n"); cq_cpuinfo(); puts("\n============================= Cache Information " "=============================\n"); unsigned cache_idx = 0; while (1) { ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <errno.h> #define MAX_NAME_SIZE 32 #define NUMBER_OF_QUESTIONS 11 #define MAX_RESPONSE_COUNT 233 #define bool int typedef struct { int id; char full_name[ MAX_NAME_SIZE ]; char responses[ NUMBER_OF_QUESTIONS ]; } bubble_respons...
C
/* Copyright (C) 2002-2011 IP Infusion, Inc. All Rights Reserved. */ #ifndef _ALG_CONFIG_H_ #define _ALG_CONFIG_H_ #ifdef FALSE #undef FALSE #endif #define FALSE (1 == 0) #ifdef TRUE #undef TRUE #endif #define TRUE (1 == 1) /* Flag manipulation macros. */ #und...
C
#include <htc.h> #include "system.h" #include "adc.h" /******************************************************************************* * PUBLIC FUNCTION: adc_initialize * * PARAMETERS: * ~ void * * RETURN: * ~ void * * DESCRIPTIONS: * Initialize the ADC module. * *******************************************************...
C
#ifndef LINKEDLIST_H #define LINKEDLIST_H typedef struct LNode { ElemType data; LNode * next; }*LinkedList; Status InitList_L(LinkedList& L); Status GetElem_L(LinkedList L,int i,ElemType &e); LinkedList GetElemP_L(LinkedList L,int i); Status ListInsert_L(LinkedList L,int i,ElemType e); Status ListDelete_L(LinkedLis...
C
#include<stdio.h> #include<stdlib.h> #include<math.h> int node,link,prime,cost[50]; int graph[50][50],graph_count[50]; int left_node[50],right_node[50]; int sample_point[25],sample_point_count=1; int real_distance[50],temp_distance[50]; int countt=0; typedef struct hashing_table *pointer; typedef struct has...
C
#include <stdio.h> #include <locale.h> int main(){ int n; setlocale(LC_ALL, "Portuguese"); printf("n: "); scanf("%d", &n); if(n>0 || n<0 || n==0){ // n = n+1; printf("%d\n", n+1); } else printf("Digite um número!\n"); return 0; }
C
#ifndef ERR__H #define ERR__H #include <stdio.h> #include <stdlib.h> #include "raw_syscalls.h" #define ASSERT_EXPECTED(received, expected, msg) \ do { \ if (received != expected) { \ fprintf(stderr, "%s\n", msg); ...
C
#include <stdio.h> #include <stdlib.h> #include <omp.h> #define NUM_THREADS 3 #define THREAD_LEN 20 typedef struct vetor { int tam; int index; char* array; } Vetor; Vetor* criar_vetor (int tam) { Vetor* v = (Vetor*) malloc (sizeof(Vetor)); v->tam = tam; v->index = 0; v->array = malloc(sizeof(char) * tam); fo...
C
#pragma once /** **/ #include<stdio.h> #include<stdlib.h> #define LENGTH 6 typedef int ElemType; typedef struct HuffmanTreeNode { ElemType data; //нڵȨֵ struct HuffmanTreeNode* left; struct HuffmanTreeNode* right; }HuffmanTreeNode, *PtrHuffman;
C
#include<stdio.h> #include<math.h> main() { double x1,y1,x2,y2,m; while(scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2)!=EOF){ m=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); printf("%.2lf\n",m);} }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #define SWAP(X, Y, T) T=X,X=Y,Y=T typedef struct student { char *id; char *name; char *phone; char *age; struct student *next; }student; student *add(student*, char*, char*, char*, char*); student *delete(stud...
C
#include<stdio.h> int main() { int X,n; scanf("%d",&X); for(n=1; n<=X; n++){ if(n%2==0){ continue; } printf("%d\n",n); } }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define WORD_LENGTH 34 struct word_node { char entry[WORD_LENGTH]; struct word_node * next; }; typedef struct word_node Word; typedef Word * WordPtr; void linkyboi(char * word); int main() { while(1) { char buff[WORD_LENGTH]; pr...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* libft.h :+: :+: :+: ...
C
#include <windows.h> #include <stdio.h> // g (Global optimization), s (Favor small code), y (No frame pointers). #pragma optimize("gsy", on) #pragma comment(linker, "/OPT:NOWIN98") // Make section alignment really small. #define WIN32_LEAN_AND_MEAN int main(int argc, char *argv[]){ HANDLE hToken; TOKEN_PRIVILEGES ...
C
/*intersectionv means common elements like for e.g. a : 1 2 4 5 7 b : 3 7 5 2 1 ans : 1 2 3 5 7*/ #include<stdio.h> int main() { int i,j,size,user_input_1[50],user_input_2[50]; printf("Please enter the size of array: "); scanf("%d",&size); printf("\nEnter the first array elements :-\n"); for (i = 0...
C
//----------------------------------------------------------------------------- // Samuel Guyette // sguyette // 1518801 // charType.c // The program two command input and output files then classifies the // characters on each line of the input file into the following categories: // alphabetic characters (upper or l...
C
#ifndef PROCESS_H #define PROCESS_H #include <stdbool.h> #include <limits.h> enum algorithm_enum {fcfs, rr, mlfq_np, mlfq_pre}; typedef enum algorithm_enum Algorithm; #define MLFQ_LEVELS 3 //INT_MAX isn't infinite, but it is over a bilion, close enough static const unsigned int fcfs_quantum = INT_MAX; static const u...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { int setenvChecking = 0; // setenv함수 수행 후 결과를 받을 변수 // 1. getenv() 함수를 사용해서 각각의 환경변수에 설정된 값을 화면에 표시하기 printf("$HOME = %s\n", getenv("HOME")); // echo $HOME printf("$PS1 = %s\n", getenv("PS1")); // echo $PS1 printf("$PATH = %s\n", getenv("...
C
#include<stdio.h> main() { long long unsigned i,i1,j,m,n,sum; while(scanf("%llu",&j)==1) { n=0; sum=0; for(i1=1;i1<j;i1+=2) sum+=i1; m=(1+(sum*2)); for(i=1;i<=3;i++) n+=(m+((j-i)*2)); printf("%llu\n",n); } return 0; } /* #include <...
C
/* ** EPITECH PROJECT, 2017 ** main.c ** File description: ** */ #include "my_rpg.h" sfRectangleShape *inv_base(void) { sfVector2f size; sfVector2f pos; size.x = 400; size.y = 500; pos.x = 790; pos.y = 290; sfRectangleShape *inv_base = sfRectangleShape_create(); sfRectangleShape_setPosition(inv_base, pos); ...
C
#include <stdio.h> #include <stdlib.h> /* <stdlib> = standard library Used to get access to abs(x) function which returns the absolute value(positive value) of x */ #define STRLEN 100 /* Defines or declares a macro of 100(int) which we use to set the size of the strings we are going to use Macros are written all...
C
#include "headers/allvars.h" //Funcion principal int main(int argc, char const *argv[]){ int option; double b, bmin, bmax, db; double Iconditions[6]; char comentario = '#'; char *nombreParametro[6], sys[30]; double maxEnergy; double totalEnergy; nombreParametro[0] = "...
C
#include <stdio.h> #include <string.h> int main() { int i, n ; char word[6]; scanf("%d", &i); for (n = 0; n < i ; ++n) { scanf("%s", word); if (strlen(word) == 5) printf("3\n"); else if (word[0] == 'o' && word [1] == 'n') printf("1\...
C
/* CIRCLE 11 Written by Amarillion (amarillion@yahoo.com) This program uses "Mode 7" to map a bitmap on to a horizontal plane. The mode_7 function is actually pretty similar to the rotate_sprite function. You can move around with the up, down, left and right keys. Use the followin...
C
/* * @lc app=leetcode id=125 lang=c * * [125] Valid Palindrome */ bool isPalindrome(char* s) { int length = strlen(s); int i = 0, j = length; while (i < j) { if (!isalnum(s[i])) { ++i; continue; } if (!isalnum(s[j])) { --j; continue; } if (isdigit(s[i]) && isdigit(s[j])) { if (s[i...
C
#include <stdio.h> int main() { // output printf("Hello World!\n"); puts("Hello, world!"); // type size char c = -1; unsigned char uc = -1; short s = -1; unsigned short us = -1; int i = -1; unsigned u = -1; long l = -1; unsigned long ul = -1; float ...
C
#include "Search.h" BSTreeNode* BuyBSTreeNode(BSTDataType data) { BSTreeNode* pNewNode = (BSTreeNode*)malloc(sizeof(BSTreeNode)); if (pNewNode == NULL) { assert(0); printf("ڵ㴴ʧܣ\n"); return NULL; } pNewNode->_data = data; pNewNode->_left = NULL; pNewNode->_right = NULL; return pNewNode; } // int BSTreeIn...
C
//{ //Constants:// const double Lambda = 0.63; // mkm const double K = 2 * PI / Lambda; const double Z = 100.0; // mkm const double Z_2 = Z * Z; const vect_t D (1.0, 1.0); const vect_t SizePicture (10.0, 10.0); // mkm const vect_t SizeResult (10.0, 10.0); // mkm const double N0 = 1.33; const double N = 1.05; c...
C
#include <stdio.h> #include "sort.h" int main() { int* arr = (int*) malloc(10*sizeof(int)); arr[0] = 13; arr[1] = 9; arr[2] = 18; arr[3] = 15; arr[4] = 10; arr[5] = 12; arr[6] = 7; arr[7] = 19; arr[8] = 3; arr[9] = 14; int* arr2 = (int*) malloc(8); arr2[0] = 19; arr2[1] = 17; mergeSort(arr2, 2); printf(...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #include <ncurses.h> #include <ctype.h> // isspace()を使うのでincludeする //----------------------------------------------------------- // define // #define MAXSTR 256 // コマンド入力の最大文字数 //-------...
C
#define SEARCH_RADIUS 1 #include "finders.h" #include "generator.h" #include "layers.h" #include <unistd.h> int isViableMansion(LayerStack *g, int *map, int64_t seed, int regX, int regZ) { Pos posMansion = getLargeStructurePos(MANSION_CONFIG, seed, regX, regZ); // printf("%d %d\n",posMansion.x,posMansion.z); ...
C
#include <stdio.h> main(void) { float l1, l2, l3; scanf("%f %f %f", &l1, &l2, &l3); if (l1 != l2 && l3 != l1 && l2 != l3) printf("escaleno"); if (l1 == l2 && l3 == l1 && l2 == l3) printf("equilatero" ); if (l1 != l2 && l3 == l1 && l2 != l3) printf("isosc...
C
//Outout time and date #include <stdio.h> #include <time.h> int main() { time_t tm=time(NULL); fprintf(stdout,"\nTime and date : %s\n",ctime(&tm)); }
C
#ifndef SERIAL_PRINTER_H #include <avr/io.h> #define SERIAL_PRINTER_H #include <avr/io.h> #include <stdio.h> //#include <stdlib.h> void USART_CONFIG(); void USART_TRANSFER(uint8_t ender); void USART_TRANSFER_STRING(char * text); void USART_TRANSFER_INT(long int val); void USART_TRANSFER_INT_HEX(long int val); void US...
C
#include "interface.h" void inicializaDataOut(DataOut *datao, int numPontos) { datao->fila = malloc(sizeof(Fila) * numPontos); datao->substituicoes = 0; datao->tempo = 0; datao->numPontos = numPontos; int i; for(i = 0; i < numPontos; i++) { esvaziaFila(&datao->fila[i], i); } } ...
C
/* * By Guido De Rosa, 2011, released to the Public Domain. * * Computational Physics course, Univ. of Naples * */ #include "io.h" void matrix_print(Matrix A) { char * fmt = "%02.2f "; Index i, j; for (i=0; i<N; i++) { if (i < MAX_PRINTABLE_ROWS) { for (j=0; j<N; j++) { if (j < MAX_PRINTABLE_COLS) ...
C
#ifndef ENTRY_H #define ENTRY_H typedef struct stateEntry { char key[128]; char value[128]; struct stateEntry* next; } stateEntry; typedef struct stateTable { size_t size; stateEntry* data[0]; } stateTable; typedef struct capsuleEntry { char name[45]; unsigned char *key; uint32_t ...
C
#include "oram/oram.h" #include "oram/orandom.h" #include <stdio.h> #include <stdlib.h> #include <string.h> char * gen_random(const int len) { int i = 0; char *s = (char *) malloc(sizeof(char) * len); static const char alphanum[] = "0123456789" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz"; f...
C
#include<stdio.h> #include<stdlib.h> struct node { int data; struct node *rlink; struct node *llink; }*tmp=NULL,*tmp2=NULL,*tmp3=NULL; typedef struct node NODE; NODE *create(); void inorder(NODE *); void insert(NODE *); void t_cpy(NODE *,NODE *); int main() { int n,m; do { printf("\n1.create tree 1\n2.Insert ...
C
/* ** gen_map.c for gen_map in PSU_2016_zappy/Zappy_server/src ** ** Made by AdelyanTV-VM ** Login <thomas.bouillon@epitech.eu> ** ** Started on Tue Jun 27 16:40:18 2017 AdelyanTV-VM ** Last update Sun Jul 2 21:25:17 2017 AdelyanTV-VM */ #include "zappy.h" static void add_ressources(t_zappy *zappy, int x, int y, ...
C
#include "serial.h" #include "stm32f401xe.h" //PA2 : USART2 TX //PA3 : USART2 RX int serialPort() { RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN; RCC->APB1ENR |= RCC_APB1ENR_USART2EN; GPIOA->AFR[0] |= (7<<(2*4)) | (7<<(3*4)); GPIOA->MODER |= (2<<(2*2)) | (2<<(3*2)); USART2->CR1 = USART_CR1_UE; USART2->BRR = (52<<4) |...
C
/* ** EPITECH PROJECT, 2018 ** getnextline ** File description: ** brandon segers */ #include "get_next_line.h" #include "my.h" #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> static int line(char **result, char **buffer) { int i = 0; if ((*result = malloc(sizeof(char) * (READ_SIZE + 1))) == ...
C
#include "stdio.h" #include "lazypcscfelicalite.h" using LazyPCSCFelicaLite::PCSCFelicaLite; using LazyPCSCFelicaLite::PCSCErrorException; using LazyPCSCFelicaLite::PCSCIllegalStateException; using LazyPCSCFelicaLite::PCSCCommandException; using LazyPCSCFelicaLite::PCSCFatalException; using LazyPCSCFelicaLite::PCSCCry...
C
#include <stdio.h> #include <sys/types.h> #include <ifaddrs.h> #include <netinet/in.h> #include <string.h> #include <arpa/inet.h> #include <unistd.h> #include <stdlib.h> #include <time.h> int main(int argc, const char* argv[]) { struct ifaddrs* ifAddrStruct = NULL; void* tmpAddrPtr = NULL; getifaddrs(&ifAddrSt...
C
//------------------------------------------------------------------------------ // LG_heap: a Heap data structure and its operations //------------------------------------------------------------------------------ // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved. // SPDX-License-Identifier: ...
C
/** * \file vertex.h * \brief Fichier d'implémentation de la structure vertex. * \author David Phan, Raphaël Afanyan * \version * \date 2014 */ #ifndef VERTEX_H #define VERTEX_H /** * \struct shared_ptr * \brief Pointeur partagé du tableau d'exclusions des edges */ struct shared_ptr { int count; //nombre...
C
#include <stdio.h> #include <stdlib.h> int gcd(int a, int b); int main() { int a,b; int result = 1; while(scanf("%d%d",&a,&b) != EOF) { result = gcd(a,b); printf("%d\n",result); } return 0; } int gcd(int a, int b) { int tmp; while(a % b != 0) { ...
C
#include <assert.h> #include <complex.h> #include <differential_eq/numerov.h> #include <math.h> #include <print_routines.h> #include "../routines.h" /*================= PARAMETERS ================*/ int N = 1000; double L = 1.0; double xi = 1.0; /*================= STRUCTURES ================*/ typedef struct Params...
C
/* Summary: Compute the yearly depreciation of the value of an item, given by Depreciation = (PURCHASE VALUE - SALVAGE VALUE) / YEAR OF SERVICE */ #include<conio.h> #include<stdio.h> void main() { float sv,pv,dep; int yos; clrscr(); printf("Enter the purchase value :- "); scanf("%f",&pv); printf("Enter the ye...
C
#include <stdio.h> // printf #include <stdlib.h> // atof #include <math.h> // fabs #include <stdbool.h> // bool #define EPSILON 0.000001 double f(double x, double a) { return x*x - a; } bool too_big(double x) { return fabs(x) > EPSILON; } bool too_far(double x, double y) { return fabs( (x-y)/y ) > EPSILON; } in...
C
# include< stdio.h> int str_ leng th(char []); void str_reverse(char [], char []); void str_ copy (char [], char []); int str_ compare(char [], char []); void str_ concatenate(char [], char[]); int str_palindrome(char []); void main(){ char s[100], s1[100], s2[100], s3[100]; int i; pri...
C
void main() { int n,a[25],b[25]={0},i,j,max=0; scanf("%d",&n); for (i=0;i<=n-1;i++) { scanf("%d",&a[i]); b[i]=1; } for(i=1;i<=n-1;i++) { for (j=n-i;j<=n-1;j++) { if(a[n-1-i]>=a[j]) { if(b[n-i-1]<b[j]+1) { b[n-i-1]=b[j]+1; } } } } for (i=0;i<=n-1;i++)...
C
#include <stdio.h> double foo(void); int main(void) { double d = foo(); printf("done %4.3f\n", d); return 0; }
C
#include<stdio.h> int main() { int n,s; scanf("%d",&n); int i,d,a[n]; scanf("%d",&d); int count=0; for (i=0;i<=n;i++) { a[i]=d%10; d=d/10; } printf("enter the number to check:"); scanf("%d",&s); for (i=0;i<=n;i++) { if(a[i]==s) { count++; } printf("%d",count); } return 0; }
C
#include<stdio.h> #include<conio.h> void main() { int a=0,b=1,c,n,i=2; printf("enter a number"); scanf("%d",&n); while(i>n) { c=a+b; i++; } printf("the fibonaaci series is %d",c); a=b; b=c; }
C
#include <string.h> #include <stdio.h> #include <ctype.h> #include "ben.h" #define DEFAULT_OUTFILE "out.bin" char parseHexDigit(char digit) { if (isdigit(digit)) return digit - '0'; if (digit >= 'A' && digit <= 'F') return 10 + digit - 'A'; if (digit >= 'a' && digit <= 'f') return 10 + digit - 'a'; return 0;...
C
#include <stdio.h> #include <stdlib.h> #include <lua.h> #include <lauxlib.h> static int has_entity(lua_State *L) { int arg_count = lua_gettop(L); if(arg_count != 1) { lua_pushstring(L, "`has_entity` expects a single argument"); lua_error(L); } // read the first argument from the stack int id = luaL_checkint(...
C
//Addition of all numbers #include<stdio.h> void main(){ int num,mod,sum=0; printf("Enter number: "); scanf("%d",&num); while(num < 0){ printf("please enter positive number only\n"); printf("Enter number: "); scanf("%d",&num); } while(num > 0){ mod=num%10; num=num/10; sum +=mod; } printf("Sum o...
C
/* File Name : ftpclient.c * * Projet Name : FTP (File Transfer Protocol) Project * Subject : Introduction to Programming Tools * Yaman Parasher and Mahmoud Nasser * * * This is the client side of FTP Server Cient model which runs with custom server. * * * Direction to use the client side: * ./ftpcli...
C
#include <stdio.h> #include <Windows.h> #include <conio.h> typedef int bool; #define true 1 #define false 0 typedef enum { NOCURSOR, SOLIDCURSOR, NORMALCURSOR } CURSOR_TYPE; struct s { int x; int y; }; void setcursortype(CURSOR_TYPE c) { system("mode con cols=80 lines=25"); CONSOLE_CURSOR_INFO CurInf...
C
/* * fs/eventfd.c * * Copyright (C) 2007 Davide Libenzi <davidel@xmailserver.org> * */ #include <linux/file.h> #include <linux/poll.h> #include <linux/init.h> #include <linux/fs.h> #include <linux/sched.h> #include <linux/kernel.h> #include <linux/list.h> #include <linux/spinlock.h> #include <linux/anon_inodes...
C
#include <stdio.h> #include <string.h> void string_change(char n[]) { char m[20]; int i; int k; strcpy(m, n); for (i = 0; n[i] != '\0'; i++) ; k = i - 1; for (i = 0; m[i] != '\0'; i++) n[i] = m[k-i]; n[i] = '\0'; } int main() { char m[20]; gets(m); string_c...
C
#include<stdio.h> #include<stdlib.h> int main(){ int a=0; char input; FILE *fp; fp=fopen("input.bin","rb"); if (fp==NULL){ return -1; } while(fread(&input,sizeof(char),1,fp)==1){ a=input&0x000000ff; printf("input=%02X,a=%d\n",input&0x000000ff,a); for (int i=0;i<32;i++){ printf("%d",((a&(1<<(31-i)))==0)?0:...
C
#include "common.h" #include "bintree.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include "Queue.h" /** * @brief Print nodes at level [level] * @note * @param *root: root pointer of binary tree * @param level: level number * @retval */ Status PrintLevelAt(BinTree *root, unsigned int lev...
C
#include <stdio.h> #include <stdlib.h> #include <allegro5/allegro.h> #include <allegro5/allegro_image.h> #include <allegro5/allegro_native_dialog.h> #include <allegro5/allegro_primitives.h> #include "arrdinamico.h" #include "createfiles.h" int createfsm(miestado* p2e, mifuncion* p2f, int cantestados, int cantfuncione...
C
/* an inefficient implementation of exact Gaussian elimination where the coefficients are all integers note that we use `long long` to represent numerators/denominators, so if it overflows, you're screwed. */ #include <inttypes.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> ...
C
/***************************************** * ̸ : ShortCircuit.c * Ͽ뵵 : ࿬ ϱ * ۼ : *****************************************/ #include <stdio.h> void main(void) // main() Լ { int a = 10, b = 20, c = 3; printf("a = %d, b = %d, c = %d\n", a, b, c); // && 0()̸ ڸ c = (a++ == 11) && (b++ == 20); printf(...
C
#ifndef FAST_HASH_TIMER_H #define FAST_HASH_TIMER_H #include <stdio.h> #include <stdlib.h> #include <time.h> /** * This macro represents an inlined, identical portion of code used to time any function. * This is such that different abstractions of timings are not affected by function call overhead. */ #define TIM...
C
/* 1.ÿΪһݣ iݶӦһǸֵ cost[i](0ʼ) ÿһ㶼ҪѶӦֵȻѡһݻݡ Ҫҵﵽ¥㶥ͻѡڿʼʱѡΪ 0 1 ԪΪʼݡ ʾ 1: : cost = [10, 15, 20] : 15 : ͻǴcost[1]ʼȻɵݶһ15 ʾ 2: : cost = [1, 100, 1, 1, 1, 100, 1, 1, 100, 1] : 6 : ͻѷʽǴcost[0]ʼЩ1cost[3]һ6 */ #include<stdio.h> #include<malloc.h> int minCostClimbingStairs(int* cost, int costSize) { int i...
C
#include <cs50.h> #include <stdio.h> int main(void) { //h= hight of the pyramid //w= width of the pyramid int w, h, x, space, gap; //ask for integer value, if not integer repeat the question do { x = get_int("height: "); } while (x>8||x<1); //to control which l...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* print.c :+: :+: :+: ...
C
#include<stdio.h> int N, A[50]; int calc(int i,int M) { if(M==0) return 1; if(i>=N) return 0; int answer = calc(i+1, M) || calc(i+1, M - A[i]); return answer; } int main() { //input int M, q, ornot; scanf("%d", &N); for(int i=0; i<N; i++) scanf("%d", &A[i]); scanf("%d", &q); for(int i=0; i<q; i++)...
C
/* Public domain by Andrew M. <liquidsun@gmail.com> See: https://github.com/floodyberry/curve25519-donna Curve25519 implementation agnostic helpers */ /* * In: b = 2^5 - 2^0 * Out: b = 2^250 - 2^0 */ static void curve25519_pow_two5mtwo0_two250mtwo0(bignum25519 b) { bignum25519 ALIGN(16) t0,c; /* 2^5 - 2^...
C
#include "ext.h" #include "ext_sysmem.h" #include "mxj_methodlist.h" #include "mxj_utils.h" t_mxj_methodlist *mxj_methodlist_new() { t_mxj_methodlist* ml; ml = (t_mxj_methodlist*) sysmem_newptr(sizeof(t_mxj_methodlist)); ml->mlist = NULL; ml->size = 0; return ml; } void mxj_methodlist_add(t_mxj_methodlist *...
C
#include <stdio.h> #include <setjmp.h> jmp_buf bufferA,bufferB; void routineA(); void routineB(); void routineA(){ int r; printf("A(1)\n"); r = setjmp(bufferA); if(r == 0) routineB(); printf("A(2) r = %d\n",r); r = setjmp(bufferA); if(r == 0) longjmp(bufferB,20001); printf("A(3) r = %d\n",r); ...
C
#include <stdio.h> void string_revert(char *s) { char tmp; int i = 0,len = 0; while (s[i] != '\0') { len++; i++; } printf("before revert:%s\n", s); for (i = 0;i < len / 2;++i)// mirror with middle index { tmp = s[i]; s[i] = s[len - 1 - i]; s[len -...
C
// This is a personal academic project. Dear PVS-Studio, please check it. // PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com #include <time.h> #include "../include/scheduler.h" #include "../include/naiveConsole.h" static unsigned long ticks = 0; typedef struct TimerNode { pcb *proces...
C
#include <stdio.h> int main() { int a, b, resultado; printf("Programa para calculos basicos\n"); printf("Digite dois numeros: "); scanf("%d %d, &a, &b"); printf("\nResultado\n"); resultado = a + b; printf("Soma = %f\n", resultado); resultado = a - b; printf("Subtração = %f\n", resu...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <fcntl.h> #include <unistd.h> #include <ctype.h> #include <sys/stat.h> #include "printFunctions.h" #include "huffmanTree.h" void printHuffmanCode(int fd, int code[], int length, char *token) { int i; //int bytes_written; int ...
C
#include "holberton.h" /** *print_alphabet_x10 - prints the alphabet *void - Entry point *Return: Always 0 * **/ void print_alphabet_x10(void) { char alpha; char multi; for (multi = '0'; multi <= '9'; multi++) { for (alpha = 'a'; alpha <= 'z'; alpha++) { _putchar(alpha); } _putchar('\n'); } }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> // 兄弟进程利用管道实现 ls | wc -l, 父进程waitpid进行回收, 并打印回收状态 int main(int argc, char *argv[]) { // create pipe int pipeFd[2]; if (-1 == pipe(pipeFd)) { perror("fork error"); exit(EXIT_FAILURE); } ...
C
#include <SDL/SDL.h> #include <GL/glut.h> #include "menu.h" #include "game.h" #include "audio.h" #include "editor.h" #include "utilities.h" /* Dimensions de la fenêtre */ unsigned int WINDOW_WIDTH = 1000; unsigned int WINDOW_HEIGHT = 1000; /* Dimensions du jeu */ int GAME_WIDTH = 804; int GAME_HEIGHT = 804; /* Nombr...
C
#include<stdio.h> void main() { int num; printf("enter any integer",num); scanf("%d",&num); printf("cube of %d=%d",num,num*num*num); } // Good Work launde
C
/*fwrite(), zapiswashta v RAND 100 sluchaini chisla*/ #include <stdio.h> #include<stdlib.h> int main (void) { FILE *fp; int i ,num; if ((fp=fopen("rand","wb"))== NULL) { printf("Cannot open file.\n"); exit(1); } for (i=0,i<100,i++) { num= rand(); fwrite(&num, sizef num ,1,fp); } f...
C
#include "string.h" #include "mailbox.h" #define MAX_NUM_BOX 32 static mailbox_t mboxs[MAX_NUM_BOX]; void mbox_init() { int i; for (i = 0; i < MAX_NUM_BOX; i++) { mboxs[i].name[0] = '\0'; mboxs[i].msg[0] = '\0'; mboxs[i].msg_length = 0; mboxs[i].msg_num = 0; mboxs[i].a...
C
// Simple command-line kernel monitor useful for // controlling the kernel and exploring the system interactively. #include <inc/stdio.h> #include <inc/string.h> #include <inc/memlayout.h> #include <inc/assert.h> #include <inc/x86.h> #include <kern/console.h> #include <kern/monitor.h> #include <kern/kdebug.h> #includ...
C
#include <stdio.h> #include <conio.h> #include <math.h> void main() { float a; positive: printf("please enter a positive number : "); scanf("%f", &a); if(a < 0) goto positive; else printf("square root of %.1f is %.2f", a, sqrt(a)); getch(...
C
#include <stdio.h> #define SIZE_X 3 #define SIZE_Y 2 #define SIZE_Z 4 int cube[SIZE_X][SIZE_Y][SIZE_Z] = {{ {1, 2, 3, 4 }/*, {0, 0, 0, 0 }*/}, { {2, 3/*,0, 0*/} , {4, 6, 8, 10 } }, { {3, 4, 5, 6 } , {6, 8, 10/*, 0*/} }}; int main(...
C
#include <stdio.h> #include "future.h" // TODO: Add error message to void future_cards_from_deck(deck_t * deck, future_cards_t * fc) /* This adds ptr into the future cards for the given index (that is, */ /* which ?n it is). So if this is a future card for ?3, then index */ /* will be 3. ptr will point at an existin...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* two_stacks_2.c :+: :+: :+: ...
C
#include<stdio.h> int main() { int i; double h,u,d,f,s,v,x; while(scanf("%lf%lf%lf%lf",&h,&u,&d,&f)==4) { if(h==0.0) break; v=u*f/100.0; s=0.0; for(i=1;;i++) { s=s+u; if(s>h){x=1;break;} else if(s<0.0){x=0...
C
#include "holberton.h" /** * jack_bauer - entry point * Description: prints the 00:00 - 23:59 of Jack Bauer * Return: 0 */ void jack_bauer(void) { int hr, ms; for (hr = 0; hr < 24; hr++) { for (ms = 0; ms < 60; ms++) { _putchar(hr / 10 + '0'); _putchar(hr % 10 + '0'); _putchar(':'); _putchar(ms...
C
#include <stdio.h> int main() { double amount; scanf("%lf",&amount); if(amount>=5000) printf("%.2lf\n",amount*0.8 ); else if(amount>=3000) printf("%.2lf\n",amount*0.85 ); else if(amount>=1000) printf("%.2lf\n",amount*0.9 ); else if(amount>=500) printf("%.2lf\n",amount*0.95 ); else printf("%.2lf\n",amou...
C
#include <stdio.h> #include <string.h> struct student{ char name[20]; /* student name */ double testScore; /* test score */ double examScore; /* exam score */ double total; /* total = (testScore+examScore)/2 */ }; double average(); int main() { printf("average(): %.2f\n", average()); return 0;...
C
//signpost.c // changed to get rid of the conflict with actual exits using "enter" /* we should probably get rid of the read action too so it doesn't mess with other signs in the room but since we're making most signs something you read I wasn't sure yet if that was a good idea *Styx* 11/18/04 */ #include <s...
C
#include "variadic_functions.h" /** * sum_them_all - function that returns the sum of all of its parameters * @n: count of parameters given * * Return: sum (variable) - or 0 - if n == 0 */ int sum_them_all(const unsigned int n, ...) { va_list nums_given; unsigned int i; unsigned int sum = 0; va_start(nums_gi...
C
/** * @file base.h * @author Aurélien Chemier * @author Romane Lhomme * @date 2014 */ #include <math.h> #include <stdlib.h> #include <stdio.h> /** * @brief Génération d'un nombre aléatoire entre borné entre A et B. * * @param A borne inferieure * @param B borne superieure * @return un double entre A e...
C
/************************************************************************** * Hailstone Numbers * Pauses for 2 seconds then prints each hailstone integer to the debug stream. * Hailstone sequence terminates when n = 1 * ***************************************************************************/ //take an ...