language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
// author : F. Costanza // date : 20.01.16 // // Function to calculte weights for HT binned samples // Returned weights must be multiplied by instantaneous luminosity[pb-1]. enum samples{ DYM5to50=1, DYM50, W}; double DYM5to50_HTBinned_Weights( float ht){ float xslo_incl = 71310.; float xslo_binned = 0.; float...
C
#include <stdio.h> #include <stdlib.h> typedef struct Linked_List { char data; struct Linked_List* next_node; } Linked_List; //forward declarations int insert(Linked_List** head, char data); int delete(Linked_List** head, char data); int isEmpty(Linked_List* head); void printList(Linked_List* head); void menu...
C
/* * button.c * * Created on: Jun 22, 2020 * Author: sergi */ #include "button.h" #include <stdio.h> /** * Initialize structure */ Button_t button_init( GPIO_TypeDef *port, uint32_t pin, ButtonActiveLevel_t Level, uint8_t id) { Button_t init = { .id = id, ...
C
/** * STM8S-EK ϰ--֣һͨһJoystick * key.c * @author lisy * @date 20170507 1207 */ #include "key.h" #include "stm8s_gpio.h" #define KEY_PORT GPIOD #define KEY_PIN GPIO_PIN_3 #define JOYSTICK_PORT GPIOB #define JOYSTICK_UP_PIN GPIO_PIN_6 #define JOYSTICK...
C
/* basic free */ #include <stdlib.h> int main() { int *p; int a; p = (int *) malloc(2*sizeof(int)); p[0] = 0; p[1] = 1; free(p); return(0); }
C
#include <stdio.h> #include <cs50.h> #include <string.h> #include <crypt.h> int main(void) { string n = "\0ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; // string pass = "50VxqXoSfyiuc"; string pass = get_string("word: "); printf("%s\n", pass); int a=53; for(int i=0; i<a; i++) { ...
C
// Find the position of number with n bits in list of all numbers with n bits // By: Chris Spitzer #include <stdio.h> #define MAX_BITS 16 #define MAX_NUM (1 << MAX_BITS) int pasc[MAX_BITS][MAX_BITS]; void init() { int i,j; for (i = 0; i < MAX_BITS; i++) { pasc[i][i] = 1; pasc[i][0] = i+1; } for (i =...
C
#include<stdio.h> #include<pthread.h> //int num_of_times = 5; int num = 2; int num_of_times = 10; pthread_mutex_t lock1 = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t cond1 = PTHREAD_COND_INITIALIZER; void* print_even() { pthread_mutex_lock(&lock1); while(num_of_times>0){ while((num%2)!=0) { pthread_cond_wai...
C
#include<stdio.h> #pragma warning(disable:4996) void init_cache(int(*cache)[101]); int jump(int(*cache)[101], int(*map)[101], int x, int y, int n); int main() { int C, t; int n, i, j; int map[101][101]; int cache[101][101]; scanf("%d", &C); for (t = 1; t <= C; t++) { init_c...
C
#include <stdio.h> #include <string.h> char inputText[] = "abbba"; int n = 0, m = sizeof(inputText) - 2, isPalindrome = 0; void checkPalindrome (int a, int b) { if (a > b) return; else if (inputText[a] == inputText[b]) { isPalindrome = 1; checkPalindrome(a + 1, b...
C
#include <stdio.h> #include <stdlib.h> void do_fstenv ( void* p ) { asm("fldpi ; fld1; fldln2 ; movl 8(%esp), %eax ; fstenv (%eax)"); } int main ( void ) { int i; unsigned int* buf = malloc(7*sizeof(int)); do_fstenv(buf); for (i = 0; i < 7; i++) { printf("%08x ", buf[i]); i...
C
#include<stdio.h> void tower(int n, char source, char dest, char temp) { if(n>0) { tower(n-1,source,temp,dest); printf("%d %c %c\n",n,source,dest); tower(n-1,temp,dest,source); } return; } int main() { int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); tower(n,'S','D','T'); printf("\n")...
C
#include <signal.h> #include <stdio.h> int main() { sigset_t waitset; sigemptyset(&waitset); sigaddset(&waitset, SIGINT); sigprocmask(SIG_BLOCK, &waitset, NULL); siginfo_t info; struct timespec timeout; timeout.tv_sec = 10; timeout.tv_nsec = 0; int result = sigtimed...
C
/* -------------------------------------------------------------------------- */ // This function does the back substitution and accomplishes the final part // of solving linear equation Ax = b; // Input: the A, b in echelon form, x in its initial form; // Output: x in its final (inverted solution) form; // Codes wr...
C
#include <stdio.h> int f(int n) { if (n<=0) return 0; if (n==1) return 1; return f(n-1) + f(n-2); } int main(void) { int r=f(10); printf("f(10) = %d\n", r); return r; }
C
//ڷκ ڸ Է¹޴´. // ڰ 50 ȮѴ. //) ڸ Է ּ : 50 // (50 ) ÷Ǽ̽ϴ. // ȸ. #include <stdio.h> int main(void) { int a, b, c; printf("ڸ Էּ: "); scanf("%d",&a); if(a==50) printf("÷Ǽ̽ϴ."); else printf("ȸ"); return 0; }
C
#include<stdio.h> int main() { int col,rows,i,j; int matrix[10][20]; printf("Enter no. of Rows"); scanf("%d",&rows); printf("Enter no. of Coloumns"); scanf("%d",&col); for(i=0;i<rows;i++) { for(j=0;j<col;j++) { printf("Enter data in [%d][%d]:",i,j); scanf("%d,%d",&matrix[i][j]); } } for(i=0;i<rows;i+...
C
// // Created by user-pc on 11/09/2017. // #include "node.h" node* createNode(int val) { node* n = (node*)malloc(sizeof(node)); if(n==NULL) { printf("error in createNode n==NULL\n"); return NULL; } n->value = val; n->next = NULL; n->pre = NULL; return n; }
C
#include <stdio.h> #include <string.h> int is_h(int num) { char szNum[4]={0}; sprintf(szNum,"%d",num); unsigned int length=strlen(szNum),i; for(i=0;i<(length+1)/2;i++) { if(szNum[i]!=szNum[length-i-1]) return 0; } return 1; } int main() { long n; scanf("%ld",&n); if(is_h(n)) printf("Y"); else print...
C
/*********************************/ /* TRIE */ /* Yoav Hattav */ /* Last Updated 30/01/20 */ /* Reviewed by: Guy Cohen-Zedek*/ /*********************************/ #include <stdlib.h> /* malloc */ #include <assert.h> /* assert */ #include "trie.h" /* API */ #define ...
C
#include "pruebas_arbol.h" #include "abb.h" #include <stdio.h> #define CANT_PRUEBAS 21 #define NUMINSERTAR 7 #define ERROR -1 int comparar_enteros(void* elemento1, void* elemento2){ if(*(int*)elemento1 > *(int*)elemento2) return 1; if(*(int*)elemento1 < *(int*)elemento2) return -1; return 0; } int mai...
C
int trap(int *height, int heightSize) { if (heightSize <= 2) return(0); int leftmax[heightSize], rightmax[heightSize]; int i, t, sum; t = leftmax[0] = height[0]; for (i = 1; i < heightSize; i++) { leftmax[i] = t; if (height[i] > t) t = height[i]; } t = rightmax[heightSize - 1] = height[heightSize - 1]...
C
#ifndef OSFRA_H #define OSFRA_H #ifdef __cplusplus extern "C" { #endif #include <stdint.h> #include <stddef.h> #include <typedef> #include <math.h> typedef float float32_t; typedef struct{ float32_t *h_magVect; //!< Plant Mag SFRA Vector float32_t *h_phaseVect; //!< Plant Phase SFRA Vector float32...
C
#include <stdio.h> #include <math.h> int judge(int x) { if(x==1) return 0; int a = sqrt(x+1); for(int i=2; i<=a; ++i) { if(x%i == 0) return 0; } return 1; } int main(void) { int n, a[401]; for(int i=0; i<401; ++i) { if(judge(i)) ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define DICT_SIZE 45427 #define NOT_FOUND -1 char *NewToUpper(char *string); int main(char args, char *argv[]){ //TODO Remove personal comments before cubmitting to sir. FILE *dict, *input, *output; int i, len, suggNum, choice; char dictionary[DI...
C
#include <stdio.h> /*Elabore um algoritmo onde digite o peso e a altura de uma pessoa. Ao final demonstre o IMC desta pessoa. Considere a tabela (slide 8 da aula 06) para determinar sua situação. IMC = peso / altura² */ int main(void) { float peso; float altura; float imc; printf("Digite o seu peso\n"); scanf("%f",&p...
C
#include <stdio.h> #include <malloc.h> #include <stdlib.h> #include <string.h> typedef struct { char *s; int l; } TOP; inline static void BI(TOP *a, int m) { int i; a->l = m; a->s = (char *)malloc(m * sizeof(char) + 1); scanf("%s", a->s); for (i = 0; i < a->l; ++i) a->s[i] -= '0'...
C
#include <stdio.h> #include <time.h> void function_to_time(void); int main(void) { time_t tend, tstart; tstart = time(NULL); function_to_time(); tend = time(NULL); printf("The time before was %s",ctime(&tstart)); printf("The time after was %s",ctime(&tend)); return 0; }
C
#include "HashMap.h" // Hash function used to store nodes based on their strings size_t djb2Hash(char* str) { size_t hash = 5381; int c; while ((c=*str++)) { hash = ((hash << 5) + hash) ^ c; } return hash; } // Creates memory space for a hash map of character & their frequency values within the base string Has...
C
#include <stdlib.h> #include <cdescent.h> #include <omp.h> static void col2ijk (const int nx, const int nh, const int col, int *i, int *j, int *k) { int h; *k = col / nh; h = col % nh; *j = h / nx; *i = h % nx; return; } static mm_sparse * mm_real_smooth_sparse_x (const int nx, const int ny, const int nz) { ...
C
#include <signal.h> #include <stdio.h> #include <stdlib.h> #include "cmd_args.h" #include "consumer.h" #include "producer.h" #include "ring_buffer.h" #include "sleep_thread.h" /*! * \brief Function to free threads (producers or consumers). * \param threads The array of threads to free. * \param elementCount The si...
C
/* This software was developed by Bruce Hendrickson and Robert Leland * * at Sandia National Laboratories under US Department of Energy * * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */ #include <stdio.h> #include "structs.h" #include "defs.h" void make_bndy_list(graph, move...
C
#include <stdio.h> // printf() , scanf() #include <stdlib.h> // rand() #include <time.h> // srand(time(0)) // ٿ void main(){ int comnum = 0; int mynum = 0; srand(time(0)); comnum = rand() % 100; // 0~99 while(1){ printf("ġƮ ==> %d\n" , comnum); printf("0~99 ڸ Էϼ >>> "); //mynum = rand() % 100; scanf("%d" ...
C
//#pragma once //#include <assert.h> //template <typename T> //class MyClass//̬Ӽ //{ //public: // MyClass() // { // data = new T[10]; // capacity = 10; // size = 0; // } // ~MyClass() // { // delete[]data; // } // void push_back(T e) // { // if (size == capacity) // { // resize(2 * capacity); // } // //assert...
C
#include "generator.h" static void display_board(completed_grid_t grid) { printf("\n# Solution\n"); for (size_t i = 0; i < grid.data.dim; ++i) { printf("#"); for (size_t j = 0; j < grid.data.dim; ++j) { for (size_t k = 2; k < NB_DIGITS(grid.data.dim) - NB_DIGITS(grid.board[i...
C
/* 3) Dizemos que uma matriz quadrada inteira é um quadrado mágico se a soma dos elementos de cada linha, a soma dos elementos de cada coluna e a soma dos elementos das diagonais principal e secundária são todas iguais. Leia uma matriz 10x10 do usuário e imprima se ela é um quadro mágico ou não. */ #include <stdio.h> ...
C
#include <stdint.h> #include "lm3s6965_memmap.h" #include "nvic.h" #define NVIC_BASE ((M3_PERIPHERAL_BASE)+ 0x00000100u) /* NVIC register map structure. * Refer: http://www.ti.com/lit/ds/symlink/lm3s6965.pdf Table 3-7. * Note: all offsets in comments are from NVIC_BASE == 0xE000E100 */ typedef struct __attri...
C
/** * Joseph Okonoboh * Lab 2, SUMMER 2015 CECS 424 * * animal.c */ #include <stdio.h> #include "animal.h" static void* Cat_Vtable[2] = {Speak_Cat, Get_Cost_Cat}; static void* Dog_Vtable[2] = {Speak_Dog, Get_Cost_Dog}; static void* Lion_Vtable[2] = {Speak_Lion, Get_Cost_Cat}; void Construct_Cat(Cat* c) { c-...
C
/* free.c Implementation of free() */ #include "malloc.h" #include "platform.h" #ifndef PROVIDES_FREE /* free Attempts to free the memory pointed to by 'ptr' Different from the standard free: returns -1 if already free, or -2 if not part of the malloc list */ BYTE free(void *ptr) { /* Do a relativly...
C
#include <std.h> #include "keep.h" inherit VAULT; void create() { ::create(); set_property("light",2); set_property("indoors",1); set_property("no sticks",1); set_name("tower of hawk"); set_short("%^YELLOW%^Inside the Tower of Hawk%^RESET%^"); set_terrain(STONE_BUILDING); set_travel(P...
C
#ifndef MAX_SUBARRAY_H #define MAX_SUBARRAY_H /****************************************/ /*** Maximum Subarray Algorithms ***/ /****************************************/ // MAXIMUM CONTIGUOUS SUBARRAY // // this will find the largest contiguous (adjacent values) // sub-array within the array passed, and retur...
C
/* * @Author: your name * @Date: 2020-02-07 17:02:29 * @LastEditTime: 2020-09-29 21:19:53 * @LastEditors: Please set LastEditors * @Description: In User Settings Edit * @FilePath: \undefinedd:\study\c&c++\数据结构\浙江大学数据结构\code\树的同构.c */ #include <stdio.h> #include <stdlib.h> #define MaxTree 10 #define ElementType ...
C
#include <stdio.h> #include "s3c2440-regs.h" #include "uart_ops.h" #include "i2c_ops.h" #include "eeprom_ops.h" #include "i2c_irq.h" void i2c_eeprom_test(void) { int i, addr, value; char choice; char buf[200]; while (1) { printf("\r\n###### i2c_eeprom testing program ######\r\n"); printf("[r] Read eeprom\r\n...
C
#include <libopencm3/stm32/rcc.h> #include <libopencm3/stm32/gpio.h> /* Set STM32 to 168 MHz. */ static void clock_setup(void) { rcc_clock_setup_pll(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_168MHZ]); /* Enable GPIOD clock. */ rcc_periph_clock_enable(RCC_GPIOD); } static void gpio_setup(void) { /* Set GPIO12-15 (in GPIO ...
C
#include <stdlib.h> #include <stdio.h> #include <assert.h> #include <stdbool.h> // Definition du type t_note struct t_note { float note; float coef; }; typedef struct t_note t_note; // Definition d'un tableau de notes t_tab_notes de 5 éléments. typedef t_note t_tab_notes[5]; /** * \brief Initialiser une no...
C
#include <stdlib.h> #include <unistd.h> #include <sys/time.h> #include <sys/types.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/select.h> #include <netinet/in.h> #include <stdio.h> #include <errno.h> #include <pthread.h> #include "handler.h" #define DEFAULT_PORT 8888 struct sock...
C
#include <stdio.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(void) { char c; int i; printf("input a number :"); scnaf("%c",&c); i = c-'0'; printf("The input number is %i\n", i); return 0; }
C
#include <stdio.h> #include <stdlib.h> int sommeTableau(int tableau[], int fin,int debut) { int i=0 , somme=0; for (i=debut ; i<fin ; i++) { somme=somme+tableau[i]; } return somme; } int max(int T[],int n){ int i;int m;m=T[0]; for (i=0; i<n ; i++) { if(T[i+1]>=T[i]) m=T[i+1]; ...
C
/* This is a standalone program. Pass an image name as a first parameter of the program. Switch between standard and probabilistic Hough transform by changing "#if 1" to "#if 0" and back */ #include <cv.h> #include <highgui.h> #include <math.h> int main(int argc, char** argv) { const char* filename = argc >= 2 ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "hash_table.h" // create a new hash list HashList_p hash_list_create() { HashList_p newlist = (HashList_p) malloc(sizeof(HashList_t)); newlist->first = NULL; return newlist; } // create a new hash node HashNode_p hash_node_create...
C
#include<stdio.h> #include<ctype.h> int main(int argc, char const *argv[]) { int char_count = 0; char ch='\0'; FILE *read, *write; read = fopen(*(argv + 1), "r"); write = fopen("temp.txt", "w+"); while ((ch=fgetc(read))!=EOF) { if islower(ch) { ch = toupper(ch)...
C
// // Created by Milan Suk on 23.02.18. // #include <stdio.h> #include <string.h> #include "matrix_test.h" /** * Print error message * @param input */ void test_err(char *input) { printf("[TEST] \x1B[31merror:\x1B[0m %s\n", input); } /** * Print success message * @param input */ void test_success(char *inp...
C
/* Goal: To understand how memory works in terms of datatypes */ #include <stdio.h> #include <stdint.h> int main() { uint8_t i; // Assigning values to 4 contiguous memory locations (since memory is byte addressable) uint8_t a[4] = {2, 1, 0, 0}; for(i=0;i<4;i++) { printf("a[%d] = %d\n", i,...
C
/* * * json_writer.c * * pgpool: a language independent connection pool server for PostgreSQL * written by Tatsuo Ishii * * Copyright (c) 2003-2015 PgPool Global Development Group * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereb...
C
#include <stdio.h> #define MAX_LEN 100 int main(void) { int i, j; char str[MAX_LEN]; fgets(str, MAX_LEN, stdin); /* Count consecutive starting blank spaces */ for(i = 0; str[i] == 32; i++) ; /* Shift the string i times to the left */ for(j = 0; str[j]; j++) str[j] = str[j + i]; printf("%s", str); re...
C
/* *写FIFO */ #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <fcntl.h> #include <stdlib.h> int main(int argc,char** argv) { if(argc<2){ printf("Usage: %s fifo_path\n",argv[0]); exit(0); } int count=0; int fd; int retry=0; char buf[128]="hello world!"; /*以写方式打开FIFO*/ if((fd=open(...
C
#include "globals.h" #include "lcdLib.h" void lcdInit() { // Configure data direction DATAREG = 0xFF; sbi(CTLREG, RS); sbi(CTLREG, RW); sbi(CTLREG, EN); _delay_ms(50); lcdCmd(0x3F); // function set _delay_us(100); lcdCmd(0x0F); // display on/off _delay_us(100); lcdCmd(0x01); _delay_us(3300); lcdCmd(0x06...
C
#include <stdio.h> #include <math.h> int main(void) { struct student { //you need to "int" them in order!! int number; char name [10]; char sex [1]; int age; double chi,math,eng; }; struct student stu_array [4] = { {1,{"zhangsan"},{'M'},20,86.3,88.5,78.5}, //if not using like this,you will get "warning:...
C
/* * prob005.h * 2520 is the smallest number that can be divided by each of the numbers from 1 * to 10 without any remainder. * * What is the smallest positive number that is evenly divisible by all of the * numbers from 1 to 20? * * * Created on: Jan 31, 2012 * Author: Jonathan Emord */ #ifndef PROB0...
C
/*05.07.2020 Данный пример демонстрирует работу UART(прерывания по приёму...). При вводе и отправке в терминале enabl светодиод на плате P1.6 загорится. При вводе и отправке в терминале desab светодиод на плате P1.6 погаснет. */ #include "project.h" #define RX_BUF_SIZE 5 #define LED_ON 1u #define LED_OFF 0u //--------...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* move.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> #include <ctype.h> int main(int argc, char **args){ FILE *f = fopen(args[1], "r"); FILE *f1 = fopen("output.c", "w"); if (f == NULL){ printf("File not found"); return 0; } char c; c = fgetc(f); while (c != EOF){ if (c == '#'){ while (c != '\n'){ fputc(c, f1); ...
C
#include <omp.h> #include <stdio.h> #define ITERATIONS 100000 int main() { int i, threads; double start, end, time, t1, step = 1.0 / ITERATIONS, PI = 0; for(i = 1; i <= 16; i++) { // Ask for i threads omp_set_num_threads(i); // Start timer start = omp_get_wtime(); // Parallel section #pragma omp p...
C
/* * Temp_user_beregner.c * * Created: 05-06-2019 14:15:24 * Author: kenne */ #include <avr/io.h> ///Decoder til Temp_user. Bestemmer hvor hurtig blseren skal kre. void Temp_user_decoder(int column, int row) { unsigned int Temp_user_input = column + row; switch (Temp_user_input) { case 12: OCR1B =...
C
/* * Copyright (c) 1995 Colin Plumb. All rights reserved. * For licensing and other legal details, see the file legal.c. * * bn.c - the high-level bignum interface */ #include "bn.h" /* Functions */ void bnBegin(struct BigNum *bn) { static int bninit = 0; if (!bninit) { bnInit(); bninit = 1; } bn->pt...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "retornaTokens.h" /* * Metodo que recebe o nome do arquivo de entrada e de saida (opcional) e limpa o codigo dos comentarios e retira dele os tokens necessarios para o tratamento. * Os tokens sao registrados em um arquivo .out */ char** retornaToken...
C
/** * @file PSA.h * * Hlavičkový soubor pro PSA * * IFJ Projekt 2020, Tým 2 * * @author <xpolis04> Jan Polišenský */ #pragma once #include "parser.h" #include "codegen.h" #include <stdbool.h> #define STACK_DEFAULT 1000 // definice typů které se vyskytují v precedenční syntaktické analýze typedef enum{ pl...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* make_grid.c :+: :+: :+: ...
C
/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ struct ListNode* reverseList(struct ListNode* head) { if(head == NULL)return NULL; if(head->next == NULL){ return head; } struct ListNode *newH = reverseList(head->next); he...
C
/* glsl.c */ #include <stdio.h> #include <stdlib.h> #include "glsl.h" /* ** Init GLSL */ int glslInit(void) { int error = 0; return error; } /* ** Read shader program from source */ static int readShaderSource(GLuint shader, const char *file) { FILE *fp; const GLchar *source; GLsizei length; int ret; pri...
C
#include <stdio.h> #include "demo_algorithms_shared.h" int partition(int array[], int low, int high); void quicksort(int array[], int low, int high); int middle_index(int low, int high); int main() { int int_array[] = {27,31,15,8,12,39,33,11,14,42,23,41, 25,13,16,15,16,18,2,33}; ...
C
#include "list.h" #include <assert.h> #include <stdbool.h> #include <stdio.h> static void test_init(){ List *list = (List *)malloc(sizeof(List)); list_init(list, NULL); assert( 0 == list_size(list)); assert(NULL == list_head(list) ); assert(NULL == list_tail(list) ); } static void test_insert(){ List *l...
C
#include <stdlib.h> #include "matrixGenerator.h" #include "multiplyMatrices.h" int convertArgvParamsToInt(char *argv[], int *x, int *y, int *z); int main(int argc, char *argv[]) { if(argc == 4){ int numColumns, numRows, numColumns2; int success = convertArgvParamsToInt(argv,&numRows,&numColumns...
C
#include<stdio.h> int main() { printf("Condicion if. \n\n"); float valA, valB, valC; valA = valB = 100; printf("Primer condicion. \n"); if(valA == valB) printf("Ambos son iguales\n\n"); printf("Segunda condicion. \n"); if(valA == valB) { printf("Ambos son iguales\n");...
C
#include <stdio.h> int main() { int n; double spending[1000]; while (scanf("%d", &n) != EOF) { if (n == 0) break; int i; double sum = 0; for (i = 1; i <= n; i++) { scanf("%lf", &spending[i]); sum += spending[i]; } double avg = sum / n; avg = (long) (avg * 100 + 0.5); avg /= 100; ...
C
/*%%===================================================================== %% Project: Pointset Registration using Gaussian Mixture Model %% Module: $RCSfile: mex_GaussTransform.c,v $ %% Language: C %% Author: $Author: bing.jian $ %% Date: $Date: 2008-11-13 21:34:29 +0000 (Thu, 13 Nov 2008) $ %% Version: ...
C
#include "heap.h" int insert(heap* queue, tcb* block){ queue->q[queue->size] = block; queue->size++; int curr = queue->size-1; while(queue->q[(curr-1)/2]->priority > block->priority){ queue->q[curr] = queue->q[(curr-1)/2]; curr = (curr-1)/2; } queue->q[curr] = block; return ...
C
#include "lists.h" #include <stdio.h> #include <stdlib.h> /** *sum_listint- returns sum of all n values in a listint_t *@head: head of listint_t *Return: 0 if list is empty or sum if not */ int sum_listint(listint_t *head) { int sum = 0; listint_t *current; if (head == NULL) return (0); current = head; w...
C
#include <stdio.h> int main() { int x,y,lee=1; scanf("%d",&x); scanf("%d",&y); while(y>=x) { x=x*2; lee++; } printf("%d",lee); return 0; }
C
#ifndef __INFLATE_H__ #define __INFLATE_H__ // inflate.h /* This module performs the inflate operation. There are also utilities for dealing with a zlib stream including reading the zlib header and the ADLER32 checksum */ // Includes #include "bitstream.h" #include "huffman.h" #include "logging.h" #include <stdlib...
C
#include <iostream> #include <stdlib.h> using namespace std; struct nod{ int data; nod *next; }*head, *tail; void adi(int data) { nod *temp = new nod; temp->data = data; temp->next = NULL; if(head == NULL) { head = temp; tail = temp; } else { temp-...
C
/* *File: main.c *Date: 2018-07-30 *Author: Dennis Bunne * *Assignment 4.3 from the swedish book "C från början" * * */ #include <stdio.h> int main(){ int days=0; double salary=0.01; for(; salary <= 10000000; days++){ salary *= 2; } printf("Days to earn 10 000 000 swedish crowns: %d\n",days ); return 0...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <sys/mount.h> #include <errno.h> int main(int argc, char *argv[]) { int result; // announce that we are here, in the INIT program result = printf("INIT: performing switch_root\n"); if(result <= 0) exit(1); ...
C
#include "holberton.h" #include <stdio.h> #include <stdlib.h> #include <string.h> /** * array_range - creates an array of integers * @min: minimum value in the array * @max: maximum value in the array * Return: a pointer to the array */ int *array_range(int min, int max) { int *ptr; int span, ct; if (min > max) r...
C
#include <stdio.h> #include <stdlib.h> #include "piladinamica.h" int main() { // int elem; // int i, elint; // int elchar; // int el1= 1; // int el2 = 45; // tPila pila_mez; // crear_pila(&pila_mez); // poner_en_pila(&pila_mez,&el1,sizeof(el1)); // poner_en_pila(&pila_mez,&el2,sizeof(el2)); ...
C
#include <stdio.h> #include <stdlib.h> #include "func.h" int PrintList(struct ListNode *head){ int i = 0; struct ListNode *current =head; while(current != NULL){ i++; printf("%2d\n", current->data); current = current->next; } return i; } void InsertInLinkedList(struct ListNode **head_p, int data, int posit...
C
//Author: Dr. Moore, Editted by Vikram Dudee #include "kstring.h" #include <stdlib.h> #include <string.h> //using namespace std; int sizetToInt(size_t t){ int res = 0; size_t temp = t; while(temp>0){ temp--; res++; } return res; } size_t intToSizet(int in){ size_t r = 0; int i = in; if(i>0){ while(i>...
C
#include "qimo.h" int main(){ seqstack A,B; InitStack(&A); InitStack(&B); //值等于栈顶 int i; // initscr(); do{ menu(); // printw("\n\n"); printf(" please input(0 - 7):"); scanf("%d",&i); // clear(); printf("\n\n"); switch(i){ case 1:push(&A,&B); break; //创建top case 2:pop(&A); break; ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* hash_dispatchers.c :+: :+: :+: ...
C
#include <sys/types.h> #include <sys/stat.h> #include <stdio.h> #include <stdlib.h> #include <wdns.h> int main(void) { /* to do compile-time checking, do something like the following: */ #if WDNS_LIBRARY_VERSION_NUMBER > 9001 printf("your install of libwdns supports compile-time versioning "); printf("(WDNS_LIBRAR...
C
/** *Author: Tim McVicker *Date: 30JAN2016 *This file includes all libraries and header files required to run the *valueServer and valueGuesser programs. It also contains the function *prototypes as well as the Node structure that is used in the programs. * functions included: *terminate_server() *terminate_...
C
#include<stdio.h> int main(){ int i=1; while(i<5){ // int a=0; static int a=5; a++; printf("a=%d\n",a); i++; } return 0; }
C
#include <stdio.h> #include <string.h> int main() { int input; scanf("%d",&input); if (input == 3 || input == 5 || input == 7) { printf("YES\n"); } else { printf("NO\n"); } return 0; } ./Main.c: In function main: ./Main.c:5:3: warning: ignoring return value of scanf, declared with attribu...
C
#include<stdio.h> struct item { int itemno,available; char itemname[50],itemcat[50]; }; int main() { int i,n; struct item s[100]; printf("Enter the number of items:"); scanf("%d",&n); for(i=0;i<n;i++) { printf("Enter the item name,item number,item category(FOOD/ELECTRONICS/COSMETICS) and availabili...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <sys/time.h> # define FRB 0 // timing for FRB010125 // # define FRB 1 // timing for FRB110220 #if FRB == 0 #define frb "FRB010125" #define indir "../frb_data/" #define file "5.4ms.cube" #define Dl 600.0 /* lower bound of DM */ #define Dh 1000.0 /* u...
C
// ESCUELA SUPERIOR DE CÓMPUTO // Macías Escalona Jorge Luis // Desarrollo de Sistemas Distribuidos - 4CM1 // DESCRIPCIÓN: estructura para el envío de datos // FECHA: Julio 18 del 2015 // ARCHIVO: data.h // #ifndef DATA_H_ #define DATA_H_ /* Definiciones necesarias para los clientes y el servidor de archi...
C
#include "be_mem.h" #include <stdlib.h> typedef struct { size_t size; } mnode; static size_t m_mem_count = 0; void* be_malloc(size_t size) { mnode *obj = malloc(size + sizeof(mnode)); if (obj != NULL) { obj->size = size; m_mem_count += size; return (char*)obj + sizeof(mnode); ...
C
#include "control.h" #include "sys.h" #include "data.h" char Fer_cmd;//ˮ ˮ0ʣ1 char flag=0;//״̬־λ int waite_time=0;//5Ӽʱʱ extern EVNDAT Evndat; //ݽṹ char high; char low; char Water_Level;//ˮλ Ϊ1ʾˮλFFʾˮλ0ʾˮλ void clean_Evndat() { Evndat.Flowrate=0; Evndat.Flowrate_out=0; Evndat.Total_flow=0; Evndat.Total_flow_ou...
C
/* ** str_to_int.c for in /home/millot_b/B4_Module/CPP-minar/d01/poule_d01/ex00 ** ** Made by Damien Millot ** Login <@epitech.eu> ** ** Started on Mon Feb 13 10:19:38 2017 Damien Millot ** Last update Mon Feb 13 11:58:14 2017 Damien Millot */ #include "str_to_int.h" #include <unistd.h> #include <stdlib.h> #includ...
C
/*Addition of two matrix*/ #include <stdio.h> int main() { int a[20][20], b[20][20], sum[20][20]; int i, j, r, c; printf("Enter the row of matrix : "); scanf("%d", &r); printf("Enter the column of matrix : "); scanf("%d", &c); printf("Enter the elements of first matrix :\n"); for (i = ...