language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <time.h> #include <stdio.h> #include <stdlib.h> int main() { struct tm *tm_ptr; time_t raw_time; (void) time(&raw_time); tm_ptr = gmtime(&raw_time); printf("Raw time is %ld\n", raw_time); printf("\n"); printf("gmtime() provides:\n"); printf("date: %04d/%02d/%02d\n", tm_ptr->tm_year+1900...
C
#ifndef _18_HASH_TABLE #define _18_HASH_TABLE #define HTABLE 0 #define LRU 1 typedef struct _ht_list_node { //struct _htable_node *prev; struct _htable_node *next; } ht_list_node; typedef struct _lru_list_node { struct _htable_node *prev; struct _htable_node *next; } lru_list_node; typedef struct _htable_node ...
C
#include <stdio.h> int main() { int i, f, l, m, n, s, a[100]; printf("Enter number of elements\n"); scanf("%d", &n); printf("Enter %d integers\n", n); for (i = 0; i < n; i++) scanf("%d", &a[i]); printf("Enter value to find\n"); scanf("%d", &s); f = 0; l = n - 1; m = (f+l)/2; while (f <=...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #define MAXSTRING 10001 void print_array(int array[],int size) { int i; for (i=0;i<size;i++) { printf("%d ",array[i]); } printf("\n\n"); } int palindrome(char *str, int length) { int a = 0; int b = length - 1; while (b > a) { if...
C
#include <stdio.h> #define MAX(x, y) ((x)>(y) ? (x) : (y)) int main(void) { int i, s; printf(" Է: "); scanf_s("%d %d", &i, &s); printf(" ū : %d \n", MAX(i, s)); return 0; }
C
#include<stdio.h> #include<string.h> #include<stdlib.h> struct student{ char id[15]; char name[100]; float marks; int rank; int flag; }; struct student arr[50]; struct student sorted[50]; void readdata(struct student arr[50]) {int i; for(i=0;i<50;i++) {scanf("%[^,]",arr[i].id);getchar();scanf("%[^,]",arr[i].name);getch...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <time.h> // Bibliotecas para socket #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <fcntl.h> // for open #include <unistd.h> // for close #include <arpa/inet.h> #include <dirent.h> #include <netdb.h> ...
C
// // Created by Unknow on 18/11/2020. // #include "cli_menu.h" int menu(char **xml_path, char **dtd_path) { char *temp = *xml_path; *xml_path = strtrim_space(*xml_path); if (temp) { free(temp); } temp = *dtd_path; *dtd_path = strtrim_space(*dtd_path); if (temp) { free(tem...
C
/*! \file Blackjack.c \author Clément BELLEIL \version 1.0 \date 9 décembre 2020 \brief TP_09 Blackjack */ #include "Blackjack.h" int NouvelleManche(int nbjoueur, Joueur liste_j[7]) { int int_i; int int_choix; int int_valretour; for(int_i=1;int_i<nbjoueur+1;int_i++) { if (liste_j[int_i].in...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* render.c :+: :+: :+: ...
C
/* vim: tabstop=4 shiftwidth=4 noexpandtab * This file is part of ToaruOS and is released under the terms * of the NCSA / University of Illinois License - see LICENSE.md * Copyright (C) 2018 K. Lange * * hexify - Convert binary to hex. * * This is based on the output of xxd. * Does NOT a hex-to-bin option - som...
C
#include "stack.h" #define SIZE 512 /* _Bool stack(u64 in, u64* out, _Bool push, _Bool pop) { static u64 stack[SIZE]; static u16 ptr = 0; _Bool result = 1; if (push && ptr < SIZE) { stack[ptr++] = in; } else if (pop && ptr > 0) { *out = stack[--ptr]; } else result = 0; return result; } */ _Bool stack(u64 in...
C
using static System.Console; namespace exercicio32 { public class exercicio32 { public static void Main(string[] args) { int[] numeros = new int[args.Length]; for (int i = 0; i < args.Length; i++) { int numero; if (int.TryParse(args[i], out numero)) { numeros[i] = numero; } else {...
C
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> void set_read(int* lpipe) { dup2(lpipe[0], STDIN_FILENO); close(lpipe[0]); // we have a copy already, so close it close(lpipe[1]); // not using this end } void set_write(int* rpipe) { dup2(rpipe[1], STDOUT_FILENO); cl...
C
/*! \file main.c \brief Main program of the serial solar system simulator. \author Peter C. Chapin <PChapin@vtc.vsc.edu> LICENSE This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either ...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> struct transition { char car;//caractère étiquetant la transition. -1 si c'est une epsilon transition int arr;//état d'arrivée de la transition struct transition *suiv; }; typedef struct transition *TRANSITION ; typedef struct{ int sigma; // ...
C
#include <stdio.h> #include <stdlib.h> #include <stddef.h> #include <string.h> #include "../array/array.h" #include "stack.h" #include "../errors.h" void init_stack(stack * s) { if (s->_array != NULL) { printf("Can't init twice for stack!\n"); exit(ERR_INIT_TWICE); } s->_array = new_array(); if(s->_array->_dat...
C
#include "extras.h" int ft_execute_d(t_data *d, t_inst i) { if (!st_push(d->ih, i)) return (0); if (!ft_execute(i, d->a, d->b)) return (0); return (1); } int ft_free_data(t_data *d) { st_free(d->a); st_free(d->b); st_free(d->mem); st_free(d->ih); return (0); } void *ft_dummy_sum(int n) { n++; return (...
C
#include<stdio.h> void main() { int a[100],b,i,c,d,e,f,k; printf("enter the value "); scanf("%d",&c); printf("enter the value "); for(b=1;b<=c;b++) scanf("%d", &a[b]); for(d=1;d<=c;d++) { if(a[d]>f) f=a[d]; } printf("the maximum value %d",f); ...
C
#include <xeroskernel.h> #include <i386.h> /*----------------------------------------------------------------------------------- * Tests for mem.c. * * List of functions that are called from outside this file: * - run_mem_test * - Runs the test suite for mem.c *-------------------------------------------------...
C
#include "ft_printf.h" void flags_init(t_options *structure) { structure->flag = -1; structure->width = 0; structure->precision = -1; structure->zero = 0; structure->type = '\0'; } int type(char format, va_list ap, t_options *structure) { int if_error; if_error = 0; if (format == (structure->type = 'c')) ...
C
/*13. Escriba una función que reciba un entero y devuelva su factorial. */ #include <stdio.h> int getFactorial(int x){ int aux = 1; for(;x > 1;x--){ aux*=x; } return aux; } int main() { int n = 2; printf("Factorial de %d: %d\n", n, getFactorial(n)); return 0; }
C
// print the square of a number. #include<stdio.h> int main(int argc, char const *argv[]) { float square(float b); // Make sure this matches the definition. int main() { float a, y; printf("enter a number?\n"); scanf("%f", &a); y = square( a ); printf("%f", y); } }
C
#include<stdio.h> #include<string.h> int main() { int i=0,j=0,k=0,l=0; char inp[50]={0},part1[50]={0},part2[50]={0}; printf("Enter production in the form A-> Aa1|Aa2|...|b1|b2..\nA-> "); gets(inp); inp[strlen(inp)]='\0'; if(inp[0]=='A') { abc:for(i++,j=0;inp[i]!='|';i++,l++) part1[l]=inp[i]; part1[l]='A...
C
/* main.c Autor: Orlando Enrico Liz Silvério Silva */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "matriz.h" int main(int argc, const char * argv[]) { int N=0, M=0; int i=0, n1=0, n2=0; char op[4]; //ponteiros para ler e escrever em arquivos de //entrada e saída FILE *f...
C
#include <stdlib.h> #include <stdio.h> void exportGPIOFile(char* fileName, int pin) { printf("Called %s, %d", fileName, pin); FILE *pfile = fopen(fileName, "w"); if (pfile == NULL) { printf("ERROR: Unable to open the file.\n"); exit(1); } fprintf(pfile, "%d", pin); fclose(pfile); } int main() { exportGP...
C
#include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> #define MAX_ROW 1000 typedef struct element { char *string; int frequency; struct element *next; } element; // Insertion is SORTED ALPHABETICALLY! element *storeWord(element *list, char *word) { for(int i = 0; i < strlen(w...
C
// vim: set tabstop=2 softtabstop=2 shiftwidth=2 expandtab : /* * Copyright (c) 2017, Ryan V. Bissell * All rights reserved. * * SPDX-License-Identifier: MIT * See the enclosed "LICENSE.forge" file for exact license terms. */ #include <errno.h> #include <stdio.h> #include <stdlib.h> #include "fibgen.h" void u...
C
#include<stdio.h> #include "date.h" int compare(struct date d1,struct date d2) { if(d1.day==d2.day && d1.month==d2.month && d1.year==d2.year) return 0; else if ((d1.year>d2.year)||(d1.year==d2.year && d1.month>d2.month)||(d1.year==d2.year && d1.month==d2.month && d1.day>d2.day)) return 1; else return -1; }
C
#ifndef ROBOTMAP_H #define ROBOTMAP_H #include "WPILib.h" /** * The RobotMap is a mapping from the ports sensors and actuators are wired into * to a variable name. This provides flexibility changing wiring, makes checking * the wiring easier and significantly reduces the number of magic numbers * floating around....
C
#include <stdlib.h> #include <stdio.h> #include <math.h> // Determine which version of GLUT to load #if defined(__APPLE_CC__) #include <GLUT/glut.h> #else #include <GL/glut.h> #endif /* Compilation command: gcc -framework GLUT -framework OpenGL main.c -o main */ // STRUCTS // Struct to represent RGB float va...
C
#include <stdio.h> #include <stdbool.h> #include <stdlib.h> #include "list.h" #define TETA 0.5 #define NUMBER_OF_CORES 3 struct core{ struct Task task; bool busy; bool faulty; }; int time = -1; struct core cores[NUMBER_OF_CORES]; int number_of_cores = NUMBER_OF_CORES; int number_of_Tasks; struct Node * li...
C
/*====================================================================== C <- MINHITSET(A,B) Minimum hitting set. (Minimum with respect to cardinality.) Inputs A : A list (l_1, ..., l_n), each l_i is a list of BETA-digits, given in ascending order. B : A BETA-Digit. Output C : A...
C
//Recibe un argumento, la ruta del fichero, Si no existe, el programa debe crearlo y escribir holaMundo //Si ya existe, el programa debe sobreescribir su contenido por "Hola Mundo" /*NOTA: MEJOR USAR RUTAS RELATIVAS QUE ABSOLUTAS PARA EJECUTARLO*/ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <f...
C
#include <stdio.h> #include <stdlib.h> int main(int argc, char* argv[]) { printf("Enter numbers (1 - 70) | CTRL + D to terminate:"); int next; if (scanf("%d", &next) != 1) { printf("\nInvalid input. Try again.\n"); exit(EXIT_FAILURE); } do { printf("%d |", next); for...
C
#include<stdio.h> int main() { double i, d, s=1, j=1; for(i=1; i<=7; i+=2) { d=(i/j); s += d; j = j*2; } printf("Value of series : %.2lf\n", s); return 0; }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_next_line.c :+: :+: :+: ...
C
/* Program to find all possible paths to reach to bottom-right cell starting from the top-left Can move only right,down or diagonally lower Enter the no of rows: 2 Enter the no of columns: 2 Total paths: 3 j ___ i |1 1 |1 3 sum of all three sides, gives total path. */ #include<stdio.h> int main() {...
C
#include <stdio.h> int main() { float Matriz[2][2], Matriz2[2][2]; int i = 0, j = 0; for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) { scanf("%f", &Matriz[i][j]); } } Matriz2[0][0] = (Matriz[0][0] * Matriz[0][0]) + (Matriz[0][1] * Matriz[1][0]); Matri...
C
/* * Table des symboles.c * * Created by Janin on 12/10/10. * Copyright 2010 LaBRI. All rights reserved. * */ #include "Table_des_symboles.h" #include <stdlib.h> #include <stdio.h> /* The storage structure is implemented as a linked chain */ /* linked element def */ typedef struct elem { sid symbol_name;...
C
#include <stdio.h> void getLine (char * const s, const size_t max); int main (void) { char string[100]; getLine(string, 100); printf("%s\n", string); return 0; } void getLine (char * const s, const size_t max) { char *p = s; while ((*p = getchar()) != '\n' && p - s < max - 1) ++p; ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* set_camera.c :+: :+: :+: ...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include "../rbtree.h" typedef struct StrUnit { rbtree_node_t node; uint32_t len; char *data; }str_unit_t; rbtree_t *rbtree; void str_unit_rbtree_insert_value(rbtree_node_t *root, rbtree_node_t *node, rbtree_node_t *sentinel) { rbtree_n...
C
#include <vxWorks.h> #include <math.h> #include <float.h> #include <stdio.h> void math() { int i; double b; /* smallest integer greater than or equal to a specified value */ i= ceil(4.3); printf("the value of i using ceil is %d\n",i); /* It gives largest integer less than or equal to a specified value */ i= ...
C
#include<stdio.h> #include<stdlib.h> int main() { int num; printf("DAYS OF THE WEEK!!\nSelect a number from 1-7\n"); scanf("%d",&num); switch(num) { case 1: printf("\nMONDAY"); break; case 2: printf("\nTUESDAY"); break; case 3: printf("\nWEDNESDAY"); break; ca...
C
/* Title : Program to check if number is even or odd Author : Shashi Kumar M Date : 1 October 2019 Description : WAP to check whether a number is even or odd using bitwise operators Input : A number Output : Print whether a number is even or odd. */ #include<stdio.h> int main() { //Declar...
C
#include<stdio.h> void printbinary(int i){ while (i > 0){ if (i % 2 != 0) printf("1"); else printf("0"); i = i / 2; } } void printhexadecimal(float x) { printf("0x%08X, %f\n", *(int *)&x, x); } main(){ float x; float y; printf("Enter a float...
C
/* ** EPITECH PROJECT, 2018 ** Project ** File description: ** join.c */ #include "client.h" void resp_join(ui_t *ui, char **resp) { char *nick = get_nickname(resp[0]); chan_t *chan_cpy = ui->session->chan; if (!nick) return; if (!strcmp(ui->session->nickname, nick)) ui->session->printChan( ui->session, r...
C
#include<stdio.h> int step; int a[1000]; int m,n; void dfs(int nx,int m){ if(nx != n && m == 0){ step++; } else if(nx == n && m != 0){ return; } else if(nx == n &&m == 0){ step++; } else{ if(m >= a[nx]){ dfs(nx+1,m-a[nx]); dfs(nx+1,m); ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef union { int balcon; char apartament; char casa[31]; }detaliu; typedef struct { char adresa[101]; int suprafata; char locuinta[31]; int nr_camere; detaliu ceva; }locuinta; int main() { locuinta...
C
#ifndef _header_basic_types_ #define _header_basic_types_ #include <stdint.h> typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; typedef int8_t s8; typedef int16_t s6; typedef int32_t s32; typedef int64_t s64; typedef float f32; typedef double f64; static_assert( sizeof(u8)==1,...
C
#include "listing.h" /*Ces fonction me servent uniquement a executer mes algorithme dans le main()*/ void viderBuffer(){ int c = 0; while (c != '\n' && c != EOF){ c = getchar(); } } void lire(char *chaine, int longueur){ char *positionEntree = NULL; if (fgets(chaine, longueur, stdin) != N...
C
#include<stdio.h> void main(void){ char nome[20]; printf("Qual e o seu nome? \n"); scanf("%s",&nome); printf("Olá %s! \n", nome); }
C
#include<stdio.h> int main() { int n; scanf("%d",&n); int ara[1000]; int i,j,k; for(i=0;i<n;i++){ scanf("%d",&ara[i]); } for(i=0;i<n;i++){ for(j=0 ; j<n ; j++){ for(k=0 ; k<n ; k++){ if(i!=j && ara[i]+ara[j]==ara[k]){ printf("%d %d %d\n",k+1,j...
C
#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <syslog.h> #include <ini_parser.h> #define __CONFIG_C__ #include "config.h" const char * config_lookup_key_str(const CONF_KV_T* config, const INI_KEY_T key) { for(const CONF_KV_T* tc = config; INI_KEY_INVALID_KEY != tc->key; tc++...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* check_three.c :+: :+: :+: ...
C
// 312350192 Omer Eckstein #include <stdbool.h> typedef struct { unsigned char red; unsigned char green; unsigned char blue; } pixel; typedef struct { int red; int green; int blue; // int num; } pixel_sum; /* Compute min and max of two integers, respectively */ int min(int a, int b) { retu...
C
/*P15.7 Program to understand the use of local static variable */ #include<stdio.h> void func(int n); int main(void) { int n,i ; printf("Enter a number : "); scanf("%d",&n); for(i=1; i<=10; i++) func(n); printf("\n"); return 0; } void func(int n) { static int step; /*Automatically initializ...
C
/** * Mutex that sleeps... and can be owned across sleeping... * * @copyright * This file is part of ToaruOS and is released under the terms * of the NCSA / University of Illinois License - see LICENSE.md * Copyright (C) 2021 K. Lange <klange@toaruos.org> */ #include <kernel/types.h> #include <kernel/printf.h> #...
C
#include <string.h> #include <stdio.h> int replace_char(char *str, char old_char, char new_char); int main(void) { int result = 0; char str[] = "this is my test string"; result = replace_char(str, ' ', '_'); printf("\n%s\n%d replacments", str, result); return 0; } int replace_char(char *str, char o...
C
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE122_Heap_Based_Buffer_Overflow__CWE135_61b.c Label Definition File: CWE122_Heap_Based_Buffer_Overflow__CWE135.label.xml Template File: sources-sinks-61b.tmpl.c */ /* * @description * CWE: 122 Heap Based Buffer Overflow * BadSource: Void pointer to a wchar_t array * ...
C
#include <stdio.h> #include <stdlib.h> int *entregarDirMemArr(int arregloInt[5],int posicion){ // Recordar que los arreglos son punteros de por si. return arregloInt + posicion; } int main(){ int arregloInt[5]; int *direccionMemoriaPos = entregarDirMemArr(arregloInt,2); printf("Direccion del arre...
C
#include<stdio.h> #include<stdlib.h> #include<ctype.h> FILE * fp; int main() { int input; int intin; int intin2; int outp; int op; printf("Enter first number: "); if (scanf("%d", &input)) { intin = atoi(input); } printf("Enter second number: "); if (scanf("%d", &input)) { intin2 = atoi(input); }...
C
#include<stdio.h> int main() { //usinf for loop printf("using for loop\n"); for(int i=0;i<4;i++){ staticdemo(); } printf("\n"); printf("using while loop\n"); //using while loop int i=0; while(i<4){ staticdemo(); i++; } return 0; } ...
C
#include<stdio.h> int main() { unsigned long long int max=0,p,a[20][20],i,j; for(i=0;i<20;i++) for(j=0;j<20;j++) scanf("%llu",&a[i][j]); //horizontal products for(i=0;i<20;i++) for(j=0;j<=16;j++) { p=1; p*=a[i][j]*a[i][j+1]*a[i][j+2]*a[i][j+3]; max=max>p?max:p; } //vertical products for(i=0;i<...
C
#include <stdio.h> #include <signal.h> #include <stdlib.h> #include <unistd.h> volatile int int_c = 0; volatile int tstp_c = 0; void hler(int senial){ if (senial == SIGINT) int_c++; if (senial == SIGTSTP) tstp_c++; } int main(int argc, char* argv[]){ printf("Pid del proceso: %d.\n", getpid()); struct sig...
C
// // Created by bartek on 3/18/20. // #include "nb_iot.h" #include "uart_comm.h" #include "string.h" #include "stdlib.h" #include "stm32f1xx_hal_dma_ex.h" #include "stm32f1xx_hal_uart.h" #include "helpers.h" // Initialize with 0 every elem static uint16_t concatenate_counter = 0; uart_struct pc_uart = { .name = "PC_...
C
#include <stdio.h> int _length(char s1) { int i, cont = 0; for (i = 0; s1[i] != '\0'; i++) if (str[i] != ' ') { alpha = 1; cont++; } cont += 1; return (cont) } #include "holberton.h" #include <stdio.h> #include <ctype.h> #include <stdlib.h> /** * strtow - function that splits into words * @str: string *...
C
#include <stdio.h> //int main (){ //char a = 'a'; //int b = 65; //char c[20] = "Hello world"; //type data //printf ("%-20s Hello2", c); //rata kanan hello 2 //printf("%20s Hello2", c); //rata kiri hello 2 //putchar ('z') //print cuma 1 karakter //puts(c); //printf("test"); //retur...
C
#define LIM 32 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <unistd.h> #include <fcntl.h> #include <time.h> #include <pmmintrin.h> float randfloat() { float r= (float)(rand()); float div =(float)(1-RAND_MAX); return r/div; } int main(){ float y[LIM],x[LIM...
C
#include "calculator.h" static RNResult *calculatorResult; static RNResult *storedCalculatorInput; static RNResult *currentCalculatorInput; static char arithmeticOperator; static void performComputation(); static void allocResult(RNResult **result); static void freeResult(RNResult **result); static void reallocResul...
C
#include <stdio.h> #include <stdlib.h> //1 double add(double firstNumber, double secondNumber){ double sum; sum = firstNumber + secondNumber; return sum; } //2 double multiply(double firstNumber, double secondNumber){ double result; result = firstNumber * secondNumber; return result; } //3 do...
C
/* Program to find distance between two given points */ /* Author:Sravanthi_yachareni */ #include<stdio.h> #include<math.h> void main() { float x1,y1,x2,y2,xd,yd,Distance; printf("Enter first point(x1,y1)"); scanf("%f%f",&x1,&y1); printf("Enter second point(x2,y2)"); scanf("%f%f",&x2,&y2); xd=x2-x1; yd=y2-y1; ...
C
#include <stdio.h> #include <termios.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <sys/select.h> /*-------------------------------------------------------*/ static struct termios initial_settings, new_settings; static int peek_character = -1; /*----------------------------------------------...
C
#include<stdio.h> #include<string.h> int main(void) { char str[100]; gets(str); int len,i; len=strlen(str); if(len%2!=0) {str[(len-1)/2]='*'; }else { str[len/2]='*'; str[(len/2)-1]='*'; } printf("%s",str); return 0; }
C
/*ip: 3 op: ***** *** * */ #include <stdio.h> #include <stdlib.h> int main() { int n,i,j; printf("Enter the number of rows:"); scanf("%d",&n); printf("The inverted triangle :\n"); for(i=0;i<n;i++) { for(j=0;j<2*n-1;j++) { if(i+...
C
#define OK 1 #define ERROR 0 #define TRUE 1 #define FALSE 0 #define MAXSIZE 20 typedef int Status; typedef int ElemType; typedef struct { ElemType data[MAXSIZE]; int length; }SqList; Status ListInsert(SqList *L, int i, ElemType e)/*将元素插入线性表*/ { int k; if (L -> length == MAXSIZE) return ERROR; if (i < 1 || i > ...
C
#include <stdio.h> #include <stdlib.h> #include <inttypes.h> #include "Lec1_st03983_A3_malloc.h" int main(int argc, char *argv[]) { my_init(); /* printf("%" PRIuPTR "\n", (uintptr_t)head); printf("%d\n", head->size); printf("%d\n", sizeof(node_t)); printf("%d\n", sizeof(node)); */ ...
C
#include<stdio.h> int main() { int dDivisors = 0; int counter = 0; int dN = 1; while(counter<=999) //the code ignores 2 numbers, so we have two number less to count! { dN+=2; for(int j = 1; j<=dN; j++) if (dN%j == 0) dDivisors++; if (dDivisors==2) counter++; dDivisors = 0; } pri...
C
#include <stdio.h> #include <stdlib.h> #include "list.h" ////////////////////////////////////////////////////////////////////// // // OPERATION:RANGE - Determine the RANGE of info values from a // list of nodes. // int main() { ////////////////////////////////////////////////////////////////// //...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* parse.c :+: :+: :+: ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* push_swap_main.c :+: :+: :+: ...
C
// https://en.wikipedia.org/wiki/Consistent_Overhead_Byte_Stuffing #include "codec.h" #define StartBlock() (code_ptr = dst++, code = 1) #define FinishBlock() (*code_ptr = code) size_t stuffData(const uint8_t *ptr, size_t length, uint8_t *dst) { const uint8_t *start = dst, *end = ptr + length; uint8_t code, *code_pt...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <ctype.h> #include <sys/socket.h> #include <sys/types.h> #include <sys/stat.h> #include <arpa/inet.h> #include <fcntl.h> #include <netdb.h> #include "cJSON.h" #include <ctype.h> #include <signal.h> #include <errno.h> #...
C
#include <REGX52.H> void delay(unsigned int t) //ʱ { unsigned char n = 0;; for(;t > 0;t-- ) for(n = 0;n <125;n++); } void main() { unsigned char i,j; unsigned int led; while(1) { delay(500); led = 0xfe; for(i = 0;i < 8;i++) { P1 = led; ...
C
#include<stdio.h> main() { int x[]={1,2,3,4,5,6,7,8,9,0},y[10],m,*p,i,j,k=0; printf("\nEnter number of numbers"); scanf("%d",&m); printf("\nEnter the numbers"); for(i=0;i<m;i++) scanf("%d",&y[i]); p=y; for(i=0;i<10;i++) { if(k==m)break; else for(j=0;j<m;j++) if(*(p+j)==x[i])printf("%d ",x[i]); ...
C
#include "holberton.h" /** * print_binary - check the code for Holberton School students. * @n: number * Return: Always 0. */ void print_binary(unsigned long int n) { int i, j = 0, result; unsigned long int k; if (n == 0) _putchar('0'); k = n; while (k != 0) { k = k >> 1; j++; } for (i = j - 1; i >...
C
#include<stdio.h> #include<conio.h> #include<stdlib.h> struct node { int info ; struct node *llink ; struct node *rlink ; }; typedef struct node *NODE ; NODE getnode() { NODE t ; t = (NODE) malloc(sizeof(struct node)); return t ; } NODE insertfront(NODE head , int item ) { NODE t , cur ; ...
C
#include "../inc/pathfinder.h" static int *fourth_check(int *k_l_con, char **splite, char **arr) { int er = 0; int len = mx_strlen("error: invalid number of islands\n"); while (er < k_l_con[1]) { if (mx_strcmp(splite[k_l_con[0]], arr[er]) == 0) { k_l_con[1]--; k_l_con[0]++;...
C
#include "requirments.h" int sumOfSquaresOfSides(int a,int b) { return (pow(a,2)+pow(b,2)); } int pythogreanTripletCondition(int a,int b,int c) { int lhs,rhs; lhs = rhs = 0; if(a > b && a > c) { lhs = sumOfSquaresOfSides(b,c); rhs = pow(a,2); #ifdef DEBUG { ...
C
/* * open.c -- * Test of the open system call. This does timing tests or * error condition testing. */ #include <sprite.h> #include <stdio.h> #include <sys/types.h> #include <sys/time.h> #include <sys/file.h> #include <sys/stat.h> #include <option.h> Boolean timing = FALSE; Boolean errorTest = FALSE; Option opt...
C
#include "amo_net.h" struct sockaddr_in si_other; int net_connect() { int sock; if ((sock=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))==-1) { perror("socket()"); exit(1); } memset((char *) &si_other, 0, sizeof(si_other)); si_other.sin_family = AF_INET; si_other.sin_port = htons(PORT); if (inet_...
C
unsigned power(unsigned x, unsigned y) { if (x == 0 && y == 0) return 1; if (x == 0) return 0; if (y == 0) return 1; if (y == 1) return x; unsigned pow = power(x, y/2); if (y % 2 == 0) return pow * pow; return x * pow * pow; }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* char_handling_fts.c :+: :+: :+: ...
C
#include <stdio.h> #include <string.h> #include <limits.h> #include <stdint.h> #include <sys/types.h> #include <sys/stat.h> #include "t_error.h" #include "pread.h" #include "log.h" #include "procmem.h" #include "process_info.h" static bool file_exists(char const * filename); extern intptr_t get_process_base_addre...
C
/* @ requires tab est un tableau avec deux dimensions, size est la taille d'une dimension @ assigns @ ensure afficher le tableau */ /* @ requires tab est un tableau avec deux dimensions, size est la taille d'une dimension @ assigns @ ensure afficher le tableau */ void affiche(int tab[100][100], int ...
C
/** * @file AllMyVariables.h * @author Team Elizabeth * @date 5th october 2016 * @brief This defines all of our variables * / /*Required include files*/ #include <p18f4520.h> #include "MotorInputDefs.h" /*First argument is the value to be written to the output pins to determine direction*/ void Set...
C
#include <stdio.h> #include <stdlib.h> int main() { int n; printf("Please enter a odd number.\n\n"); scanf("%d",&n); if(n%2==0){ printf("Please enter a valid odd number."); } else{ patternPrinter(n); } } void patternPrinter(int n){ for(int i = 1;i<(n+1)/2;i++){{ ...
C
#include <conio.h> #include <conio.h> void main() { int smallest, secondsmallest, i, n; int str[25]; printf("enter the array size"); scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &str[i]); } if (str[0] < str[1]) { smallest = str[0]; secondsmallest = s...
C
#include "binary_trees.h" /** * binary_tree_rotate_right - rotate a root node right * @root: the current root node * Return: the pointer to the new root node */ btt *binary_tree_rotate_right(btt *root) { btt *r = root; btt *l; btt *mid; if (root == NULL || root->left == NULL) return (NULL); l = r->left; ...