language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include<iostream> using namespace std; bool verifyIfBst(int* seq,int length) { int i, j; int root = seq[length-1]; for(i=0;i<length-1;i++) { if(seq[i]>root) break; } j=i; for(;j<length-1;j++) { if(seq[j]<root) { return false; } } bool left = true; if(i>0) left = verifyIfBst(se...
C
#include <stdlib.h> #include <ucontext.h> void makecontext(ucontext_t *ucp, void (*fn)(void), int argc, void *arg) { unsigned long stack = (unsigned long) ucp->uc_stack.ss_sp; unsigned long stack_size = ucp->uc_stack.ss_size; if (argc != 1) abort(); /* need to push stack pointer, f as ip and data as first arg */...
C
#include <stdio.h> #include <stdlib.h> int main(){ char *p = (char *)malloc(50*sizeof(char)); gets(p); int upper_count=0, lower_count=0, space_count=0, num_count=0,other=0; int i=0; while(p[i] != '\0'){ if((p[i]-'A')>=0 && (p[i]-'Z')<=0) upper_count++; else if((p[i]-'a')>=0 && (p[i]-'z')<=0) lower_count++; ...
C
#include "Types.h" void kPrintString(int iX,int iY,const char *pcString); void Main(void) { kPrintString(0,10,"Switch To IA-32e Mode Success~!!"); kPrintString(0,11,"IA-32e C Language Kernel Start..............[Pass]"); } void kPrintString(int iX,int iY,const char *pcString) { CHARACTER *pstScreen = (CHA...
C
#include <stdio.h> #include <stdbool.h> #include <string.h> #include <stdlib.h> #include "./parser/include/eis_parser.h" bool success(int parser, EIS_ERROR errcode){ char txt[10000]; int actual_chars; if (errcode == eis_err_none) return true; for (int i=1; i<=eis_parser_get_error_count(parser); ++i){ actua...
C
#ifndef HASHSET_H #define HASHSET_H typedef enum {false, true} bool; struct _myhashset; typedef struct _myhashset MyHashSet; MyHashSet* myHashSetCreate(); void myHashSetAdd(MyHashSet* obj, int key); void myHashSetRemove(MyHashSet* obj, int key); bool myHashSetContains(MyHashSet* obj, int key); void myHashSetFree(MyHas...
C
/** * Name: solution.c * Purpose: Sum of Digits ot a Five Digit Number * Author: Gafur Hayytbayev */ #include <stdio.h> void sum_of_digits(int n) { int sum = 0; int a[5] = {0,0,0,0,0}; for(int i=0, j=1;i<5;i++, j=j*10) { a[i] = ((n-a[3]*1000-a[2]*100-a[1]*10-a[0])/j)%10; sum=sum+a[i]; } printf("%d\n", ...
C
#include <stdio.h> #include <stdlib.h> void display(); void insertAtBeginning(); void deleteAtBeginning(); void deleteAtEnd(); void deleteAtPosition(); int length(); struct node { int data; struct node *prev, *next; }; struct node *head = NULL, *tail; void createLinkList() { struct node *newnode; newnod...
C
typedef struct element { int val; struct element* next; } element_t; typedef struct list { element_t* head; element_t* tail; } list_t; list_t* list_create( void ); void list_destroy( list_t* list ); element_t* element_create( int i ); int list_append( list_t* list, int i ); int list_prepend( list_...
C
#include <stdlib.h> #include <stdio.h> int main() { long long int array1[10][10]; long long int array2[10][20]; // directly nested loop int i,j; for(i = 0; i < 10; ++i) { for(j = 0; j < 10; ++j) { array1[i][j] = (long long)rand(); } } // 2 directly nested loops for(i = 0; i < 10; ++i) { for(j = 0; j...
C
/* Part of Measurement Kit <https://measurement-kit.github.io/>. Measurement Kit is free software under the BSD license. See AUTHORS and LICENSE for more information on the copying conditions. */ #ifndef MEASUREMENT_KIT_FFI_H #define MEASUREMENT_KIT_FFI_H /* * Measurement Kit Foreign-Function-Interface (FFI) AP...
C
#include "fileIO.h" int maxBookId(){ int savedat1, savedat2; BookNode *head = bookMemAlloc(), *curr = NULL; curr = head->nextNode; savedat1 = curr->book.bookId; while(curr->nextNode != NULL){ curr = curr->nextNode; savedat2 = curr->book.bookId; if(savedat1 < savedat2){ savedat1 = savedat2; } } cur...
C
/* * ===================================================================================== * * Filename: kernel.c * * Description: * * Version: 1.0 * Created: 10/16/2015 11:22:24 AM * Revision: none * Compiler: gcc * * Author: Axel Fahy, Rudolf Hohn * Orga...
C
#include <stdio.h> #include <stdlib.h> #include <stdint.h> int main(int argc, char *argv[]) { // ensure proper usage if (argc != 2) { fprintf(stderr, "Usage: ./recover image\n"); return 1; } char *infile = argv[1]; char outfile[7]; FILE *inptr = fopen(infile, "r")...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* philo.c :+: :+: :+: ...
C
/* *** OS Spring 2013 *** Priject #2 *** *** Payam Mohajeri *** 89522237 *** *** Ayyoob Imani *** 89521089 *** */ #include "utility.h" int IO_ReadLine(char* input) { char buf = 0; int size = 0; strcpy(input, ""); int rc = read(STDIN, &buf, 1); if (rc < 0) return rc; while (buf != 13 && buf != 10) { ...
C
#include <stdio.h> #define MAX 100 main() { int i,j,n,m,mat[MAX][MAX],s[MAX],p,min; printf("Matrica je mxn, unesite n: "); scanf("%d", &m); printf("Matrica je mxn, unesite n: "); scanf("%d", &n); printf("uneta matrica: \n"); for(i=0;i<m;i++) for(j=0;...
C
/* * Copyright (c) 2013-2017 Ilya Kaliman * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISC...
C
#include <stdint.h> #include <stdio.h> extern uint64_t sm64; extern uint64_t sm64_next(); #define SEED1 1387366483214 int main() { int i; sm64 = SEED1; for (i = 0; i < 10; i++) { uint64_t z = sm64_next(); printf("\t0x%016lX,\n", z); } return 0; }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main04.c :+: :+: :+: ...
C
// PR c++/79937 // This is a constexpr adaptation of pr79937-3.C and pr79937-4.C. // { dg-do compile { target c++14 } } struct X { unsigned i; unsigned n = i; }; constexpr X bar(X x) { return x; } struct Y { static constexpr Y bar(Y y) { return y; } unsigned i; unsigned n = bar(Y{2,i}).n; }; constexpr X...
C
#include <stdio.h> #include <stdlib.h> #include "merge.h" void merge( int * A , int * B, int * M,int len_A, int len_B ) { int i=0; int j=0; while(i< len_A && j< len_B) { if (A[i] < B[j]) { M[i+j]=A[i]; i++; } else{ M[i+j]=B[j]; j++; } } while(i<len_A) //lorsque len_A > Len_B on remp...
C
#include <stdio.h> #include <stdlib.h> struct cadastro { char nome[20], rua[20]; int idade; }; int main() { /*Em geral, o acesso a um arquivo é quase sempre feito de modo sequencial. Porém, a Linguagem C permite realizar operações de leitura e escrita randômica usando a função fseek() //Forma...
C
#include <stdio.h> struct S1 { long Arr[10]; }; typedef char Type; int main() { struct S1 Brr[10]; Type * ptr1 = (Type *) Brr[6].Arr; Type * ptr2 = (Type *) Brr[2].Arr; printf("ptr1 - ptr2 = %ld\n", ptr1-ptr2); return 0; }
C
#include "assignment3.h" void insertbuffer(buffer_t value) { if (buffer_index < SIZE) { buffer[buffer_index++] = value; } else { printf("Buffer overflow\n"); } } buffer_t dequeuebuffer() { if (buffer_index > 0) { return buffer[--buffer_index]; // buffer_index-- wo...
C
#include <signal.h> #include <sys/types.h> #include <stdio.h> int main(int argc, char *argv[]) { sigset_t set; int sig_ret; int i = 0; sigemptyset(&set); sigaddset(&set,SIGINT); sigprocmask(SIG_BLOCK,&set,NULL); for(i=0;i<5;i++) { sleep(1); printf("state:block\n"); } sigprocmask(SIG_UNBLOCK,&set,NULL...
C
#pragma once #include <stdbool.h> #include <stdio.h> /* Optional debugging settings, specified at runtime */ extern bool DEBUG; /* Set inside of enumy.c */ extern bool DEBUG_EXTRA; /* Set inside of enumy.c */ /* This function will only be executed if the runtime argument */ /* -d 1 or -d 2 is passed */ #define...
C
/* * Copyright (C) 2017 "IoT.bzh" * Author: José Bollo <jose.bollo@iot.bzh> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unle...
C
// Program to print Sum of 10 inputted numbers and print Sum separately. #include<stdio.h> #include<conio.h> #include<stdlib.h> int main() { int No = 0,sum =0,count =0; printf("\n\t Enter the numbers for its summation "); for(count = 1;count <=10 ;count++) { printf("\n\t Enter Number %d =",...
C
#include "sort.h" /** * shell_sort - Sorting function in ascending order using the ShellSort * sort algorithm using the knuth sequence. * * @arr: The integer array that will be sorted. * * @size: The size of the integer array. * * Return: Always nothing (VOID). */ void shell_sort(int *arr, size_t size) { ...
C
#include <linux/module.h> #include <linux/sched.h> #include <linux/pid.h> #include <linux/wait.h> #include <linux/list.h> #include <linux/kthread.h> #include <linux/delay.h> #include <linux/kallsyms.h> #include <linux/mm_types.h> #include <linux/sched/mm.h> #include <linux/pid_namespace.h> // cat /proc/kal...
C
#include <stdio.h> #include <unistd.h> int main() { int i = 100; write(stdout, "hello = %d", i, 1000); }
C
#include "binary_search.h" int binary_search(int arr[], int size, int item) { int low = 0; int high = size - 1; while (low <= high) { int mid = (low + high) / 2; int guess = arr[mid]; if (guess == item) { return mid; } else if (guess > item) ...
C
#include<stdio.h> struct node{ int data; struct node *next; }; struct node *newnode,*temp,*head=0; struct node *head1=0; struct node *head2=0; struct node *head3=0; struct node *head4=0; void insert(int d,struct node **head) { newnode=(struct node*)malloc(sizeof(struct node)); newnode->data=d; ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* check_stack.c :+: :+: :+: ...
C
/* * multi_task_management.h * * Created on: 20181025 * Author: Linuxer */ #ifndef _MULTI_TASK_MANAGEMENT_H_ #define _MULTI_TASK_MANAGEMENT_H_ #define MAX_TASK_NUM 10 #define USER_TASK_DEFAULT_PRIORITY 13 #define MAIN_PAGE_FIRST_LINE 20 #define MAIN_PAGE_LINE_SPACE 18 #define MAIN_PAGE_LINE_MARG...
C
#include <stdio.h> float media(){ float soma=0; float entrada = 0; int contador = 0; while (entrada != 99){ printf("digite a nota %d : ", contador+1); scanf("%f", &entrada); if (entrada != 99){ soma = soma + entrada; contador = contador + 1; } ...
C
#include "PE43702.h" void PE_GPIO_Init(void) { /* LE: C5 CLK: C6 DATA: C7 */ GPIO_InitTypeDef GPIO_InitStructure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE); //ʹPE˿ʱ GPIO_InitStructure.GPIO_Pin =GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//ͨģʽ GPIO_InitSt...
C
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> typedef struct node { int data; struct node* next; }Node; int Length(Node*); Node* BuildOneTwoThree(); void Push(Node** , int ); void printList(Node* ); void deleteList(Node* ); void Insert(Node** , int , int ); int main() { int num; Node* ...
C
#include <sys/wait.h> #include <sys/stat.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include "commands.h" int lsh_mv(char **args) { FILE *ifp, *ofp; if (args[1] == NULL || args[2] == NULL) { fprintf(stderr, "lack of arguments for function \"mv\"\n"); exit(EXIT_FAILURE); } ...
C
#include <stdio.h> #include <stdlib.h> struct B_psTree { struct train_data {double cal_priority; int trian_id; }; struct train_data train_data_1; struct B_psTree *lprt; struct B_psTree *rprt; }; typedef struct B_psTree node; node *createtree(node *root); node *insert(t...
C
// // L01_Functions.h // Unit02_lesson01_understanding_functions // #ifndef L01_Functions_h #define L01_Functions_h #include <stdarg.h> #include "BinaryTree.h" struct listNode { int data; struct listNode *next; }; int sumOfDigits(int number); int sumOfDigitsMystery(int number); int heightOfTree(struct tr...
C
#include <stdio.h> #include <stdlib.h> struct array{ int *A; int size; int length; }; void Display(struct array *arr){ printf("Elements are:\n"); int i = 0; for(i = 0; i < arr->length; i++){ printf("%d\n",arr->A[i]); } } void MergeArrays(struct array *arr1, struct array *arr2, stru...
C
/* | PC-LISP (C) 1984-1989 Peter J.Ashwood-Smith */ #include <stdio.h> #include <math.h> #include <time.h> #include "lisp.h" /************************************************************************* ** (sys:time) Will return the time in seconds since the OS's idea of ** ** creation. On UNIX this is Jan 1 GMT,...
C
#include<studio.h> int main() { printf("Welcome to master branch"); time_t mytime; struct tm *mylocaltime; mytime=time(NULL); mylocaltime=localtime(&mytime); printf("Year:%d\n",mylocaltime->tm_year+1900); printf("version: 0002\n"); printf("hello world!\n"); return 0; }
C
/*运用逗号表达式进行赋值*/ #include "stdio.h" int main(void){ int a = (1,2); printf("a:%d\n",a); return 0; }
C
// ;**************************************************************************************************************************** // ;Program name: "root". This program demonstrates the input of 3 numbers and using them * // ;to calculate the roots of a quadratic formula. Copyright (C) 2021 Nicholas Ayson. ...
C
#include "holberton.h" /** * *_strncpy - function that copies a string. *@dest : char *@src : char *@n : int * Return: nothing */ char *_strncpy(char *dest, char *src, int n) { int i; int j; j = 0; for (i = 0 ; dest[i] != '\0' ; i++) {} while (j < n && src[j] != '\0') { dest[j] = src[j]; j++; } for (; j < n ; j++...
C
#include <stdio.h> int main(void) { int n = 42; // Declare and initialise n. printf("The value of n is %i.\n", n); // Print n (inside format string). return 0; } /**** * * Note: * * Variable names in C consist of a letter [a-zA-Z], followed by any * number of letters, underscore...
C
#include <stdio.h> main() { printf("\n =|------------------------|=\n"); printf(" ==| Azis Jabbar Susetio |==\n"); printf(" ===| 4210141021 |===\n"); printf(" ==| 1 - D4 Game Technology |==\n"); printf(" =|------------------------|=\n"); int array1[10], array2[10]; ...
C
/* * Função responsável por gravar os dados dos clientes no arquivo físico */ #include "libLocadoras.h" void gravarCliente(char arqFisicoClientes[], Cliente c){ FILE *arq = fopen(arqFisicoClientes, "ab"); if (arq == NULL){ printf("\nErro ao abrir arquivo de Clientes\n"); return; } /* * ...
C
#include <stdlib.h> #include "libPermutation.h" int main (void) { int s, *v; s = 4; v = malloc (s * sizeof (int)); if (!v) { printf ("Fatal error\n"); return 1; } v[3] = 1; v[2] = 2; v[1] = 0; v[0] = 1; ShowVector (s, v); printf ("Inter 7 ?= %d\n", ParserVectorToDigitV2 (s, v)); ShowVector (s, v);...
C
/****************************************************************************** * Copyright (C) 2017 by Ben Heberlein * * Redistribution, modification or use of this software in source or binary * forms is permitted as long as the files maintain this copyright. This file * was created for the University of Colorado Bou...
C
#include "debugDisplay.h" #include <string.h> #include <stdarg.h> #define VID_MEMORY 0xB8000 static unsigned int _xPos=0, _yPos=0; static unsigned _startX=0, _startY=0; static unsigned _color=0; void debugPutc(unsigned char c) { if(c==0) return; if(c=='\n' || c=='\r') { _yPos++; _xPos = _startX; return; ...
C
#include "device_query.h" #include <stdlib.h> #include <stdio.h> #include <string.h> int main(int argc, char** argv) { if(argc < 2) { fprintf(stderr, "usage: %s <function>\n", argv[0]); return 0; } if(strcmp(argv[1], "query") == 0) { device_query(); } else { fprint...
C
#include "helpers.h" #include <math.h> // Convert image to grayscale void grayscale(int height, int width, RGBTRIPLE image[height][width]) { RGBTRIPLE tmp[height][width]; for(int i = 0; i < height; i++) { for(int j = 0; j < width; j++) { tmp[i][j] = image[i][j]; } } ...
C
#include<stdio.h> void main(){ int a = 20; double b = 15.6; int c; c = a + b; printf("%d",c); } /*-------explanation------------ a = 20 //type int b == 15.6 //double c= (garbege) //type int c = a+b = 20 + 15.6 // addition of two double or float value is alwys double value = 35.6 c = 35 // but we are storin...
C
#include<stdio.h> #include<stdlib.h> int main(void) { char name; int id=0; int a=0,b=0,c=0; scanf("%c\n%d\n%d\n%d\n%d",&name,&id,&a,&b,&c); printf("Name:%c\nID:%d\nAverage:%d\nTotal:%d\n",name,id,((a+b+c)/3),(a+b+c)); return 0; }
C
#include <stdlib.h> #include <stdio.h> #include "lists.h" /** * delete_nodeint_at_index - delete node at index * @head: head of a linked list * @index: index of a a node * * Return: 1 or -1 */ int delete_nodeint_at_index(listint_t **head, unsigned int index) { unsigned int i = 0; listint_t *tempNode1, *tempNo...
C
#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> #include<stdlib.h> #include<string.h> //1.ʵһַеkַ //ABCDһַõBCDA //ABCDַõCDAB //2.жһַǷΪһַתַ֮ //磺s1 = AABCDs2 = BCDAA1s1 = abcds2 = ACBD0. //AABCDһַõABCDA //AABCDַõBCDAA //AABCDһַõDAABC //1.abcdef -> a , bcdef -> bcdefa(ѭkΣkַ //жǷַĺ is_left_move(char* str1, char* st...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <inttypes.h> // Define estrutura para o Bitmap typedef struct { int32_t width; int32_t height; unsigned int rowwidth; uint16_t depth; unsigned char *data; } bitmap_t; // Le o bitmap de um arquivo // Retorna o bitmap lido no parametro bitmap int...
C
#include <stdio.h> #include <stdlib.h> int **malloc2dR(char *nomefile,int *nr, int *nc) { int **m; FILE *fp=NULL; int i=0,j=0,r,c; fp=fopen(nomefile,"r"); if(fp==NULL) exit(printf("\n Errore apertura file")); fscanf(fp,"%d %d",&r,&c); // alloco la matrice m=malloc(r*sizeof(int*)...
C
#include "drivers/keyboard.h" #include "io.h" #include "scan.h" #include "terminal.h" #include "print.h" void init_keyboard_driver() { outb(0x21, 0xfd); outb(0xa1, 0xff); } uint8_t KeyboardHandler() { uint8_t state = inb(0x64); while (state & 1 && (state & 0x20) == 0) { uint8_t scan = inb(0x60); ...
C
/* Բ飬ܹnˣÿM ӦԱȥM, һ */ #include <stdio.h> #define TOTAL_NUM 30 #define COUNT 6 static void print_status(char *arr) { int i; for (i = 0; i < TOTAL_NUM; i++) { printf("%2d", arr[i]); } printf("\n"); } int main(int argc, char const *argv[]) { char array[TOTAL_NUM] = ...
C
#include<stdio.h> #include<sys/types.h> #include<sys/socket.h> #include<netinet/in.h> #include<string.h> #include<netdb.h> #include<stdlib.h> #include<unistd.h> #include<arpa/inet.h> #define PORT 7228 int main(int argc,char **argv) { int sockfd, ret,len,n; struct sockaddr_in serverAddr; int newfd; struct sockadd...
C
#include <string.h> #include <dirent.h> #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <pthread.h> #include "multiThreadSorter.h" int cT=0; node* master = NULL; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; typedef struct _thread_args{ char* directory; char* s...
C
#include <stdio.h> int main() { long int a,b,c; int n,cont; double r; printf("Enter how many terms of the Fibonacci sequence you want: \n"); scanf("%d", &n); if (n <= 1) { printf("Error\n"); } else { a = 1; b = 1; cont = 2; printf("\n\n1\n1\n"); while(cont < n) { c...
C
#include "header.h" //afisarea cu ajutorul unei funciti recursive void afisareRecurs(FILE *fisier_output, int *parent, int index, int start) { if(index == start) fprintf(fisier_output, "%d ", start); else { afisareRecurs(fisier_output, parent, parent[index], start); fprintf(fisier_ou...
C
/* ** EPITECH PROJECT, 2018 ** CPool_2018 ** File description: ** Maxence Carpentier */ int my_is_prime(int nb) { int result = 0; if (nb <= 1) return (0); for (int i = 1; i < nb; i+=4) if (nb % i == 0) result++; if (result > 1) return (0); else return (1...
C
#include <stdio.h> #include <string.h> int main() { char num[50]; int result = 10,i; scanf("%s",num); int len = strlen(num); printf("%d\n",len); for(i=1;i<len;i++) { if(num[i] == '(' && num[i-1] == '(') { result +=5; } else if(num[i] == ')' && num[i-1] ==')') { result +=5; } else res...
C
#pragma once #include "Global.h" typedef struct _Point Point; struct _Point { Coordinate x ; Coordinate y ; } ; Point * Point_new (void) ; //Point ü ϴ ⺻ Point * Point_newWithXYCoordinates (Coordinate x, Coordinate y) ; //־ (X,Y) ǥ Ǵ ü ϴ void Point_free (Point * _this) ; //Ҹ Coordinate Point_xCoordinate (Point ...
C
#include <stdio.h> #include <stdlib.h> #ifndef NINTH_H_ #define NINTH_H_ typedef struct _Node_ Node; Node* Node_Construct(int element, Node* leftChild, Node* rightChild); void Node_Destroy(Node* node); int BinarySearchTree_GetInOrderSuccessor(Node* root); Node* BinarySearchTree_DeleteInOrderSuccessor(Node* root, i...
C
/*! mana (library) @file libmana.c @brief システム全体に関するソースファイル @detail このファイルはライブラリ全体に関係するソースファイルです。 @author Shun Moriya @date 2003- */ #if !defined(___LIBMANA_H___) #include "libmana.h" #endif #include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #if defined(_WIN32) #include ...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> char get_frequent_character(char* line) { int* v = (int*)calloc(127, sizeof(int)); char frequent_character; int maximum = 0; int i; for(i = 0; i < strlen(line); i++) { v[((int) line[i])]++; } for(i = 0; i < strlen(line); i++) { if(v[((int) line[i])...
C
/* ** EPITECH PROJECT, 2021 ** PARTICULES ** File description: ** main */ #include "struct.h" #include "define.h" #include "function.h" #include <time.h> float get_random_float(float const min, float const max) { return ((float)rand() / (float)(RAND_MAX) * (max - min) + min); } sfColor get_random_color(unsigned ...
C
#include "dbp.h" #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <string.h> #include <ctype.h> #include <errno.h> #include <unistd.h> #include <sys/time.h> #include <sys/types.h> #include <limits.h> #include <sys/inotify.h> #include "mountwatch.h" #include "config.h" /* I keep almost typing mouthw...
C
/* CI.H ---- */ #include "CI.h" /* STRUCT COMPARE_REV ------------------ */ static struct compare_rev { inline int operator() (uint16_t *a, uint16_t *b) const { return *a < *b ? 1 : *a > *b ? -1 : (a < b ? 1 : a > b ? -1 : 0); } } cmp; /* MIN() ----- */ static inline uint32_t min(uint32_t a, uint32_t b) { retu...
C
/* ** map.c for emacs in /home/jules/Info/tekadventure/src ** ** Made by Jules Spender ** Login <louis.chegaray@epitech.eu@epitech.net> ** ** Started on Tue May 16 17:17:39 2017 Jules Spender ** Last update Sun May 28 22:31:37 2017 blaise carnevillier */ #include "my_h3.h" int do_move(sfEvent event, t_cobble *en...
C
/**************************************************************************//** * @file main.c * @version V0.10 * @brief Capture the PWM0 Channel 0 waveform by PWM0 Channel 2, and use PDMA to transfer captured data. * * SPDX-License-Identifier: Apache-2.0 * @copyright (C) 2019 Nuvoton Technology Corp. All...
C
#define NULL ((void*)0) typedef unsigned long size_t; // Customize by platform. typedef long intptr_t; typedef unsigned long uintptr_t; typedef long scalar_t__; // Either arithmetic or pointer type. /* By default, we understand bool (as a convenience). */ typedef int bool; #define false 0 #define true 1 /* Forward d...
C
#include <stdio.h> void main(){ int n, sum = 0; printf("Enter a number to see if it is an Armstrong Number: "); scanf("%d", &n); int q = n; while(q){ int p = q%10; q = q/10; sum += p*p*p; } if(sum == n) printf("%d is an Armstrong number.\n", n); el...
C
#include "libft.h" char *ft_strsub(char const *s, unsigned int start, size_t len) { char *res; if (s == NULL) return (NULL); if ((res = malloc(sizeof(char) * (len + 1))) == NULL) return (NULL); res = ft_strncpy(res, &s[start], len); res[len] = '\0'; return (res); }
C
//James Current //display inspired by hanoi.c from JustForFun section @ //http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/index.html #include <curses.h> #include <stdlib.h> #include <string.h> #define POSX 10 #define POSY 5 #define DISK_CHAR '#' #define PEG_CHAR '|' //a peg is an array of disk sizes typedef struct{ ...
C
#include "node.h" struct deck { node* rightmost = nullptr; node* leftmost = nullptr; int length = 0; }; void PushFront(deck& d, number n); void PushBack(deck& d, number n); number PopFront(deck& d); number PopBack(deck& d); number Front(deck& d); number Back(deck& d); int Size(deck& d); void Clea...
C
int prime (int x) { int i,p=1; for (i=2;i<=sqrt(x);i++) { if (x%i==0) { p=0;break; } } return p; } int main () { int n; scanf ("%d",&n); int i=6; while (i<=n) { int j=3; while (j<=i/2) { if (prime(j)) if (prime(i-j)) { printf("%d=%d+%d\n",i,j,i-j); bre...
C
#include <stdio.h> #include <stdlib.h> //exit, rand, srand #include <unistd.h> //pipe, close, fork, usleep, read, write, getpid, getppid #include <sys/wait.h> //wait #include <errno.h> //Control de errores #include <string.h> //strerror #include <time.h> //Para la semilla del generador de aleatorios int main() { // P...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_play.c :+: :+: :+: ...
C
#include<stdio.h> int main(){ //pyramid using alphabets int i,j; char input, alphabet = 'A'; printf("Enter the character you want to print\N"); scanf("%c", &input); for(i=0; i<(input-'A'+1); i++) { for(j=0; j<=i; j++) { printf("%c", alphabet); } alphabet++; p...
C
#include <errno.h> #include <stdio.h> #include "flat_gen.h" uint32_t binary[(1<<ROM_ADDR_BITS)-1]; /* Generates a flat rom binary image*/ void emit_binary() {} /* Generates an address into the rom for the given parameters */ uint32_t emit_addr(size_t opcode, char zero, char interrupt, char step) { uint32_t tmp = z...
C
#include<stdio.h> #include<stdlib.h> #include<pthread.h> #define NUM_THREADS 8 void *threadFunction(void * data) { int threadNumber = *((int *) data); printf("Hello world from thread %d\n", threadNumber); return NULL; } int main(void) { pthread_t threadNumber[NUM_THREADS]; int threadData[NUM_THREADS];...
C
#include <stdio.h> // inicio da funo principal int main() { // declarao de variveis iniciais int gasto[12]; int chuva[12]; int reservatorio = 0; int reservatorio_max = 0; int i = 0; // declarao array de char que sera usada na entrada das chuvas e dos gastos por ms char meses[12][100] = { "Janeiro"...
C
/* Copyright 2015 Jonathan Watmough Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software di...
C
#include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <stdlib.h> #include <netinet/in.h> #include <arpa/inet.h> #include <string.h> #include <time.h> #include <sqlite3.h> #include <pthread.h> #define N 512 #define DATABASE "database.db" #define R 1 #define O 2 #define Q 3 #def...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* realloc.c :+: :+: :+: ...
C
#include "holberton.h" /** * _memset - constand byte * @s: pointed variable * @b: constant byte * @n: function fills the first * Return: _memset */ char *_memset(char *s, char b, unsigned int n) { unsigned int c; for (c = 0; c < n; c++) { s[c] = b; } return (s); }
C
#include <stdio.h> #include <stdint.h> #include <stdlib.h> uint64_t euclid(uint64_t,uint64_t); void check(uint64_t a, uint64_t b, uint64_t c) { if (euclid(a,b) != c) { printf("ERROR: euclid(%lu, %lu) != %lu\n",a,b,c); exit(1); } } int main(__attribute__((unused)) int argc, __attribute__((unu...
C
/* ** EPITECH PROJECT, 2018 ** null ** File description: ** null */ #include "minishell.h" int my_str_isnum_remastered(char const *str) { int i = 0; while (str[i] != 0) { if (str[i] < 48 || str[i] > 57) return (0); i++; } return (1); } int check_badly_next(char *s, int number, int letter) { if ((letter ...
C
/*-------------- Telecommunications & Signal Processing Lab --------------- McGill University Routine: FiltAudio [options] -f FilterFile AFileI AFileO Purpose: Filter data from an audio file Description: This program takes an audio file and a filter coefficient file as input and ...
C
/* Header file for queue implementation. */ #ifndef QUEUE_H #define QUEUE_H #include <stdlib.h> #include <stdio.h> struct queue { int capacity, current_size, front, elements[]; }; struct queue * create_queue (const int); void enqueue (struct queue *, const int); int dequeue (struct queue *); void delete_queue (str...
C
// A BOINC compatible fitness calculation routine for the Orphan FILE* density profile project // B. Willett Feb. 25, 2010 // Adapted for use with B&H treecode May 11, 2010 // Takes a treecode position, converts it to (l,b), then to (lambda, beta), and then constructs a histogram of the density in lambda. // Then ca...