language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> int main(void) { int Ingresso = 1; int Idade = 22; if (!Ingresso) printf("Você não tem ingresso!\n"); if (Idade < 18) printf("Você é menor de idade!\n"); if (!Ingresso || Idade < 18) printf("Você não pode entrar!\n"); if (Ingresso && Idade >= 18) ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_stack.c :+: :+: :+: ...
C
/****************************************************************************** * FILE: omp_bug2.c * DESCRIPTION: * Another OpenMP program with a bug. * AUTHOR: Blaise Barney * LAST REVISED: 04/06/05 ******************************************************************************/ /**********************************...
C
#ifndef TH_GENERIC_FILE #define TH_GENERIC_FILE "THNN/generic/LogSigmoid.c" #else void THNN_(LogSigmoid_updateOutput)( THNNState *state, THTensor *input, THTensor *output, THTensor *buffer) { THTensor_(resizeAs)(output, input); THTensor_(resizeAs)(buffer, input); //Use the...
C
#include <math.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <assert.h> #include <limits.h> #include <stdbool.h> int main() { int n,tot; int k,i,s=0; scanf("%i %i", &n, &k); int *ar = malloc(sizeof(int) * n); for(i = 0; i < n; i++){ scanf("%i",&ar[i]); } ...
C
#include "C:\Keil_v5\ARM\PACK\Keil\TM4C_DFP\1.1.0\Device\Include\TM4C123\TM4C123GH6PM.h" #include <string.h> #include <stdlib.h> char readChar(void); void printChar(char c); void printString(char * string); char* readString(char delimiter); //void SystemInit(); int main(void) { // 1. Enable the UART0 ...
C
#include <stdio.h> #include <cs50.h> int main(void) { // TODO: Prompt for start size int height; do { height = get_int("height of pyramid: "); } while (height > 8 || height < 1); int i; int j; int d; for (i = 0; i < height; i++) { for (d = height - 1; d > i; d--) ...
C
#include <string.h> #include "application.h" struct app_entry_t *new_app_sig(int id, char *sig) { struct app_entry_t *entry; if (strlen(sig) >= MAX_SIG_LENGTH) return NULL; entry = (struct app_entry_t *)malloc(sizeof(struct app_entry_t)); if (entry) { entry->appId = id; strcpy(entry->regex, sig); } ret...
C
#include <stdio.h> int main() { int a[7] = {3, -355, 235, 47, 67, 943, 1222}; int i; int *ptr; ptr = a; for (i = 0; i < 5; i++) printf("%p\n", ptr[i]); return 0; }
C
#include <stdint.h> #include <stdio.h> #include <string.h> typedef uint8_t u8; static void hexdump(u8 *ptr, unsigned len, int bytes); u8 mem[0x20] = { 0, }; int main(void) { memset(mem, 0xf, sizeof(mem) - 2); // hexdump(mem, sizeof(mem), 0); int i; u8 A = 5; int carry = 1; for (i = 0; i < s...
C
#include <stdio.h> int main() { int n = 100; int *p; p = &n; printf("%p\n", p); printf("%d\n", n); printf("%d\n", *p); }
C
/* chvt.c - change virtual terminal for [k]freebsd Copyright (C) 2009 Werner Koch This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without modifications, as long as this notice is preserved. This file is distributed in the ho...
C
#include<stdio.h> int main() { int a,b,sum; a=123; b=456; //a>b?printf("a"):printf("b"); sum=a+b; printf("sum is %d\n",sum); return 0; }
C
#include <stdio.h> int sum_of_natural_numbers(int n) { if(n == 0) return 0; return n + sum_of_natural_numbers(n - 1); } int main() { int n; printf("\nEnter the number : "); scanf("%d", &n); printf("\nSum of first %d Natural Numbers is %d\n",n,sum_of_natural_numbers(n)); return 0; }
C
#include<stdio.h> #include<stdbool.h> void DisplaySchedule(char); int main() { char ch = '\0'; printf("Enter division "); scanf("%c",&ch); DisplaySchedule(ch); return 0; } void DisplaySchedule(char c) { if(c=='A'||c=='a') { printf("Your exam is at 7 AM "); } else if(c=='B'||c=='b...
C
#include<stdio.h> #include<string.h> int main() { char a[105], b[105]; int i; scanf("%s %s", &a, &b); for(i=0; i<strlen(a); i++) { if(a[i]<95) {a[i]+=32;} if(b[i]<95) {b[i]+=32;} } i = strcmp(a, b); printf("%d", i); }
C
#include<stdio.h> float celsiusToFahren(int a, int b, int c); int main() { float e; e = celsiusToFahren(0, 1.8, 32); return 0; } float celsiusToFahren(int a, int b, int c) { float e; e = (float) (a * b) + c; printf("The result is:%.2f", e); return e; }
C
#include <stdio.h> void main() { int *a1,*a2,*a3; triangle(); printf("area of triangle= %d",a1); rectangle(); printf("area of rectangle= %d",a2); square(); printf("area of square= %d",a3); } int triangle() { float *l,*b,int *a1; *a1=(1/2)*l*b; } void rectangle() { int a=5,b=10,a2; ...
C
#ifndef _TTY_H #define _TTY_H #include <termios.h> #define TTY_BUF_SIZE 1024 //队列大小 struct tty_queue { unsigned long data;//缓冲区中字符行数 unsigned long head; unsigned long tail; struct task_struct * proc_list;//该队列中的阻塞进程列表 char buf[TTY_BUF_SIZE];//队列缓冲区 }; /** * 注意:队列的头是不放数据的 */ #define INC(a) ((a) = ((a)+1) & (TT...
C
#include<stdio.h> void main() { int i; for(i=0;i<=10;i++) { printf("saranteja\n"); } i=1; while(i<=10) { printf("saranteja\n"); i++; } i=1; do { printf("saranteja\n"); i++; }while(i<=10); }
C
/* NOTE: program run with ./ReaderWriters ricr ricb roocr roocb wicr wicb woocr woocb nr nw • ricr is the range parameter for controlling how long readers sleep inside their critical sections • ricb is the base number of nanoseconds a reader will sleep inside their critical sections • roocr is the range parameter fo...
C
/* ףһ 2004240205 (궨) */ #include<stdio.h> #define M(a,b) (a>b?a:b) #define MAX(a,b,c) (M(a,b)>c?M(a,b):c) int main() { int a,b,c; scanf("%d%d%d",&a,&b,&c); printf("%d",MAX(a,b,c)); return 0; }
C
/* CSC D84 - Unit 1 - Search This file contains stubs for implementing the different search algorithms covered in the course. Please read the assignment handout carefully - it describes the game, the data you will have to handle, and the search functions you must provide. Once you have read the handout carefull...
C
/* * MemoryManage.h * * Created on: 2020年2月22日 * Author: LuYonglei */ #ifndef SRC_MEMORYMANAGE_H_ #define SRC_MEMORYMANAGE_H_ #include <stdlib.h> #include <stdint.h> #include "task.h" /* 字节对齐数 字节对齐掩码 * 8 0x0007 * 4 0x0003 * 2 0x0001 * 1 ...
C
/** \file adc1.c \author G. Icking-Konert \date 2013-11-22 \version 0.1 \brief implementation of ADC1 functions/macros implementation of functions for ADC1 measurements in single-shot mode */ /*----------------------------------------------------------------------------- INCLUD...
C
#include<stdio.h> #include<stdlib.h> #include <locale.h> // 2) Faa uma funo recursiva que calcule e retorne o N-simo termo da sequncia // Fibonacci. Alguns nmeros desta sequncia so: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89... void fibonacci(int num){ int x = num; int vetorAux[x]; int i; vetor...
C
#include "pcm_alsa.h" #include<stdio.h> #include<stdlib.h> #include<unistd.h> #include<sys/types.h> #include<sys/stat.h> #include<fcntl.h> //wav 文件头数据结构 #define ID_RIFF 0x46464952 #define ID_WAVE 0x45564157 #define ID_FMT 0x20746d66 #define ID_DATA 0x61746164 #define FORMAT_PCM 1 #define fix_min_m...
C
#include<stdio.h> #include<unistd.h> #include<pthread.h> #include<stdlib.h> int data = 0; void taska() { int i = 0; for (i=3; i>0; i--) { data = data + i; printf("data = %d\n", data); sleep(2); } return; } void taskb() { int i = 0; for (i=7; i>0; i--) { data = data + data*i; sleep(1); } return; } ...
C
#include<stdio.h> int main() { FILE *f1; char c; f1 = fopen("input.txt","w"); //input.txt while( (c=getchar()) !=EOF) //EOF input Ѵ putc(c,f1); fclose(f1); f1=fopen("input.txt", "r"); // о´ while( (c=getc(f1)) !=EOF) //EOF Ͽ ڸ о printf("%c",c); fclose(f1); getchar(); return 0; }
C
#include <stdio.h> int main(void) { enum Color {red, green, blue = 10, yellow}; //给枚举常量的第一个值赋值 enum Color rgby; printf("red = %d\n", red); printf("green = %d\n", green); printf("blue = %d\n", blue); printf("yellow = %d\n", yellow); return 0; }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_pythagore.c :+: :+: :+: ...
C
/** * \file abin.c */ #include "abin.h" /* #define N int #define F double typedef struct s_noeud { N op; F val; bool unaire; struct s_noeud *fg, *fd; } noeud, *abin; */ /** * \fn abin enraciner(T x, abin g, abin d) * \brief enraciner deux arbres * \return la racine */ abin enraciner(N op, F v...
C
#include "stdio.h" int main() { char buf[300]; FILE* fin = fopen("task1.txt", "r"); FILE* fout = fopen("result.txt", "w"); for(int i=0; i<5; i++) { fgets(buf, 200, fin); fprintf(fout,"%s",buf); } do { fscanf(fin, "%154c",buf); buf[154] = '\0'; fprintf(fout, "%s\n",buf); } while( fgets(buf, 300, f...
C
#include <stdlib.h> #include <string.h> #include <stdio.h> #include <stdint.h> #include "chacha20.h" #include "utils.h" const int ROUND_1[] = {0, 4, 8, 12}; const int ROUND_2[] = {1, 5, 9, 13}; const int ROUND_3[] = {2, 6, 10, 14}; const int ROUND_4[] = {3, 7, 11, 15}; const int ROUND_5[] = {0, 5, 10, 15}; const int ...
C
#include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <stdint.h> #include <unistd.h> #include <byteswap.h> #include "fileHeader.h" int printError() { // test perror("main"); return 0; } uint8_t* readFileBackwards(uint32_t size, int sourceFd) { uint8_t* buffer = malloc(size * sizeof(uint8_t));...
C
//SPI master #include <avr/io.h> #include <util/delay.h> //SPI initvoid void SPIMasterInit(void) { //set MOSI, SCK and SS as output DDRB |= (1<<PB3)|(1<<PB5)|(1<<PB2); //set SS to high PORTB |= (1<<PB2); //enable master SPI at clock rate Fck/16 SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR0); } //master send function void S...
C
#include <stdio.h> #include <stdlib.h> #include <locale.h> #include <string.h> #include <math.h> #define TAM 200 typedef struct dados { int codigo, ano, status; float orcamento; char titulo[40], descricao[100], gerente[50], tipo[30], publico[30]; } base_projetos; int contador = 0; int i; int status; void cadas...
C
//########################################################## //## ENSTA Bretagne ## //## Simplified library code for Dynamixel. ## //## Inspiration from ROBOTIS 2015.11.02 ## //########################################################## #include <stdio...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "z_arv_AVL_ED.h" #include "fa_impressao.h" /* inicializa rvore */ int arvAVL_init (char **args) { TipoArvAVL *defn; printf("Processando %s ...\n",args[0]); if (arvAVL != NULL) { fprintf(stderr, "ED: estrutura jah inicializada - delete-a ...
C
/*Accept number from user and input:7585 5 output:2 input:89765 1 o/p: 0 */ #include<stdio.h> int digitfreq(int num,int digit) { int dig=0,cnt=0; if((digit<0)&&(digit>9)) { return 0; } if(num<=0) { num=-num; } while(num!=0) { dig=num%10; if(dig==digit) { cnt++; } num=num/10; } return cnt ; } int main() { int ivalu...
C
#include "message.h" #include <stdlib.h> #include <stdbool.h> #include <string.h> #include <stdio.h> void createNewArray(char** oldMatrix, char** newMatrix, oldMatrixHeight, oldMatrixWidth) { int newMatrixRowIndex = 0; int newMatrixColumnIndex = 0; for(int i = 0 ; i < oldMatrixWidth ; i++, newMatrixRowIndex++) {...
C
#include "LCD_RG1602A.h" #include "Delay.h" #define SET_LCD_E HAL_GPIO_WritePin(LCD_E_GPIO_Port, LCD_E_Pin, GPIO_PIN_SET) #define RESET_LCD_E HAL_GPIO_WritePin(LCD_E_GPIO_Port, LCD_E_Pin, GPIO_PIN_RESET) //BORYS #define SET_LCD_RS HAL_GPIO_WritePin(LCD_RS_GPIO_Port, LCD_RS_Pin, GPIO_PIN_SET) #define RESET_LCD_RS HAL...
C
#include <linux/init.h> #include <linux/module.h> #include <linux/sched.h> #include <linux/init_task.h> #include <linux/kernel.h> MODULE_LICENSE("GPL"); static const char *task_state_array[] = { "R (running)", /* 0 */ "S (sleeping)", /* 1 */ "D (disk sleep)", /* 2 */...
C
#include <stdio.h> int main(void) { int i; printf("%%d\t%%.2f\t%%x\t%%c\n"); for (i = 0; i < 64; i++) { printf("%d\t%.2f\t%x\t%c\n", i, i+0.0, i, (char) i+65); } }
C
// cyclically rotate array by one #include<stdio.h> int crotate(int a[],int size) { int temp,i; temp=a[size-1]; for(i=size-1;i>=1;i--) { a[i]=a[i-1]; } a[0]=temp; //printf("test"); return 0; } main() { int a[20],n,i,ch; printf("Enter the size of the array:\n"); scanf("%d",&n)...
C
/*cccp generate return '\n\tputs("Hello, world!");\n' */ #include <stdio.h> #include <math.h> int main() { /*cccp begin*/ puts("Hello, world!"); /*cccp end 61DD0743*/ /*cccp generate -- Create a sine LUT of length 1000. return '\n\tputs("Need more generation.");\n' */ /*cccp begin*/ puts("Need more generati...
C
/* *Implement popen() and pclose(). Although these functions are simplified by not requiring the signal handling employed in the implementation of system() (Section 27.7), * you will need to be careful to correctly bind the pipe ends to file streams in each process, and to ensure that all unused descriptors referring...
C
/* */ /* RFF.C : Recursive find file utility */ /* */ /* Programmed By Lee jaekyu */ /* ...
C
#include <stdio.h> #include <stdlib.h> /* General Utilities */ #include <unistd.h> #include <sys/file.h> #include <errno.h> #include <fcntl.h> #include <string.h> #define LOGFILE "log.txt" /* Gets a lock of the indicated type on the fd which is passed. The type should be either F_UNLCK, F_RDLCK, or F_WRLCK...
C
// This file is for Step 2. // You should do // Step 2 (A): write seq2 // Step 2 (B): write main to test seq2 // Step 2 (C): write sumSeq2 // Step 2 (D): add test cases to main to test sumSeq2 // // Be sure to #include any header files you need! #include <stdio.h> #include <stdlib.h> int seq2(int x) { int y; if...
C
#include "lists.h" #include <stdlib.h> #include <stdio.h> /** * reverse_listint - main entry, reverse the linked list * @head: pointer to the head of the node * * Return: a pointer to the first node of the reversed list */ listint_t *reverse_listint(listint_t **head) { listint_t *curr; listint_t *prev; prev ...
C
#include<stdio.h> void main() { //ּ : ؼϰ ڵ տ ۼ // 1. ڵ忡 ۼ // 2. ʴ ڵ带 // ּ : ctrl + k + c // ּ Ű : ctrl + k + u /* ּ ڵ带 ּó ϱ ؼ ּ ʿϴ. */ //̸ ϴ κ //printf("ǥ\n"); //̸ ϴ κ //printf("10\n"); }
C
/* ** EPITECH PROJECT, 2020 ** main ** File description: ** main */ #include "minishell.h" void setup_shell(t_shell *mysh, t_env *envi, char **env) { remove_jumpline(mysh->buffer); mysh->clean = clean_str(mysh->buffer, ';'); mysh->opt = my_strtok(mysh->clean, ";"); mysh->args = my_str_to_word_array(my...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_print.c :+: :+: :+: ...
C
/*{{{ includes */ #include "PTMEPT-utils.h" #include "PTMEPT.h" #include <MEPT-utils.h> #include <assert.h> #include <stdlib.h> #include <aterm2.h> #include <string.h> /*}}} */ static ATermTable lowerCache = NULL; /*{{{ static PTPT_Tree lookupTree(PT_Tree tree) */ static PT_Tree lookupTree(PTPT_Tree tree) { i...
C
#include <stdlib.h> #include <stdio.h> #define SIZE 64 struct mnv{ int tnum; int raz; int dnum[SIZE]; }; int main(){ struct mnv num[SIZE]; int i=0, n=0, d=0, vnum; while(d==0){ num[n].raz=0; vnum=0; scanf("%d", &vnum); num[n].tnum=vnum; if(vnum==-1){ d=1; break; } ...
C
/* * Note: git import taken from hellomain.c @ r1821. * * Based on Autotool Tutorial by Alexandre Duret-Lutz (updated: May 16, 2010) * * "Using GNU Autotools", * by Alexandre Duret-Lutz * http://www.lrde.epita.fr/~adl/autotools.html * * Tutorial examples based on: * GNU Autoconf 2.65 * GNU Auto...
C
/* author Sijun Li */ #include "pools.h" void initQ(MqueueDef* const th,int size,uint8_t* data){ th->size = size; th->data = data; th->front = th->rear = 0; } void pushQ(MqueueDef* const th, uint8_t data){ th->data[th->rear++] = data; if(th->rear >= th->size)th->rear = 0; // Discards oldest data; if(th->rear ==...
C
// // Created by CalebBorwick on 2019-11-25. // #include "account.h" #include <stdlib.h> #include <stdio.h> account *createAccount(char typ, int dep, int with, int transf, int transa, int transFee, int over, int bal){ account *new = (account *) malloc(sizeof(account)); new->type = typ; new->deposit = dep; ...
C
#include <stdlib.h> #include <stdio.h> #define SIZE 2000000 float xsum(int l, int r, float* tab) { if(l == r) return tab[l] * tab[l]; int half = (l + r) / 2; return xsum(l, half, tab) + xsum(half+1, r, tab); } int main() { float e = 1.0 / SIZE; float * tab = malloc(SIZE * sizeof(float)); int ...
C
// gcc -o irm1 irm1.c -l bcm2835 -l lirc_client // sudo ./irm1 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <bcm2835.h> #include <lirc/lirc_client.h> // LED3 je na DVK512 pločici na P28 što je pin 20 na BCM-u, // ako se koristi protobord može se // koristiti isti ovaj pin ili neki drugi #define P...
C
#include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <string.h> int size = 1; char* fileName; void* buffer; FILE* file = NULL; int bufferLocation = 2; struct fun { char *name; void (*fun)(char *filename, int size, void *mem_buffer); }; void quit(char *filename, int size, void *mem_buffer) { fclose(f...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include "intsort.h" int main(int argc, char *argv[]){ if (argc != 2) { printf("Expected 2 args, got %d", argc); } /* Open the file.*/ FILE *file = fopen(argv[1], "r"); if (!file) { exit(EXIT_FAILURE); } /* Read, ...
C
// This program simulates the flow of heat through a two-dimensional plate. // The number of grid cells used to model the plate as well as the number of // iterations to simulate can be specified on the command-line as follows: // ./heated_plate_sequential <columns> <rows> <iterations> // For example, to execute with...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* operations.c :+: :+: :+: ...
C
/* * command.h */ #include <stdint.h> #include <stdio.h> #ifndef HASHTABLE_COMMAND_H #define HASHTABLE_COMMAND_H /** * A command type. */ typedef enum command_type { UNKNOWN = 0, INSERT = 1, DELETE = 2, FIND = 3, LIST = 4 } command_type_t; /** * A command. */ typedef struct command...
C
#include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <dlfcn.h> #include "mm.h" #include "memlib.h" #ifdef DRIVER #define malloc mm_malloc #define free mm_free #define realloc mm_realloc #define calloc mm_calloc #endif #define WSIZE 4 #define OVERHEAD 8 #define ...
C
/* * xyprintf.h * * Created on: Oct 30, 2010 * Author: hammer */ #ifndef XYPRINTF_H_ #define XYPRINTF_H_ typedef struct __windowDef { int x; int y; int width; int height; } windowDef; void clearScreen(void); #define BOLD 1 #define INV 2 #define UNDER 4 /** * This method prin...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* biggest_pal.c :+: :+: :+: ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* format_handler.c :+: :+: :+: ...
C
/* ** my_explode.c for MySlack in /home/nomad/mySlack/client ** ** Made by BARREAU Martin ** Login <barrea_m@etna-alternance.net> ** ** Started on Sun Feb 18 22:34:57 2018 BARREAU Martin ** Last update Sun Feb 18 22:35:32 2018 BARREAU Martin */ #include <libmy.h> #include <stdlib.h> char **my_explode(char *str,...
C
/* This set of routines handles the basic terminal IO on a NeXT * system. These routines are all designed to be called from * Fortran. Thus ttinit can be called using the Fortran line * CALL TTINIT() */ #include <sys/ioctl.h> #include <stdio.h> static struct sgttyb term, saveterm; ttinit_() /* Sets the t...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define SIZE 1000 #define SEPAR ' ' int split(char *str, char *result[]); int main() { char input[SIZE]; gets(input); char *result[SIZE]; int n = split(input, result); int i = 0; char *p; for(i = 0; i < n; i++){ printf("\""); p = result[i]; while...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_split.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> double wtime() { struct timeval t; gettimeofday(&t, NULL); return (double)t.tv_sec + (double)t.tv_usec * 1E-6; } int getrand(int min, int max) { return (double)rand() / (RAND_MAX + 1.0) * (max - min) + min; } void siftDown(int *numbers, int...
C
#include<stdio.h> #include<time.h> #include<stdlib.h> void swap( int* x, int* y) { int temp = *x; *x = *y; *y = temp; } void bubbleSort(int a[], int n) { for ( int i = 0; i < n - 1; i++) { for ( int j = 0; j < n - 1 - i; j++) { if (a[j] > a[j + 1]) { swap(&a[j], &a[j + 1]); } } } } void selecti...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> typedef struct Ponto { double x, y; } Ponto; //grafo usando matriz typedef struct Grafo { double **adj; //armazena distâncias entre os pontos[i][j] int n; } Grafo; typedef Grafo *p_grafo; p_grafo criar_grafo(int n) { int i,...
C
#include <stdio.h> #include "toBinTestVersion.h" void toBin(unsigned int x, FILE* file) { if (x == 0) return; toBin(x / 2, file); fprintf(file,"%d", x % 2); } void basic(unsigned int m, FILE* file) { unsigned int number = 3; int change = 0; while (number <= m) { fprintf(file, "%u ", number); toBin(number, ...
C
#include <bits/stdc++.h> using namespace std; int main() { int n,i=1; scanf("%d",&n); printf("I hate"); while(i<n) { if(i%2){ printf(" that I love");i++;} else{ printf(" that I hate");i++;} } printf(" it"); return 0; }
C
#include <stdio.h> // wasa関数の宣言 void WaSa(int *a, int *b); int main(void){ int a, b; printf("2つの整数を入力してください.\n"); scanf("%d", &a); scanf("%d", &b); WaSa(&a, &b); printf("和:%d, 差:%d\n", a, b); return 0; } void WaSa(int *a, int *b){ int tmp_a, tmp_b; tmp_a = *a; tmp_b = *b; ...
C
#include <stdio.h> #include <cs50.h> #include <math.h> #include <string.h> #include <ctype.h> #define MAX 9 int main(void) { return true; } typedef struct { string name; int votes; } candidate; int candidate_count; candidate candidates[MAX]; bool vote(string name) { for (int x = 0; x < candidate_co...
C
#include<stdio.h> #include<time.h> void struct_ex01(){ typedef struct{ char role[20]; char position[4]; }lol_info; struct lol_champ{ char name[14]; int number; lol_info info; struct lol_champ *self_c; }champ[3], *c, *sc; c=champ; ; for(int...
C
#include <stdio.h> #include <stdlib.h> struct sNODE { int dado; struct sNODE *esq, *dir; }; struct sNODE *raiz = NULL; struct sNODE *inserir(struct sNODE *no, int dado); struct sNODE *remover(struct sNODE *no, int dado); void emOrdem(struct sNODE *no); void preOrdem(struct sNODE *no); void posOrdem(struct sNODE ...
C
/** * @file battery.c * @author Peter Magro * @date August 4th, 2021 * @brief Handles all battery measurement-related functions. */ //*********************************************************************************** // Include files //*****************************************************************************...
C
/* queue.c Richard Coffey ECE 223 Program #3 */ #include <stdio.h> #include <stdlib.h> //#include "list.h" #include "queue.h" //#include "sim.h" //queue is a linked list so should never be full struct queue_s { list list; int numelements; int maxsize; }; /* create and initialize a new queu...
C
#include <stdio.h> int main(int argc, char **argv){ int n, q; int S[100], T[100]; scanf("%d", &n); for(int i = 0; i < n; ++i){ scanf("%d ", &S[i]); } scanf("%d", &q); for(int i = 0; i < q; ++i){ scanf("%d", &T[i]); } int ret = 0; for(int i = 0; i < q; ++i){ int val = T[i]; for(int ...
C
#include <stdio.h> int main(void) { int psbit = 0, sbit = 0, rebit, i = 1, j = 0, end = 0, end2 = 0; int ps[64] = { 0 }; int s[64] = { 0 }; int Ps , S , psbit2, sbit2 , sign = 0; scanf("%d %d", &Ps, &S); if(Ps <= 0 && s >0) { sign = 1; }else if (Ps > 0 && s <= 0) { sign = 1; } //비교 if(Ps <= 0) ...
C
/* sort.c */ // This program generates sorts the following list of random numbers; #include <stdio.h> #include <stdlib.h> #include <time.h> // Utility / debug function only used to check array is sorted void print_arr(int *arr, int size) { printf("["); int i; for(i = 0; i < size; i++){ printf("%d, ", arr[i]); ...
C
#include "./rendering_resource.h" #include "../../logger/logger.h" #include "../../memory/memory.h" #include "../../vulkan/functions/functions.h" #include "../../vulkan/tools/tools.h" void rendering_resource_init_empty(rendering_resource* res) { res->device = VK_NULL_HANDLE; res->command_pool = VK_NULL_HANDLE...
C
#include <stdio.h> #include <stdlib.h> /** *main - progrman that multiplies two numbers *@argc: argument count *@argv: pointer point to argument string *Return: 0 */ int main(int argc, char *argv[]) { int rest, i; char *p; int n; rest = 0; if (argc > 1) { for (i = 1; argv[i]; i++) { n = strtol(argv[i],...
C
#include<stdio.h> /** * main - function, entry point * @argc: # of args passed to program. * @argv: string array args passed to program. * * Description: program to print all arguments it receives. * Return: Always 0 */ int main(int argc, char *argv[]) { int count; for (count = 0; count < argc; count++) { printf("...
C
#include <ctest.h> #include <func.h> CTEST(FUNC_TEST, COMMON){ // Given /*int a[] = {5,4,3,2}; int b[] = {5,6,7,8}; */ int a = 5; int b = 5; // When int result; result = func(a,b); // Then //int expected[] = {10,10,10,10}; int expected = 10; //int i; //for (i = 0; i < 4; i++){ ASSERT_EQUAL(expected,...
C
/* * TCP_Server.c * * @date 2015/10/01 * @author Leejewoo * @email nowwoo91@gmail.com * * TCP_Socket의 생성과 해당 디스크립터 반환 */ #include <sys/socket.h> /* for socket(), bind(), and connect() */ #include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */ #include <unistd.h> #include <string.h> /* for memset() */...
C
/* ** aff_cases.c for 42sh in /u/all/bereng_p/cu/rendu/SVN/42sh/current ** ** Made by philippe berenguel ** Login <bereng_p@epitech.net> ** ** Started on Sun May 23 16:02:55 2010 philippe berenguel ** Last update Sun May 23 23:23:48 2010 carole cailleux */ #include <stdlib.h> #include "parser.h" #include "builtin...
C
#include<stdio.h> void strncopy( char *sbuf, char *dbuff, int n) { int i; for( i = 0; i < n; i++) { dbuff[i] = sbuf[i]; } dbuff[n] = '\0'; printf("the destination string is: %s\n", dbuff); }
C
#include <stdio.h> #include <math.h> #include <ctype.h> #define MAX_LINE 1000 int any(char s[], char c) { int res = -1; for (int i = 0; s[i] != '\0'; ++i) if (s[i] == c) { res = i; break; } return res; } int any_s(char s1[], char s2[]) { int res = -1; for (int i = 0; s2[i] != '\0'; ++i) { int ...
C
/* From:ITC 7 Resource management defects 7.3 Invalid memory access to already freed area 7.3.2 "using pointer to double,conditional statement if ~else using static variable of function scope" */ static int staticflag1=1; void invalid_memory_access_002 () { double *ptr, *dptr = 0,a; static in...
C
#ifndef _STACK_H #define _STACK_H #include <stdio.h> #define MAX_STACK_SIZE 100 typedef struct{ int x; int y; }Point; Point* stack_cur_poit(Point* buf, int* b_size); void stack_push(Point* buf, int* b_size, Point* dot); void stack_pop(Point* buf, int* b_size); #endif
C
#include<stdio.h> #include<ctype.h> int main () { char buff[101]; char *s; s = buff; scanf("%s",buff); while(*s){ *s = toupper(*s); ++s; } printf("%s",buff); }
C
#include "fft.h" #include <stdio.h> #include <math.h> #include <stdlib.h> //精度0.000001弧度 void conjugateComplex(int n,complex_S in[],complex_S out[]) { int i = 0; for(i=0;i<n;i++) { out[i].m_dVirt = -in[i].m_dVirt; out[i].m_dReal = in[i].m_dReal; } } void absComplex(complex_S f[],doubl...