language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct { int codProd; char denumire[50]; char um[10]; int cantitate; int pretUnitar; }produs; void readProcess(char* numeFis, produs *p, int *n) { FILE *pf = fopen(numeFis, "r"); if (pf == NULL) { printf("Couldn't open File"); exit(1); ...
C
#include "io.h" void main() { int sum[10]; int i; i = 2; sum[0] = 1; sum[1] = 1; while(i<10) { sum[i] = sum[i-1] + sum[i-2]; i = i +1; } i = 0; while(i<10) { print_i(sum[i]); i = i+1; } }
C
#include <stdio.h> #include <stdlib.h> #include "prio.h" int main() { struct FP P; P = prio_creer_vide(); prio_affiche(P); P = prio_inserer(P, 1, 102); prio_affiche(P); P = prio_inserer(P, 2, 12); P = prio_inserer(P, 3, 48); P = prio_inserer(P, 4, 36); P = prio_inserer(P, 5, 12); P = prio_inserer(P, 6, 1...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* export_utility_two_support.c :+: :+: :+: ...
C
#include<stdio.h> int main(void) { int max,min,n; int tmp,i,s[100]; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d",&s[i]); } max=s[0]; min=s[0]; for(i=1;i<n;i++){ if(max<s[i]) max=s[i]; if(min>s[i]) min=s[i]; } tmp=max-min; printf("%d\n",tmp); return 0; } ./Main.c: In fun...
C
#include <stdio.h> #include<stdlib.h> #include "answer11.h" // -------------------------------------------------------------------- HuffNode /** * A Huffman coding tree. We must implement two small functions... * * (1) HuffNode_create(value); // create a new HuffNode * (2) HuffNode_destroy(tree); ...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <errno.h> #include <unistd.h> #include <signal.h> #include <fcntl.h> void set_fl(int fd,int flag) { int oldflag=fcntl(fd,F_GETFL); int newflag=flag|oldflag; if(fcntl(fd,F_SETFL,newflag)<0) { fprintf(stderr,"fcntl: %s\n",strerror(errno)); exit(1...
C
#include "lcd.h" void main(void) { LCD_Initialize(); while (1) { for(char i = 0; i < 100; i++){ LCDGoto(0, 0); LCDPutChar(i/10 + 48); LCDGoto(1, 0); LCDPutChar(i%10 + 48); for(char j = 0; j < 5; j++) __delay_ms(5...
C
#if 0 static const struct { //must do linear search on these const unsigned char *magic; MIMEtype type; unsigned short len; unsigned short offset; } extra_mimes[]={ {"Microsoft Word 6.0 Document",(MIMEtype){"application","msword"},27,2080}, {"Documento Microsoft Word 6",(MIMEtype){"application","msword"},26,2080}, {"Mi...
C
#include "word.h" char* int2word(mpz_t nb, char* charset, int base, char* word) { //printf(" == %d : %s : %d == ", base, charset, nb); int i = 0; int t = 0; int k = 0; int nb_char= 0; int start = 0; mpz_t tmp, tmp2, tmp3, inf, number; mpz_init_set(number, nb); mpz_init_set(tmp, nu...
C
#include <stdio.h> #include <stdlib.h> #include <cs50.h> #include <string.h> #include <ctype.h> void encrypt(string, int k); int main (int argc, char* argv[]) { int k; /*Get the command line-argument and convert from string to int If no argument is provided return 1 and printf error message*/ ...
C
#include <stdio.h> #include <string.h> //For strlen #include <mpi.h> //For MPI functions #define MAX_STRING 100 int main(void) { char greeting[MAX_STRING]; int comm_size; int my_id; MPI_Init(NULL,NULL); MPI_Comm_size(MPI_COMM_WORLD,&comm_size); MPI_Comm_rank(MPI_COMM_WORLD,&my_id); if(my_id != 0) { sprin...
C
#include "monty.h" /** *pall - print all the stack *@stack: pointer to the top element *@line_number: line number *Return: void */ void pall(stack_t **stack, unsigned int line_number) { stack_t *st = *stack; while (st != NULL) { printf("%d\n", st->n); st = st->next; } (void) line_number; } /** *pint - print...
C
#include<reg51.h> #define smotor P2 void wiper(); void delay(unsigned int d); sbit rain_sensor=P1^0; void main() { rain_sensor=1; //making as input port smotor=0x00; for(;;) { while(rain_sensor==1); //wait till the rain is not present wiper(); //run the motor } } void wiper() ...
C
#include <stdarg.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include "bano_html.h" #include "bano_perror.h" static int resize_data(bano_html_t* html, size_t size) { const size_t new_size = (size + 0x1000) & ~(0x1000 - 1); void* co...
C
/* ** EPITECH PROJECT, 2021 ** number_generator.c ** File description: ** number_generator */ #include "../include/helper.h" #include "../include/my.h" asciiart *number_generator(void) { asciiart *ascart = malloc(sizeof(asciiart)); ascart->zero = zero(); ascart->one = one(); ascart->two = two(); ...
C
#include <stdio.h> void imprimirJogadores(int i, int n, int jogador[]) { if (i < n) { printf("%d\n", jogador[i]); imprimirJogadores(i+1, n, jogador); } } int decomporTabuleiro(int casa, int n) { if(n > casa) { return casa; } else{ return decomporTabuleiro(casa-...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #define PI 3.14 #define R 2 #define S PI * R * R #define AREA(r) PI * r * r #define ADD(a, b) a + b #define MUL(a, b) ((a) * (b)) /* *#define MAX(a, b) do{ \ * if (a > b) \ * { \ * ...
C
#include <avr/io.h> #include <avr/interrupt.h> #include <util/delay.h> #define F_CPU 1000000UL #define BAUD 2400 #define BAUDRATE ((F_CPU)/(BAUD*16UL)-1) // define posible commands we can recieve via UART #define READ_0 ((unsigned char) 0) #define READ_1 ((unsigned char) 1) #define READ_2 ((unsigned char) 2) #define ...
C
#include <stdio.h> #include <stdlib.h> /** numĵַõֵַָһ */ void change(int *num) { // nummainеnumͬһ // ļһӰmainеnum *num += 1; } int main(void) { int num = 9; change(&num); // ú printf("num = %d\n", num); // Ϊ10 return (0); }
C
#include <stdio.h> #include <string.h> int main(void) { printf("hello!\n"); printf("\033[1mhello!\033[0m\n"); printf("\033[4mhello!\033[0m\n"); printf("\033[31;42mhello!\033[0m\n"); /* *printf("ESC[2Ihello![0I\n"); *printf("\033[3Ihello!\033[0I\n"); */ return 0; }
C
#include <stdio.h> int main() { char *chessboard [8][8]; for (int i=0;i<8;i++) { for (int j = 0; j<8;j++) { if (i==0 || i==7) { switch (j) { case 0: case 7: chessboard[i][j] ="R"; break; case 1: case 6: che...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <mpi.h> #include "misc.h" #include "hotplate.h" #define WIDTH 768 #define HEIGHT 768 #define MSG_SLICE_START 0 #define MSG_SLICE_END 1 #define MSG_DONE 2 int nproc, iproc; Hotplate *plate; int main(int argc, char *argv[]) { int iter = 0; do...
C
#include <stdio.h> int main(int argc, char const *argv[]) { int i,count,distancia,vezes,k,step,matriz[100]; scanf("%d",&count); for (i = 0; i < count; i++) { scanf("%d %d",&distancia,&vezes); for (k = 0; k < vezes; k++) { scanf("%d",&step); matriz[k]=step; } k=0; if(matriz[0]...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_next_line.c :+: :+: :+: ...
C
#include "sort.h" /** * insertion_sort_list - sorts a double linked list * of integers in ascending order * @list: list listint_t * Return: Void */ void insertion_sort_list(listint_t **list) { listint_t *l_list = NULL; listint_t *a = NULL; listint_t *b = NULL; listint_t *tmp = NULL; listint_t *tmp_1 = NULL; ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define LIM 40 char * s_gets(char *st, int n); void search(char *str); int main() { char *input[LIM]; printf("Enter a string less than %d: \n", LIM); gets(input); search(input); return 0; } char * s_gets(char *st, int n) { char ret_val...
C
/* * gmem.h * * Memory routines with out-of-memory checking. * * Copyright 1996-2003 Glyph & Cog, LLC */ #ifndef GMEM_H #define GMEM_H #include <stdio.h> #ifdef __cplusplus extern "C" { #endif /* * Same as malloc, but prints error message and exits if malloc() * returns NULL. */ extern void *gmalloc(int si...
C
#include "binary_trees.h" /** * binary_tree_depth - function that measures the depth * of a node in a binary tree. * @tree: pointer to the node to measure the depth. * Return: 0 if tree is NULL */ size_t binary_tree_depth(const binary_tree_t *tree) { size_t count = 0; if (tree == NULL) { retur...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* parse_pointers.c :+: :+: :+: ...
C
#include<stdio.h> #include<conio.h> void main() { int n,k; printf("enter the celsius:"); scanf("%d",&n); k=n+273.5; printf("\n%d",k); }
C
/** @file icm20948.h @author Andre Renaud @date July 2020 @brief Interface routines for the ICM 20948 IMU chip */ #ifndef ICM20948_H #define ICM20948_H #ifdef __cplusplus extern "C" { #endif #include <stdbool.h> #include "config.h" #include "twi.h" /** Define datatype for handle to ICM20948 functi...
C
// mysh.c ... a small shell // Started by John Shepherd, September 2018 // Completed by Yuancong, July 2020 #include <stdlib.h> #include <stdio.h> #include <string.h> #include <ctype.h> #include <signal.h> #include <sys/wait.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #include <glob.h> #include...
C
#include <stdio.h> int main(){ //int n,fatorial; int n; int fatorial=1; printf("Insira um inteiro positivo:\n" ); scanf("%d",&n); while(n>1){ fatorial=fatorial*n; n--; //ou n=n-1; } printf("O fatorial do numero inserido e %d\n",fatorial ); return 0; }
C
#include<stdio.h> #include<stdlib.h> // Use a linked list for no particular reason, i just wanted to use a linked list typedef struct node{ char data; int count; struct node * next; }node; void add(node * head, char c){ while(head->next != NULL){ if(head->data == c) break; h...
C
#include <stdio.h> int main() { int numero, qtdhrstrab; float valorhora, salario; scanf("%d", &numero); scanf("%d", &qtdhrstrab); scanf("%f", &valorhora); salario = (qtdhrstrab * valorhora); printf("NUMBER = %d\n", numero); printf("SALARY = U$ %0.2f\n", salario); return 0; }
C
// LinkList.cpp // 30.12.2020 #include<stdio.h> #include<process.h> #include<stdlib.h> struct node{ int info; struct node* link; }; struct node* start=NULL; void create(); void traverse(); void insert_beg(); void insert_last(); void insert_after(); void delete_beg(); void delete_last(); void delete_after(); v...
C
#include "holberton.h" /** * is_all_digits - checks to see if all characters in a string are digits * @s: string to check * Return: 1 if all chars are digits, 0 otherwise */ int is_all_digits(char *s) { int i = 0; while (s[i]) { if (s[i] < 48 || s[i] > 57) return (0); i++; } return (1); } /** * buil...
C
#include "../../inc/koala.h" /** ** Create a token of a pipe **/ int tokenize_pipe(char **tok, t_que **lex) { if (*tok) { if (**tok != '\0') push_que(0, *tok, lex); free(*tok); (*tok) = NULL; } (*tok) = ft_strdup("|"); if (!(*tok)) exit(1); if (*tok) { push_que(0, *tok, lex); free(*tok); (*t...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* stalkcursor.c :+: :+: :+: ...
C
#include "BCDCompute.h" byte BCDaddOne(byte BCDvalue, byte BCDmin, byte BCDmax) { if (BCDvalue >= BCDmax) return BCDmin; if (BCDvalue < BCDmin) return BCDmin; if ((BCDvalue & 0xF) != 9) BCDvalue++; else BCDvalue = (BCDvalue & 0xF0) + 0x10; return BCDvalue; } byte BC...
C
// WAP to SUM two numbers entered through keyboard by using a suitable user // defined function (say SUM) for addition operation. // (By using Category-1: Function taking arguments and returns value) #include<stdio.h> int SUM(int, int); //Function Prototype or Function Declaration int main() { int a, b, c; prin...
C
/* * Clientes_lib.c * * Created on: 10 oct. 2019 * Author: alumno */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdio_ext.h> #include "Clientes_lib.h" int hardCodeClientesList(Cliente list[], int length) { list[0].id=1; strncpy(list[0].nombre,"Hycite SRL",length); strncpy(list...
C
#include <stdio.h> int main(){ char board[20][20]; int q; scanf("%d", &q); while(q--){ for(int i = 0; i < 15; i++) scanf("%s", board[i]); char winner = 'n'; for(int i = 0; i < 15; i++){ for(int j = 0; j < 15; j++){ if(board[i][j] != '.'){ ...
C
int main(int argc, char *argv[]); __size32 fib(int param1); /** address: 0x100004bc */ int main(int argc, char *argv[]) { int g3; // r3 int g3_2; // r3{12} int g5; // r5 int local0; // m[g1 - 24] printf("Input number: "); g5 = scanf("%d", &local0); /* Warning: also results in %g6, %g7,...
C
void call_interrupt(uint8_t PIN) { detachInterrupt(digitalPinToInterrupt(PIN)); } void call_interrupt(uint8_t PIN, void (*isr)) // przesłanie funkcji jako parametru { attachInterrupt(digitalPinToInterrupt(PIN), isr, FALLING); } void read_rpm_seeder() { rpm_seeder_read_window_time_now = milli...
C
/* chapter 27 exercise 1 page 1033 */ #include <stdio.h> #include <stdlib.h> size_t jd_strlen(const char* p) { if (p == 0) return 0; const char* last = p; while (*last) last++; return last - p; } int jd_strcmp(const char* s1, const char* s2) { while (*s1 == *s2 && *s1 != 0 && *s2 != 0) { s1++; s2++; } ...
C
#include <stdio.h> int main() { //定义整型 int num; int num = 5; //定义长整型 long long bignum; long long bignum = 123456789012345LL //longlong赋初值>2^31-1需要加上LL //定义无符号型 unsigned int a1; unsigned long long a2; //定义单精度浮点型 有效精度6-7位 float fl; float fl = 3.1415; //定义双精度浮点型 有效精度15-16位 doub...
C
#include "eqg_types.h" uint32_t eqg_skip_materials(uint8_t* data, uint32_t length, uint32_t count) { uint32_t p = 0; uint32_t i; for (i = 0; i < count; i++) { EQGMaterial* mat = (EQGMaterial*)(data + p); p += sizeof(EQGMaterial); if (p > length) return 0x...
C
#include "CUDAArray.h" #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <float.h> #include <stdlib.h> #include <stdio.h> #ifndef CONVOLUTION_HELPER #define CONVOLUTION_HELPER int defaultThreadCount = 32; // GPU FUNCTIONS __global__ void cudaArrayAdd(CUDAArray<float> source, CUDAA...
C
int main(void) { int Counter=0, k; int number[5]; int seed=0; while (1) { Counter++; for(k=0; k<5; k++) { number[k]=0; number[k]=rand(seed)% 2; } } }
C
// Does not require a separate prototype #include <stdio.h> float getNumber() { float x; printf("Enter a number: "); scanf("%f", &x); return x; } int main() { float i; i = getNumber(); printf("%f\n", i); return (0); }
C
#include "circuits.h" #include <stdbool.h> #include <stdlib.h> #include <stdio.h> #include <string.h> /* Used this source - https://www.hackerearth.com/practice/data-structures/linked-list/singly-linked-list/tutorial/ - to help implement struct, addNode and createNode */ //Creates a new node Node createNode(void) { ...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <sys/wait.h> #include <sys/types.h> int main(){ int i=0,status,pid; for(;i<10;i++){ pid=fork(); if(pid>0){ wait(NULL); if(WIFEXITED(status)) printf("Meu filho morreu %d\n",WEXITSTATUS(status)); exit(0); } printf("...
C
/* <SOURCE-LICENSE> [ PA(Peter-Anna) OS ] ======================================== Peter-Anna OS is a real time OS. Peter-Anna OS is made by Peter and Anna. Peter and Anna lives in South Korea. They love each other so much. Peter usually develops ...
C
/* Tiny helper function library ============================ TOC: * Memory manipulation functions * Character string functions License (BSD-2) =============== Copyright (c) 2013, Gusts 'gusC' Kaksis <gusts.kaksis@gmail.com> All rights reserved. Redistribution and use in source and binary forms, with or without m...
C
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> void getNeighbors(int n, int i, int* n1, int* n2) { if(i == 0) { *n1 = n - 1; *n2 = 1; } else if(i == n - 1) { *n1 = n - 2; *n2 = 0; } else { *n1 = i - 1; *n2 = i + 1; } } bool isPeak(int value, int n1, int n2) { if((n1 > value && n2 > value...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include "spell-checker_data.h" /** * A Trie implementation to hold the dictionary data. * * See https://en.wikipedia.org/wiki/Trie for a description of a Trie. * * TODO: Extract the implementation out, put into specific implementation file, * to easily...
C
/** * @file pgm.c * @brief Funções relativas à leitura dos ficheiros pgm * @author Emanuel João Conceição Lopes <2140825@student.estg.ipleiria.pt> */ #include "pgm.h" #include "debug.h" #include "errors.h" #include "common.h" #include "memory.h" /** * @brief abreo o ficheiro pgm * @details [long description] * * ...
C
#include <stdio.h> #define ALPHABET_SIZE 256 /* count char frequencies */ main() { int alphabet[ALPHABET_SIZE]; for (int i = 0; i < ALPHABET_SIZE; i++) { alphabet[i] = 0; } int c; while ((c = getchar()) != EOF) { if (c == ' ' || c == '\t' || c == '\n') { /* skip */ ...
C
#include "parseheader.h" #include "httpd.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> /*implemetation the HTTP header *fd is a file content the header info */ void parse_header(int fd) { char buf[512]; /*---------a modifier-------getline is not pratice to use*/ ssize_t headernu...
C
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* * File: main.c * Author: Admin * * Created on 11 de abril de 2020, 11:21 */ #include <stdio.h> #include <stdlib.h> #includ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_next_line2.c :+: :+: :+: ...
C
/* ID: southp01 LANG: C TASK: frac1 */ #include <stdio.h> #include <string.h> #define MAX_D 160 struct frac { int n; /* numerator */ int d; /* denominator */ float val; }; int cmp_frac(const void *a, const void* b) { const struct frac* fa = a; const struct frac* fb = b; float diff = fb->val...
C
//5. Write a C program to print all odd number between 1 to 100. #include<stdio.h> int main() { int i; printf("All ODD Numbers between 1 to 100\n"); for(i=1;i<=100;i++) { if(i%2!=0) printf("%d ",i); } return 0; }
C
/* newClones - Find new clones. */ #include "common.h" #include "linefile.h" #include "hash.h" #include "cheapcgi.h" #include "obscure.h" static char const rcsid[] = "$Id: newClones.c,v 1.3 2003/05/06 07:22:30 kate Exp $"; void usage() /* Explain usage and exit. */ { errAbort( "newClones - Find new clones\n" "usa...
C
#include<stdio.h>//二叉树的顺序存储结构 #include<stdlib.h> #include"SeqStack.h" #define MaxTreeNodeNum 100 typedef int DataType; void Visit(int t) { printf("%d",t); } typedef struct { DataType data[MaxTreeNodeNum]; int n; }QBTree; typedef struct bonde{ DataType data; struct bonde *lchild,*rchild; }Bonde,*BT...
C
#include <stdlib.h> #include <stddef.h> #include <pthread.h> #include <stdarg.h> #include <stdio.h> #include <math.h> #include <string.h> #include <signal.h> #include <unistd.h> #define MAXLINE 4096 #define DEFAULT_THREADCOUNT 10 #define DEFAULT_SAMPLESIZE 100 #define ERR(source) (perror(source),\ fprintf(stde...
C
#include <stdlib.h> #include <stdio.h> double m(double *x, int n) { double a, b; int i=0; a=x[1]; for (i = 0; i< n; ++i) { if (a<x[i]){ a=x[i]; } } b=x[1]; for (i = 0; i< n; ++i) { if (b>x[i]){ b=x[i]; } } return a - b; } int main() { double s; int n; int i=0;...
C
#include "processamento.h" int hora_de_mover_tiro_canhao(J* jogo) { if (jogo->contador_tempo % 2 == 0) return 1; else return 0; } int hora_de_mover_tiro_alien(J* jogo) { if (jogo->contador_tempo % 6 == 0) return 1; else return 0; } void processa_lista(J* jogo, char input) /* processa todos os elementos d...
C
#include<stdio.h> int arr[8] = { 15,22,13,27,12,10,20,25 }; typedef struct Node{ int data; struct node *next; }node; typedef struct queue{ node *front; node *rear; int count; }Queue; void InitQueue(Queue *q) { q->count = 0; q->front = NULL; q->rear = NULL; } int IsEmpty(Queue *q) { return (q->...
C
/* ** change_line.c for in /home/fernan_w/Téléchargements/backup/readline ** ** Made by ** Login <fernan_w@epitech.net> ** ** Started on Thu Jun 2 23:15:23 2016 ** Last update Sun Jun 5 19:13:25 2016 retyt */ #include <unistd.h> #include "readline.h" #include "my.h" static int write_line_up(char *str) { int ...
C
#include <stdio.h> //정수 한 개 입력받아 아스키 문자로 출력하기 int main(void) { int a; scanf("%d", &a); printf("%c", a); }
C
#include<stdio.h> int id[20],completed[20],arrivalTime[20],burstTime[20],ct[20],tat[20],wt[20]; int n,t=0,noOfCompletedProcess=0,i; void print_table() { float avgWT=0,avgTAT=0; printf("\n\n\n\n\n"); printf("\n|---------------------------------------------------------------------------|"); pr...
C
#include <avr/io.h> #include "pacer.h" static uint16_t pacer_period; /* Initialise the pacer module. */ void pacer_init (uint16_t pacer_frequency) { /* TODO: initialise timer/counter peripheral the same way as in lab2/lab2-ex2/timer.c but also calculate the timer/counter value from the pacer frequ...
C
#include "stack.h" void init(){ start = NULL; } int push(unsigned int n){ t_node *p = start; start = (t_node*)malloc(sizeof(t_node)); if(!start){ return 1; } start->data = n; start->next = p; return 0; } int pop(unsigned int *n){ if(start){ ...
C
// Sorting integers with bubble sort void printarr(int*, int); void bubblesort(int* arr, int size){ // 'Bubble' up the largest element to the last position for(int i = size-1; i>=0; --i){ int tmp; for(int j=1; j<=i; ++j){ // Swap if(arr[j]<arr[j-1]){ tmp = arr[j-1]; arr[j-1] = arr[j]; ...
C
/*** Timer handling APIs ***/ /************************************************************************ * * This file contains the definitions of functions concerned with the * handling of timers in Nucleus SE: * * NUSE_Timer_Control() * NUSE_Timer_Get_Remaining() * NUSE_Timer_Reset() * NUSE_Timer_Informat...
C
#include<stdio.h> long add(int n , int d) { int c = n/d -( n%d==0) ; return (long)d * c*(c+1)/2 ; } int main() { int t , n , i,c; long int sum; scanf("%d",&t); while(t--) { fflush(stdin); scanf("%d",&n); sum = 0; sum+=add(n,3); sum+=add(n,5); sum-=add(n,15); printf("%ld\n",sum...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/msg.h> #include <unistd.h> /*--------------------------------------------------------------*/ #define N 1000000 #define CHAVE 6 /*---------------------------------------------------------*/ struct msg{ long tipo; int gc;...
C
#include <stdio.h> #include <stdlib.h> #include "persona.h" #define CPAIS 6 void menu(ePersona pers[], int cant){ ePais pais[6] = {{0,"Argentina"},{1,"Uruguay"},{2,"Brasil"},{3,"Chile"},{4,"Peru"}, {5,"Paraguay"}}; int opc; do{ printf("1)Ingresar alta de una persona.\n2)Dar de baja a una p...
C
/* MIT License Copyright (c) 2018 Viviano Riccardo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files ((the "LICENSE")), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publi...
C
/* for drawing */ /* by shindow(liuyu_200411@sina.com) */ /* 2010.4.1 setup */ #include "type.h" #include "const.h" #include "lib.h" #include "protect.h" #include "global.h" //0H--ɫ,1H--ɫ,2H--ɫ,3H--ɫ,4H--ɫ,5H--,6H--ɫ,7H--ɫ //8H--ɫ(˸),9H--ɫ(˸),AH--ɫ(˸),BH--...
C
/****************************************************************************** * File Name : packet_search.c * Date First Issued : 06/01/2014 * Board : PC * Description : Search packets *******************************************************************************/ #define _LARGEFILE64_...
C
#ifndef __QXWZ_SOC_H #define __QXWZ_SOC_H #include <stdlib.h> #include <stdint.h> #define QXWZ_SOCKET_DATA_CACHE_LEN 1024//socketݰС typedef int qxwz_ssize_t; typedef int8_t qxwz_soc; typedef struct { char *hostName; short port; }qxwz_soc_address;//ӵַ /** * һTCP(***ʵ***) * @return tcpͨ */ qxwz_soc qxwz_s...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "heap.h" void HeapSort1(int *values, int dimVect) { int i; HeapVector *h = CreazaVector(values, 0, dimVect); for (i = 0; i < dimVect; i++) AdaugaValoareMinHeap(h, values[i]); for (i = 0; i < dimVect; i++) values[i] = ExtrageMinim(h); E...
C
#ifndef ARRAY_H #define ARRAY_H struct Array{ unsigned int width; //size in bytes of each elem in array unsigned int nel; //number of elements in array unsigned int capacity; //total number of elements that can be stored in the array void *data; //pointer to the conten...
C
#include "btlin_basic.h" #include <stdio.h> #include <stdlib.h> #include <math.h> #include <ctype.h> // Copy double* btlin_matrix_newcopy(double* a, int m, int n) { double *ret,*p; int i,size; size = m*n; ret = (double*)malloc(sizeof(double)*size); // Alternatives: Copy in chunks (2^n blocks) p = ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> void reverse (char*, int, int); void reverseStmt (char *str) { int len = strlen(str); int start = -1; int i; reverse(str, 0, len); printf("\nReversed string is %s\n", str); for (i = 0; i < len; i++) { if ( (start != -1) && (str[i] == ' ') ) { ...
C
#include"prototypes.h" struct node *start=NULL; int data,item,pos; struct node *last=NULL; void singly_linked_list() { system("cls"); system("COLOR F2"); while(1) { system("cls"); gotoxy(35,3); printf("\xDB\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2 SINGLY LI...
C
/* Problem Statement: Write a program to divide two numbers */ //header file for input output functions #include<stdio.h> //macro definitions #define TRUE 1 #define FALSE 0 //creating a typedef typedef int BOOL; //Function definition for dividing two numbers BOOL DivideNumbers(int num1, int num2, float *answer) { if...
C
/* Ultrasonic Range Finder */ /* For a HC-SR04 Ultrasonic Sensor */ /* It sends a 10us pulse to start ranging (3.3V tolerant) */ /* Then it receives back a 5V pulse from 150us-38ms */ /* the distance can be calculated based on the width of */ /* the pulse. i.e. time/148 = distance in inches */ /* Th...
C
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include "tmm_check.h" /* This is the prototype for the function you have to pass to be called. * * Two options are available to you: * * 1) Using 2D matrices * * A, B and C are created as double-dimension arrays (float**) * where: * - A[i] is a poi...
C
#include<stdio.h> int main() { int money,num=0,a=0,m; printf("请输入要买的钱数:"); scanf("%d",&money); //printf("\n请输入个m空瓶可兑换一个瓶子:"); //scanf("%d",&m); //num = money; while(money>=1) { a = money%2; //money = money/2; num += money+a; money = money/2; } printf("最多可喝到%d瓶汽水\n",num); return 0; }
C
/* Blinky with a button. An LED is attached to Pin 25 and a button is attached to Pin 1 When the button is pressed, the LED should blink */ #include "lpc111x.h" void delay(unsigned len) { while(len--); } void ConfigPins() { SYSAHBCLKCTRL |= BIT6 + BIT16; // Turn on clock for GPIO and IOCON IOCON_PIO0_2 &= ~(B...
C
#include "usart.h" void USART_Configuration(void) { USART_InitTypeDef USART_InitStructure; USART_InitStructure.USART_BaudRate = 115200; //??USART?????? USART_InitStructure.USART_WordLength = USART_WordLength_8b; //8???? USART_InitStructure.USART_StopBits = USART_StopBits_1; //??????????????? USART_InitStruc...
C
/** * @file: k_msg.c * @brief: kernel message passing routines * @author: Yiqing Huang * @date: 2020/10/09 */ #include "k_msg.h" #ifdef DEBUG_0 #include "printf.h" #endif /* ! DEBUG_0 */ int k_mbx_create(size_t size) { #ifdef DEBUG_0 printf("k_mbx_create: size = %d\r\n", size); #endif /* DEBUG_0 */ ...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <stdio.h> #include <string.h> #include <sys/time.h> #include <time.h> #define SHORT 0; #define LONG 1; #define STANDARD 2; void sampleLoadAvg(char lineBuf[256], int LB_SIZE, int iteration, int interval); //Sample the load avg int main(int argc, char...
C
#include "imu.h" /** * @brief * * @param x * @param y * @param z * @param samples */ void avg_mag(float *x, float *y, float *z, char samples) { float tx,ty,tz; *x =0; *y=0; *z=0; float fsamp = (float)samples; for (char i = 0; i < samples; i++) { read_mag(&tx,&ty,&tz); *x = *x + (tx/fsamp); *y =...
C
/* Write a program which accept one number from user and check whether 9th or 12th bit is on or off. Input : 257 Output : TRUE iMask1: 0000 0000 0000 0000 0000 0001 0000 0000 0X00000100 iMask2: 0000 0000 0000 0000 0000 1000 0000 0000 0X00000800 */ #include<stdio.h> typedef int BOOL; #define TRUE 1 #define FALSE 0 ...