language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <pcap/pcap.h> #include <time.h> #include <stdlib.h> #include <stdio.h> char buffer[1024] ; int index = 0 ; void getPacket( u_char *arg , const struct pcap_pkthdr * pkthdr , const u_char * packet ) { int* id = (int *)arg ; int i , j ; /* printf( "[+] id : %d\n" , ++(*id ) ) ; printf( " packet...
C
// Copyright (c) 2018 Felix Schoeller // // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. #include <stdio.h> #include "memory.h" #include "value.h" #include "vm.h" #include "dictionary.h" #include "hashtable.h" #include "list.h" void *reall...
C
#include <stdio.h> #include <stdlib.h> void print_lines(char** lines, int num_lines,int num){ int i; for(i = num_lines-num ; i < num_lines; ++i){ printf("%s", lines[i]); } } void free_lines(char** lines, int num_lines){ int i; for(i = 0 ; i < num_lines; ++i){ free(lines[i]); } if(lines != NULL && num_li...
C
// https://www.urionlinejudge.com.br/judge/en/problems/view/1098 #include <stdio.h> int main() { int i, j; float frac; for (i = 0; i <= 20; i += 2) { frac = i / 10.f; for (j = 1; j <= 3; ++j) printf("I=%g J=%g\n", frac, j + frac); } return 0; }
C
#include "tab_instru.h" #include <stdio.h> #include <stdlib.h> /*struct instr{ char * inst; int val1, val2, val3; }*/ int idx_instr=0; void instr_add(char* name, int v1, int v2,int v3){ tab_instr[idx_instr].inst = name; tab_instr[idx_instr].val1=v1; tab_instr[idx_instr].val2=v2; tab_instr[idx_instr].val3=v...
C
/** * program to find the square root of the given number till given precision * * @Harsh_Garg,1910990582,19/07/2021 * Assignment 1 */ #include<stdio.h> double find_square_root(int number,int precision); int main() { //declaring the variables for number and precision int number = 0; int precis...
C
#include "support.h" int main(int argc, char **argv) { // Ensure valid command line args if (argc != 4) { fprintf(stderr,"usage: %s <hostname> <port> <filename>\n", argv[0]); exit(1); } // Get the hostname and the port number. // char *hostname = argv[1]; int portno =...
C
//----------------------------------------------------------------------------- // List.c // List ADT // Stephanie Lu, sqlu // 2020 Spring CSE101 PA2 //----------------------------------------------------------------------------- #include<stdio.h> #include<stdlib.h> #include<ctype.h> #include<string.h> #inc...
C
#include <stdio.h> #include <stdlib.h> typedef struct { int N; int *u; int *u_rank; }union_find; union_find *make_union_find(int N){ int i; union_find *uf = (union_find *)malloc(sizeof(union_find)); uf->N = N; uf->u = (int *)malloc(sizeof(int) * N); uf->u_rank = (int *)malloc(sizeof(int) * N); ...
C
/////////////////////////////////////////////////////////////////////////////// // Programa para el pic 16F1827 que muestra en numero de 4 cifras en 4 // // displays de siete segmentos digito a digito, la velociadad de cristal de // // cuarzo esta configurada a 4MHz // ...
C
#include "cells.h" int main(void) { char command; char c = 'O'; int rule_arr[8] = {0}; int flag; term_size t_size; srand(time(0)); do { fflush(0); flag = 0; get_size(&t_size); get_rule(rule_arr); generate(rule_arr, &t_size, c); printf("Run again? (y/n) or change char? (c): "); command = ge...
C
#include <stdio.h> extern int count; // extern ٸ Ͽ int total = 0; int input_data() { int pos; while (1) { printf(" Է : "); scanf("%d", &pos); if (pos < 0) break; count++; total += pos; } return total; }
C
#include <stdio.h> #include <stdlib.h> int fibo(int num1) { printf("Fibonacci Number %d \n", num1); if(num1==0) return 0; if(num1==1) return 1; return (fibo(num1-1) +fibo(num1-2)); } int main() { int num1; printf("input Fibonacci ="); scanf("%d", &num1); fibo(num1); ...
C
#include <SDL2/SDL.h> #include <SDL2/SDL_opengl.h> #include "pattern.h" #include "clock.h" const int width = 800; SDL_Window * win; #define CIRCLE_RADIUS .005 #define CIRCLE_POINTS 24 #define FPS 50 void draw_circle(double x, double y, rgb_t color) { int i; glColor3ub(color.r, color.g, color.b); glPushMa...
C
#include <stdio.h> int main() { /* Escribe los numeros del 1 al 10*/ int numero = 1; do { printf ("%d\n", numero); numero++; }while (numero <= 10); return 0; }
C
#include"sem_header.h" int main() { key_t key = ftok(FILENAME, 'x'); int flag = IPC_CREAT; int perm = S_IRUSR|S_IWUSR; int id; ERRHANDLER(id = semget(key, 1, flag|perm)); struct sembuf sop; int n = 10; while(1) { sop.sem_num = 0; sop.sem_op = -1; sop.sem_fl...
C
#include<stdio.h> #include<stdlib.h> struct node { ///INSERTION AT END int info; struct node *link; }; struct node *START=NULL; struct node*createNode() { struct node*n; n=(struct node*)malloc(sizeof(struct node)); return n; } void insertnode() { struct nod...
C
#include <stdio.h> #include <omp.h> int main() { int ii; #pragma omp parallel private(ii) { for(ii=0;ii<10;ii++) { printf("Iteration: %d from %d\n",ii,omp_get_thread_num()); } } printf("\n"); return 0; }
C
// Function prototypes for large file access // The function xL has the same prototype and semantics as the function x (x=fopen, fclose, etc) #include <stdio.h> #include <sys/stat.h> #include "DataStructures.h" typedef int FileHandle; FileHandle fopenL(const char *filename, const char *mode); int fcloseL(FileHandle);...
C
#include <stdlib.h> #include <stdio.h> #include "bst.h" #include "queue.h" static BinNode * BST_node_new(int k) { BinNode * b = malloc(sizeof(BinNode)); b->key = k; b->left = NULL; b->right = NULL; return b; } BST * BST_new() { BST * b = malloc(sizeof(BST)); b->root = NULL; return b; } ...
C
/* ** tekpixel.c for raytracer1 in /home/voravo_d/rendu/raytracer1 ** ** Made by dorian voravong ** Login <voravo_d@epitech.net> ** ** Started on Sun Jul 17 14:40:52 2016 dorian voravong ** Last update Sat Oct 8 18:51:17 2016 Quentin Fournier Montgieux */ #include "lapin.h" void tekpixel(t_bunny_pixelarray *pix,...
C
#include"util_2.h" extern void error(int, char *); double *DajWekt(int n) { double *we; if (!(we = (double *) malloc((unsigned) n * sizeof(double)))){ error(0, "wektor"); } return we; } void CzytWekt(FILE *fd, double *we, int n) { for (int k = 0; k < n; k++) { fscanf(fd, "%lf", &w...
C
/* * @Author: shishao * @Date: 2019-07-16 14:33:47 * @Last Modified by: shishao * @Last Modified time: 2019-07-16 14:45:44 */ #include <avl.h> #include <assert.h> #define get_height(node) (((node)==0)?(-1):((node)->height)) #define max(a,b) ((a)>(b)?(a):(b)) /* RR(Y rotates to the right): k2 ...
C
#include <stdio.h> int search(int a[], int v, int l, int r); main(){ int a[10] = {2, 43, 20, 878, 100, -34, 0, -5, 21}; int index = -2; index = search(a, 0, 0, 9); printf("%d\n", index); } int search(int a[], int v, int l, int r){ int i; for(i=l; i<=r; i++){ if(a[i] == v){ return i; } } return -1; }...
C
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <sys/types.h> #include <sys/wait.h> #include<sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <string.h> //Function that parses out unnecessary characters //such as ' ', and '\t' char** parse(char* s) { static char* words[500]; memset...
C
// SigLib frequency domain plot header file // This file must be included after siglib.h // Frequency Domain Plots : // These functions support separate lengths for the source array and the DFT // so that short arrays can be zero padded to longer (power of 2) lengths // If the source dataset length is longer than the D...
C
#include "slide_line.h" /** * slide_line - slides and merges an array of integers * @line: array (int) * @size: length of array * @direction: direction of merge (L/R) * Return: 1 | 0 */ int slide_line(int *line, size_t size, int direction) { return 1; }
C
/************************************************************************* > File Name: 12_34.c > Author: Amano Sei > Mail: amano_sei@outlook.com > Created Time: 2020年09月23日 星期三 16时22分52秒 ************************************************************************/ #include "csapp.h" struct baseargs{ ...
C
#include <string.h> #include <stdio.h> int main(void) { char str1[] = "USC is in Columbia. USC's coach is Spurrier. USC is in the SEC."; char str2[100]; char str3[] = "USC"; char str4[] = "[Chickens!]"; int i, j; printf("The Original String is: \"%s\"\n", str1); i = j = 0; while...
C
void printarr(int a[], int size) { for (int i = 0; i < size; i++) printf("%d ", a[i]); printf("\n"); } void swap(int* p1, int* p2) { long tmp; tmp = *p1; *p1 = *p2; *p2 = tmp; } #include <stdio.h> void qs_sort(int Array[], int N, int start, int end) { int head = start, tail = end; int middle = (start + end)...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* show_usage.c :+: :+: :+: ...
C
#include <stdio.h> int main() { int i; int j; int board[20][20]; for (i = 0; i < 20; i++){ for (j = 0; j < 20; j++) { board[i][j]=0; } } return 0; }
C
/* * Copyright (c) 2010, the Short-term Memory Project Authors. * All rights reserved. Please see the AUTHORS file for details. * Use of this source code is governed by a BSD license that * can be found in the LICENSE file. */ #include "meter.h" #ifdef SCM_RECORD_MEMORY_USAGE static long alloc_mem = 0; static l...
C
/*--------------------------------------------------------- Teste da funcao ccreate ---------------------------------------------------------*/ #include "../include/cthread.h" #include "../include/support.h" #include <stdlib.h> #include <stdio.h> void *foo(void *param) { int n=(int)param; printf("->Thread...
C
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #define CORE 12 // struct arg_struct // { // int arg1; // int arg2; // }; int step = 0; void *parallel_addition(void *arg) { int core = (int)step; // Each thread computes 1/4th of matrix addition for (size_t i = core * MAX / CORE; i < ...
C
/* * encoding: UTF-8 with BOM * * ISSUE: Really weird bug at fgetws() with stdin, doesn't read the newline character * => getwc(stdin) to ignore it. */ #include <fcntl.h> //_O_U16TEXT #include <io.h> //_setmode() #include <stdio.h> #include <string.h> int wmain(int argc, wchar_t* argv[]) { _setmo...
C
/* K Web Server 0.2.1 By Ark 2014.7.30 */ #include <sys/socket.h> #include <stdio.h> #include <sys/types.h> #include <stdlib.h> #include <netinet/in.h> #include <sys/wait.h> #include <errno.h> #include <string.h> #include <arpa/inet.h> #include <pthread.h> #include <unistd.h> #include <string.h> #include <signal.h...
C
#include <ipconf.h> #include "net_sas.h" /* MODULE_HDR +----------------------------------------------------------+ ** ** <W[> SAS_GETSOCKOPT_01 ** ** <> SAS_GETSOCKOPT_01( void ) ** ** Ȃ ** ** <^[l> sXe[^X (BOOL) TEST_PASS I ** TEST_FAIL ُI ** ...
C
#include "parse.h" char **parse_args( char *line ) { int i; int counter = 2; for (i = 0; i < strlen(line); i++) { if (line[i] == ' ') { counter++; } } char **arr = calloc(counter, sizeof(char *)); char *tmp; counter = 0; while ((tmp = strsep(&line, ...
C
/* Autore: Giovanni Giorgis Titolo: Implementazione di una struttura a Casaccio Data: 7/10/2019 Descrizione: Data una semplice struttura Casaccio, composta da un intero e da un char implementarne il toolkit */ #include <stdio.h> #include <stdlib.h> #include "casaccio.h" int main() { //co...
C
#include "RWDungeon.h" #include "fibheap.h" void move_monster_help(int mon_index, mon_struct *mon); static int32_t distance_non_tunnel(const void *key, const void *with){ return ((tile_struct *) key)->nonTunnelNPC - ((tile_struct *) with)->nonTunnelNPC; } static int32_t distance_tunnel(const void *key, const voi...
C
// Weather update client // Connects SUB socket to tcp://localhost:5556 // Collects weather updates and finds avg temp in zipcode #include "zhelpers.h" #include "msgpack.h" int main (int argc, char *argv []) { // Socket to talk to server printf ("Collecting updates from weather server…\n"); void *context = ...
C
/* 编程练习6 编写一个程序,使其从标准输入读取字符,直到遇到文件结尾。对于每个字符,程序需要检查并报告该字符是否是一个字母。 如果是的话,程序还应报告该字母在字母表中的数值位置。例如,c和C的字母位置都是3.可以先实现这样一个函数:接受一个 字符参数,如果该字符为字母则返回该字母的数值位置,否则返回-1。 */ #include <stdio.h> int isabc(char ch); int main(void) { char ch; int flag; while( (ch = getchar()) != EOF) { if ( (flag = isabc(ch)) != ...
C
#include "holberton.h" /** * _isdigit - function to know if a character is a digit * @c: - input int parameter * Return: - return 1 if the input value is a digit otherwise returns 0 */ int _isdigit(int c) { if (c >= 48 && c <= 57) { return (1); } else { return (0); } }
C
#include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <stdio.h> /* Perror */ #include <errno.h> #include <stdlib.h> #include <string.h> #define BUFFER_SIZE 128 void sampleread(int fd ) { ssize_t nr; char buff[BUFFER_SIZE]; nr = read(fd, buff, BUFFER_SIZE); if (nr < 0) { ...
C
#include<stdio.h> #include<stdlib.h> #include<sys/types.h> #include<sys/ipc.h> #include<sys/shm.h> int leer_car(); int main (int argc, char *argv[]) { int shmid, *variable; key_t llave; llave= ftok(argv[0],'k'); if ((shmid=shmget(llave,sizeof(int),IPC_CREAT|0600))==-1) { perror("Error en shmget"); exit(-1)...
C
#include <stdio.h> #include <stdlib.h> #include "stack.h" int main() { stack *stk = NULL; push(7, &stk); push(2, &stk); push(9, &stk); push(12,&stk); push(15,&stk); printf("%d\n",pop(&stk)); printf("%d\n",pop(&stk)); printf("%d\n",pop(&stk)); printf("%d\n",pop(&stk)); printf...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define CONFIG_FILENAME "./config.ini" char db_ip[32] = {0}; char db_name[32] = {0}; int dump_period = 1; char lib_switch = 0; typedef struct { char *name; int type; #define TYPE_LONG 1 #define TYPE_ULONG 2 #define TYPE_STR 3 #define TYPE_CHAR 4 #def...
C
/* * calculator_operations.c * * Created on: 8 sep. 2020 * Author: cgimenez */ #include <stdio.h> #include <stdlib.h> int fSumOperation(float firstOperator, float secondOperator, float* pResult) { int ret = -1; if(pResult != NULL) { *pResult = firstOperator + secondOperator; ret = 0; } return ret...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/time.h> #include <signal.h> #include "ssu_runtime.h" int main(void) { sigset_t set; gettimeofday(&begin_t, NULL); sigemptyset(&set); sigaddset(&set, SIGINT); switch (sigismember(&set, SIGINT)) { case 1 : printf("SIGINT is included. \...
C
#include <stdio.h> #include <stdlib.h> /* This programs explains usage of: 1. getw 2. putw These are used to read/write integer values */ void main() { FILE *Fptr; int i, j, k[6]; Fptr = fopen("file1", "w"); clrscr(); if (Fptr == NULL) { printf("File could not be opened."); exit...
C
#include <stdio.h> void SortDisp(int dt1,int dt2); int main(void) { int num1; int num2; printf("l-->"); scanf("%d",&num1); printf("l-->"); scanf(" %d",&num2); SortDisp(num1,num2); return 0; } void SortDisp(int dt1,int dt2) { int w; if(dt1 > dt2) { w = dt1; dt1 = dt2; dt2 = w; } printf("l1...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* project.c :+: :+: :+: ...
C
/* * professorStudent.c * * Problem Description: * You have been hired by the CIS Department to write code to help synchronize * a professor and his/her students during office hours. The professor, of * course, wants to take a nap if no students are around to ask questions; if * there are students who want ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strjoin.c :+: :+: :+: ...
C
#include <stdio.h> int main(void) { int option; printf("Te encuentras en un sueno y tiens 3 caminos. \n"); printf("Escribe 1 si quieres ir por el camino de los dulces\nEscribe 2 si quieres ir por el caminio de madera\nEscribe 3 si quieres ir por el camino de los perros\n"); scanf("%i", &option); switch(opt...
C
#include<stdio.h> int fun() { if(1 < 2) { return; } else { return 1; } } int main() { printf("%d\n",fun()); return 0; }
C
#include<stdio.h> #define MAX 50 void main() { int A[MAX][MAX],B[MAX][MAX],C[MAX][MAX]; int Arows,Acols,Brows,Bcols, i,j,k,sum=0; // First Matrix printf("Enter the First Matrix (Size) X by X \n"); scanf("%d %d",&Arows,&Acols); printf("Enter the Elements of Matrix A : \n...
C
/** ****************************************************************************** * @file hal_gpio.c * @author Eakkasit L. * @version V1.0.0 * @date 26-Aug-2015 * @brief Brief of file description ****************************************************************************** */ #include "hal/hal_gpio.h" #if (...
C
#include "functionTest.h" #include <string.h> Department *departmentCreate(char *name, char *location) { Department *department = (Department *)malloc(sizeof(Department)); char *n = (char *)malloc(128 * sizeof(char)); char *a = (char *)malloc(128 * sizeof(char)); strcpy(n, name); strcpy(a, locat...
C
/* Передача размера массива в функцию Количество элементов массива можно найти вот так: sizeof(a) / sizeof(a[0]) Таким образом, если у нас есть массив, то можно легко найти количество элементов в нём. Но то же самое нельзя сделать с указателем, даже если он указывает на первый элемент массива. То...
C
/* ** EPITECH PROJECT, 2021 ** B-CPP-300-STG-3-1-CPPD02M-clement.muth ** File description: ** tab_to_2dtab */ #include <stdio.h> #include <stdlib.h> void tab_to_2dtab(const int *tab, int length, int width, int ***res) { *res = malloc(sizeof(int *) * length); if (!*res) return; for (int x = 0; x < ...
C
/* ** EPITECH PROJECT, 2022 ** cpp_d02m_2018 ** File description: ** Created by Florian Louvet, */ #include <stdlib.h> void tab_to_2dtab(const int *tab, int length, int width, int ***res) { *res = malloc(sizeof(int *) * length + 1); int pos = 0; for (int i = 0; i < length; i++) { (*res)[i] = malloc...
C
#include <stdio.h> int main(int argc, int *argv[]){ if(argc>1){ int i; for(i=1;i<argc;i++){ char item[1]=argv[i]; if(i==argc-1){ printf("%i\n",(int)item); } else{ printf("%i ",(int)item); } } }else{ return 0; } }
C
#include<stdio.h> int count(int n); int main() { int n,res=0; printf("Enter the Number whose digits are to be counted"); scanf("%d",&n); res=count(n); printf("The number of digits in %d = %d",n,res); } int count(int n) { static int res=0; if(n!=0) { res++; count(n/10); } return res; }
C
#include "log.h" #define STR_INFO " INFO: " #define STR_DEBUG " DEBUG: " #define STR_WARNING "WARNING: " #define STR_ERROR " ERROR: " #define STR_FATAL " FATAL: " #define MAX_BUFF_SIZE 64 static void _log(FILE* stream, const char* logstr, const char* format, va_list args) { char buff[MAX_BUFF_SIZE];...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* list_files.c :+: :+: :+: ...
C
#include <stdio.h> long string2int(char *); float string2float(char *); void string2bin(char *); void string2bin64(char *); void string2hex(char *); void string2hex16(char *); void int2bin(int); void int2hex(); int bin2int(); void bin2hex(); void bin2hex16(); void double2double(char *); void double2bin(float); void ...
C
#include "utl/assert.h" #include "utl/test.h" #include "../src/linkedlist.c" CMC_CREATE_UNIT(linkedlist_test, true, { CMC_CREATE_TEST(new, { linkedlist *ll = ll_new(); cmc_assert_not_equals(ptr, NULL, ll); bool passed = ll->count == 0 && ll->head == NULL && ll->tail == NULL; cmc_...
C
/* API for thread handling */ /*********************************************************************/ /* Global includes */ /*********************************************************************/ #include <stdio.h> #include <unistd.h> #include <pthread.h> #include <si...
C
#include<stdio.h> int main() { int n1,n2,n3,max1,max2; printf("number 1 : "); scanf("%d",&n1); printf("number 2 : "); scanf("%d",&n2); printf("number 3 : "); scanf("%d",&n3); if(n1>=n2 && n1>=n3) { max1 = n1; if(n2 >= n3) {max2 = n2;} ...
C
#include <stdio.h> void minmax(int *data, int *max, int *min); int main(void) { int i; int max; int min; int array[10]; printf("0~100の範囲の整数値を複数入力せよ。\n"); printf("入力要素の上限は10とする。\n"); printf("-1が入力された場合入力終了とみなす。\n"); for (i=0; i<10; i++) { printf("%dつ目の数字を入力してください\n", i + 1); ...
C
/* _rename.c -- Implementation of the low-level rename() routine * * Copyright (c) 2004 National Semiconductor Corporation * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are ret...
C
#include <string.h> #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <termios.h> #include <signal.h> int alarmFlag=0, alarmCounter=0; int maxPackageSize = 512, retries = 3, timeOut = 3; int cntTrasmit = 0, cntRetransmit = 0, cntReceived = 0, cntRejSend = 0...
C
#include <stdio.h> #include <pthread.h> #include <sys/types.h> #include <sys/syscall.h> #if 0 int *func(void *p) { printf("thread executed\n"); return 0; } int main (void) { pthread_t th; int s; s = pthread_create(&th, NULL, func, NULL); if(s != 0) { perror("thread create"); return 0; } pthread...
C
#include <stdio.h> #include <stdlib.h> int main() { void Binary(int n) { int A[n]; if (n < 1) { for (int i = 0; i < n; i++) printf("%d", A[i]); } else { A[n - 1] = 0; Binary(n - 1); ...
C
#include<stdio.h> #include<string.h> int main(){ int n,x,d[100],e[100],resp=0,i; char c; while(scanf("%d",&n)!=EOF){ memset(d,0,sizeof(d)); memset(e,0,sizeof(e)); while(n--){ scanf("%d %c",&x,&c); switch(c){ case 'D': d[x]++; break; ...
C
#include<stdio.h> int main() { int C; scanf_s("%d", &C); for (int i = 1; i <= C;i++) { int N; int cnt = 0; double score[1000]; double sum = 0, avr; scanf_s("%d", &N); for (int j = 0; j < N; i++) { scanf_s("%lf", &score[j]); sum += score[j]; } avr =sum / N; for (int ...
C
#include "libft.h" #include <stdio.h> int main(void) { char str[] = "You're slow, even when you are falling."; ft_putstr("str: "); ft_putendl(str); ft_putstr("call ft_strstr(str, \"even\", 25): "); ft_putendl(ft_strnstr(str, "even", 25)); ft_putstr("call ft_strstr(str, \"even\", 10): "); printf("%s\n", ft_strn...
C
#include <stdio.h> struct t{ unsigned long long int soma; int next; }vet[1000]; unsigned long long int v[1000], k, R, euros,aux; int N; int main(void) { int t,inst,i,j,p; scanf("%d",&t); for(inst=1;inst<=t;inst++){ scanf("%llu %llu %d",&R, &k, &N); for(i=0;i<N;i++) scanf("%llu",&v[i]); for(i=0;i<...
C
#include "holberton.h" /** * _sqrt_recursion - function that returns the natural square root of a num * @n: integer to find square root of * Return: int */ int _sqrt_recursion(int n) { int sqr; sqr = _pow(1, n); return (sqr); } /** * _pow - checks whether the square of a number * @x: will be square, incre...
C
// ECE 6110 - Quiz 2 - Tyler McCormick // // This code implements a function generator, where a user can choose from a sine, sawtooth, or square wave. The amplitude of all // three functions is adjustable from 1-9, as well as the frequency, in Hz. For a square wave, the duty cycle can also be chosen. // // All choices ...
C
#include "../include/bytecode.h" BytecodeHeader* new_bytecodeheader( void ){ BytecodeHeader* bch = malloc( sizeof(BytecodeHeader) ); bch->entry_point_ = 0; bch->code_size_ = 0; return bch; } void bytecodeheader_set_entrypoint( BytecodeHeader* _ptr_bch,unsigned int _data ){ _ptr_bch->entry_point_ = _data; } ...
C
#include <stdlib.h> #include <stdio.h> int main() { int num1 = 20; int* ptr_num1 = &num1; int* ptr_num2 = malloc(sizeof(int)); ptr_num2 = ptr_num1; int num2 = *ptr_num2; free(ptr_num2); }
C
/* triangle-float.c: triangle classifier via floating-point arithmetic * author: David Eisenstat <eisenstatdavid@gmail.com> * date: 2014-01-13 */ #include <complex.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #if 0 static long double FabsCarg(long double complex z) { return fabsl(cargl(z)); } #els...
C
#include <stdio.h> // github ø void main(){ int num1, num2, num3; int result; printf(" Էϼ: ex)3 4 5(Enter)"); scanf("%d %d %d", &num1, &num2, &num3); result = (num1-num2)*(num2+num3)*(num3%num1); printf("(%d-%d)X(%d+%d)X(%d%%%d)=%d", num1, num2, num2, num3, num3, num1, result); }
C
#include <stdio.h> #include <stdlib.h> #include "rmsd.h" #include "drmsd.h" #include <time.h> #include "clrec.h" #include <string.h> #include "nnlsh.h" #include <assert.h> #define bufSize 2048 int main(int argc, char *argv[]) { if(argc!=2 && argc!=5 && argc!=6) { printf("Wrong arguments!\n"); return -1; } FILE...
C
/* Formats binary values into ascii strings using the standard c format syntax E.g. to format the value stored in variable data as an integer at least three characters wide. printformat("%3i" , data); */ #ifndef _MSP430_PRINTF_ #define _MSP430_PRINTF_ #include <msp430g2553.h> #include "stdarg.h" void printformat(cha...
C
#include <stdlib.h> #include <stdio.h> #define MAX_ROWS 50 #define MAX_COLS 50 #define WHITE_PIXEL '.' #define BLUE_PIXEL '#' #define RED_PIXEL_1 '/' #define RED_PIXEL_2 '\\' int main(void) { FILE *f_in, *f_out; if (!(f_in = fopen("A.in", "r"))) { printf("ERROR: no input file.\n"); return EXI...
C
#include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <time.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdbool.h> typedef struct banned_ip { in_addr_t addr; struct banned_ip *next; } banned_ip...
C
#include <stdio.h> #include <math.h> int main() { int num, power, ans = 0; for (num = 1; num < 10000; ++num) { for (power = 0; power < 10000; ++power) { int digitOfNum = (power * log10(num)) + 1; ans += digitOfNum == power; } } printf("%d\n", ans); return 0; }
C
#include <stdio.h> int main() { int t; scanf("%d",&t); while(t--) { int n,m,x,y; scanf("%d %d %d %d",&n,&m,&x,&y); if(((n-1)%x==0&&(m-1)%y==0&&(n-1)>=0&&(m-1)>=0)||((n-2)%x==0&&(m-2)%y==0)&&(n-2)>=0&&(m-2)>=0) printf("Chefirnemo\n"); else printf("Pofik\n"); ...
C
/* * echoserveri.c - An iterative echo server */ /* $begin echoserverimain */ #include "csapp.h" #include <sys/epoll.h> #define MAX_EVENTS 100000 void echo(int connfd); int main(int argc, char **argv) { int listenfd, connfd, port, clientlen, epfd, nfds, i, nr; struct sockaddr_in clientaddr; struct h...
C
/** * @file HRI_ACMP.h * @brief Declaraciones a nivel de registros del ADC (LPC845) * @author Esteban E. Chiama * @date 4/2020 * @version 1.0 */ #ifndef HRI_ACMP_H_ #define HRI_ACMP_H_ #include <stdint.h> #if defined (__cplusplus) extern "C" { #endif #define ACMP_BASE 0x40024000 //!< Direccion base del Co...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> struct Node { int num; struct Node *left; struct Node *right; }; struct Node *insert(struct Node *root, int num) { if (root == NULL) { root = malloc(sizeof(struct Node)); root->num = num; root->left = NULL; ...
C
#include "../../testing/utest.h" #include <stdio.h> #include <stdlib.h> #include <string.h> //INCLUDE LIBRARY TO TEST #include "../../inc/LinkedList.h" #include "../../testing/inc/Employee.h" void removeTestSetup(void) { utest_print("Setup...\r\n"); } void removeTestCase01(void) { LinkedList* list; int r; ...
C
#include <stdio.h> int main(void){ int n; scanf("%d",&n); for(int i = 1; i <= n; i++){ for(int j = n-i; j > 0; j--){ printf(" "); } for(int k = 1; k <= 2*i-1; k++){ printf("*"); } printf("\n"); } }
C
#include <stdio.h> #include <string.h> void xoa(char s[], char s1[]) { char kq[100]; int t = 0, i = 0, j, k, ns1 = strlen(s1); strcat(s, "|"); while (s[i] != '|') { k = i; j = 0; while (s[k] == s1[j]) { k++; j++; } if (j == ns1...
C
#include <stdio.h> #define BR_ELEMENTI 100 void preuredi(int *a, int m); int main() { int a[BR_ELEMENTI], i, j, m; printf("Vnesete broj na elementi M:"); scanf("%d", &m); printf("\nVnesete ja nizata:\n"); for (i=0;i<m;i++) { printf("a[%d]=", i); scanf("%d", &a[i]); } printf("\nNizata pred da se preuredi e:\n\n"); for ...
C
#include <stdio.h> #include <string.h> #define COMBINATIONS 6561 #define OPS 8 void generateCombination(int permutationIdentifier, char* arr){ int arrPtr = 0; for(int i = 1; i < OPS ; i++, permutationIdentifier /= 3){ arr[arrPtr] = i + '0'; arrPtr++; int op = permutationIdentifier % 3; ...