language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include "line.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_LINE_LEN 60 // char line[MAX_LINE_LEN + 1]; struct node { struct node *next; char word[]; } *line = NULL; int line_len = 0; int num_words = 0; void clear_line(void) { struct node *temp; while (line) { temp = line; ...
C
#include <stdio.h> #include <stdlib.h> int * randx(int n) { int * vec = (int *)malloc(sizeof(int) * n); return(vec); } int main(int argc, char ** argv){ int n = 1000000; int m = 1000; int * x = randx(n); int * y = randx(n); int * p = (int *)malloc(sizeof(int) * n); int ix = 0; f...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* fmt_d.c :+: :+: :+: ...
C
#include "binary_trees.h" /** * binary_tree_depth - function that measures * the depth of a node in a binary tree * @tree: pointer with the address of node * Return: size of depth or 0 if NULL */ size_t binary_tree_depth(const binary_tree_t *tree) { size_t depth; if (!tree) return (0); for (depth = 0; tree->p...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* handle_error.c :+: :+: :+: ...
C
/* see page 65 */ /* DOW = 0 for Sunday, ..., 6 for Saturday */ #ifdef ASTROALGO #include <math.h> #include <stdio.h> #include "AstroAlgo.h" __declspec(dllexport) short __stdcall #else short #endif ShDayOfWeek(short *pshDOW, double doY, double doM, double doD) { short shReturnValue = (short) ...
C
#include <io.h> int putchar(int c) { volatile *uart_data = ADDR_UART_DATA; volatile *uart_stat = ADDR_UART_STAT; while (*uart_stat & UART_TX_BUSY); *uart_data = c; } static char *str = "Hello, World!"; void main(void) { char *c = str; while (*c) { putchar(*c); c++; } }
C
#include "holberton.h" /** * _isupper - print uppercase char * @c: the char * Return: 1, 0 */ int _isupper(int c) { if (c > 64 && c < 91) return (1); else return (0); }
C
#include <linux/proc_fs.h> #include <linux/hugetlb.h> #include <linux/module.h> /* Obtiene el dato en kilobytes */ #define K(x) ((x) << (PAGE_SHIFT - 10)) /* Licencia, Descripción y Autor*/ MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("This module shows information about RAM memory."); MODULE_AUTHOR("grupo30"); stat...
C
int modulo(int a, int b) { int r = a - ((a / b) * b); if (r < 0) r = a - (((a / b) - 1) * b); return r; } int euclides_ext(int a, int b) { int r1 = a, r2 = b; int s1 = 1, s2 = 0; int t1 = 0, t2 = 1; int s; int t; while (r2 > 0) { int q = r1 / r2; int r = r1 - (q * r2); r1 = r2; r2 = ...
C
#include <linux/module.h> /* Needed by all modules */ #include <linux/kernel.h> /* Needed for KERN_ALERT */ MODULE_LICENSE("GPL"); /* Setting Licence to GPL */ int __init ourinitmodule(void) /* Will be called during insmod <module>.ko */ { printk(KERN_ALERT "\n Welcome to sample kernel module.... \n"); ...
C
#include<string.h> #include<sys/types.h> #include<sys/dir.h> int search(char*file, char*dir){ DIR *dirptr=opendir(dir); struct dirent *entry=readir(dirptr); while(entry!=NULL) { if(strlen(entry->d_name)==strlen(file)&&(strcmp(entry->d_name,file)==0) return 0; entry=readdir(dirptr); } return 1; }
C
#include "emp.h" int main(){ int fd = open("em.dat",O_RDONLY); if(fd==-1) perror("open"),exit(-1); struct emp em; while(1){ int res = read(fd,&em,sizeof(em)); if(res==-1) perror("read"),exit(-1); if(!res) break; printf("%d,%s,%lf\n",em.id,em.name, em.sal); } close(fd); }
C
#include "ucode.c" char tokens[16][32]; int numtokens, i; int scan(char *line, char target) { int pos = 0, length = 0; //start from endof string length = strlen(line); //printf("len = %d, line = %s\n", length, line); while(length > 0) { //printf("compare %c to %c\n", line[length], target); //sear...
C
/* File: printTree.c Description: functions for huffman tree printing */ #include "printTree.h" int makePrintQ(node *n, int posL, int posR, int incR, printQ **Q) { treePart part; int lSubTreeWidth; if(n==NULL){ return 0; } if(n->c0!=NULL || n->c1!=NULL){ part = intNd; } els...
C
#include "holberton.h" /** * lenght - Function to know the lenght of the given string. * @s: given string. * Return: Lenght (position of the last char in the string) */ int lenght(char *s) { if (*s) return (1 + lenght(s + 1)); else return (0); } /** * aux_pal - Function that compare the first char with th...
C
#include <stdio.h> #include "stack_op_char.c" #include <string.h> int isOperand(char ch){ return (ch >= 'A' && ch <= 'Z'); } int isOperator(char ch){ return (ch == '+' || ch == '-' || ch == '*' || ch == '/' || ch == '^'); } char stackTop(Stack s){ return s.item[s.top]; } int prece(char ch){ switch(ch){ ca...
C
/** * helpers.c * * Computer Science 50 * Problem Set 3 * * Helper functions for Problem Set 3. */ #include <cs50.h> #include "helpers.h" #include <stdio.h> /** * Returns true if value is in array of n values, else false. */ bool search(int value, int values[], int n) { int highPoint = n; i...
C
#include <errno.h> #include <string.h> #include <stdlib.h> #include <stdio.h> #include "bool.h" #include "err_t.h" #include "array.h" #include "lenstring.h" #include "vector.h" #include "log.h" #include "alloc.h" #include "ast.h" #include "scriptfile.h" #include "lex.h" static unsigned estimate_max_ast_node_count(si...
C
#include <stdio.h> #include <stdlib.h> #include <time.h>//ֵ //׺ʽֵ //תΪ׺ʽֵΪʹջѭ洢ṹʵ //ջ˳洢ṹһάʵ #define OK 1 #define ERROR -1 #define TRUE 1 #define FALSE 0 #define MAXSIZE 10 typedef int Status; typedef char ElemType; typedef struct { ElemType data[MAXSIZE]; int top;//ջָ }Stack; Status ...
C
#include <stdio.h> // printf(), sprintf() int main(void) { char str[10]; int num = 961406; sprintf(str, "%d", num);/* sprintf make the interger with string*/ printf("str = %s\n", str); return 0; }
C
#include <stdio.h> int main(){ FILE *fp; int c; fp = fopen("letters.txt", "w"); for(c='a'; c<='z'; c++) { fputc(c, fp); } fclose(fp); return 0; }
C
#include <unistd.h> int main(void) { char low; char high; int i; i = 0; low = 'a'; high = 'B'; while (i < 13) { write(1, &low, 1); write(1, &high, 1); low += 2; high += 2; i++; } write(1, "\n", 1); return (0); }
C
#include <stdio.h> #include <math.h> #define PI 3.1415926 main() { float x; printf("һǶ: "); scanf("%f",&x); printf("Ϊ: %7.1f\n",sin(x*PI*180)); }
C
/* * ping.c * * Created on: Oct 13, 2015 * Author: jim */ #include <avr/io.h> #include <util/delay.h> #include <stdlib.h> #include "ping.h" inline ping_data_t * newPing() { return malloc(sizeof(ping_data_t)); } inline void freePing(ping_data_t * ping) { free(ping); } volatile unsigned long volatil...
C
#include <stdio.h> #include <stdlib.h> #define INCREMENTO 0.0001 float rzq(float n){ float valor_inc = 0.0001, sair = 1; do{ if((int)(valor_inc * valor_inc) == n){ sair = 0; }else{ valor_inc += INCREMENTO; } }while(sair); return valor_inc; } int main(void){ float n = 0; printf("Entre com o numero ...
C
#include "substring.h" /** * cmp - difference between values * @a: the first var * @b: the second var * Return: 0 **/ int cmp(const void *a, const void *b) { return (*(int *)a - *(int *)b); } /** * check - chek continous words continous * @T: the array with index for ever word * @len: the var word size * @T...
C
#include <avr/io.h> #include <avr/interrupt.h> #include "rtos.h" #include "kbd.h" #include "list_event.h" //============================================================================= void (*pState)(unsigned char event) = INITIAL_STATE; unsigned char timerInterrupt = 0; // volatile static task TaskArray[MAX_TASKS]...
C
#include<stdio.h> int main() { int n,i,p; scanf("%d",&n); for(i=2;i<=n;i+=2) { p=i; p=p*i; printf("%d^2 = %d\n",i,p); } }
C
/* * GPTM_Compare_Mode.c * * Created on: 13-Dec-2019 * Author: black_Pearl */ /* * used for counting number of events * or count the number of rising edge or falling edge */ /* * Capturing the toggle rate of PA5 and PA6 will be input capture * pin */ #include<stm32f4xx.h> int timeStamp =0; int main...
C
#include "spi_flash.h" #include <stdint.h> #define DELAYS 20 //min:128 #define DELAY_us 250 //min:128 uint32_t g_ulM25P16ID = 0 ; void GPIO_ResetBits() { M25P16_CS = 0; } void GPIO_SetBits() { M25P16_CS = 1; } void DelayS(uint16_t delay) { uint8_t i; if(delay > 50) { delay = DELAYS; } for(i = 0;...
C
/* A simple pointer example in C, with lots of comments! */ #include <stdio.h> int main() { /* create a variable */ int number = 8; /* create the integer pointer */ int *ip; /* set the pointer equal to the address (location) of number */ ip = &number; /* print the address of the numbe...
C
/********************************************** * Writen by: Nguyen Xuan Thanh - EEIU09053 * * school of Electrical Engineering * * ------- * * Project: Colour Sensor TCS3200 * * * *********************************************** HARDWARE -------- MCU = ATmega32 Running at 8M...
C
#include <stdio.h> #include <errno.h> #include <sys/types.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> void creerProc(int nb, int num); int main() { int nbProcess; // nombre de processus dans la file do { printf("Combien de processus à c...
C
// utils.c // // contains a bunch of stuff I need. // // Written in C but compiled with gcc, so I can use // comments. #include <string.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <netdb.h> #include <netinet/in.h> #include "utils.h" #include <sys/socket.h> #include <netinet/in.h> #incl...
C
#include "example.h" //the function you created int my_function() { int i,j,k; i = 1; j = 2; k = 3; return i+j+k; }
C
#include <stdio.h> #define MAX_SIZE 500 char content[MAX_SIZE]; char input[MAX_SIZE]; int cursor = 0; int main() { fgets(input, MAX_SIZE, stdin); for (int i=0; i<strlen(input); i++){ //printf("input[i]: %c\n", input[i]); char temp[MAX_SIZE] = {'\0'}; if (input[i] == ...
C
/* Dillon Stock stockdil@basset 2017-01-29 untitled.cpp Your Comments */ #include <iostream> #include <fstream> #include <stdio.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <cstring> #include <string> using std::cout; using std::endl; using std:...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct __STUDENT { char name[20]; int score; struct __STUDENT* next; } Student; Student* insert(Student* root, Student value) { Student* head = malloc(sizeof(Student)); head->next = root; Student* cursor = head; while (cur...
C
#include <stdio.h> #include <stdlib.h> int sum(int m, int n); int main(int argc, char **argv) { int m = 10; int n = 5; printf("%d\n", sum(m, n)); return 0; } int sum(int m, int n){ int result; result = m + n; return result; }
C
#pragma once #include <stdint.h> //so we can use uint8_t etc. typedef struct vector2 { float x; float y; }; struct transform_t { vector2 position; vector2 rotation; vector2 scale; }; struct rigidbody_t { vector2 velocity; vector2 acceleration; }; struct sprite_t { uint32_t id; vector2 size; };
C
#include "emetteur.h" /* Demande un nombre d'utilisateurs qui est soit 1 soit 2 ou un multiple de 4 * @param : void */ int choixNbUtilisateurs( void ){ int nb = 1; do{ if( nb == 0 || (nb != 2 && nb != 1 && nb%4 != 0 ) ) printf("\nErreur: nombre d'utilisateurs incorrect."); printf("\nNombre d'uti...
C
#include <stdio.h> #include <getopt.h> #include "calc.h" #include "mylib.h" #include "stack.h" /* DO NOT CHANGE: This file is used in evaluation */ int main(int argc, char * const * argv) { Stack * main_stack; /* to store the postfix expression */ int option; /* each command line option */ /* initialize debug s...
C
#include <stdio.h> int main() { int i,a,b,s=0; scanf("%d %d", &a, &b); if (a > b){ a = a + b; b = a - b; a = a - b; } if (a%2==0)a--; a = a + 2; for (i = a;i < b;i=i+2){ s = s + i; } printf("%d\n",s); return 0; }
C
#include <stdio.h> #include <stdlib.h> #include "gd.h" #include "gdtest.h" int main() { gdImagePtr im, exp; char *path, filename[2048]; const char *file_im = "gdimagerotate/remirh128.png"; FILE *fp; int color; int error = 0; int angle; fp = gdTestFileOpen(file_im); im = gdImageCreateFromPng(fp); fclose(fp)...
C
#include <stdio.h> typedef struct test_a TEST_A; struct test_b { int x; int y; }; int main() { struct test_b b; b.x = 0; b.y = 1; TEST_A a; printf(" %d, %d\n", b.x, b.y); return 0; }
C
#include "testlib.h" #include <stdlib.h> #include <stdarg.h> static int failed = 0; static int count = 0; local void testFail(String testname, String fmt, ...); extern int fluidLevel; void showTest(char *name, void (*fn)(void)) { int localFluidLevel = fluidLevel; printf("(Starting test %s\n", name); fn(); test...
C
#include<stdio.h> int main() { int a[4]={2,3,5,7}; int b[5]={11,13,17,19,23}; int b2[5],a2[9],i; FILE *fp1,*fp2; fp1=fopen("75_1.dat","wb"); fp2=fopen("75_2.dat","wb"); fwrite(a,16,1,fp1); fwrite(b,20,1,fp2); fclose(fp1); // fp1 is deactivated fclose(fp2); // to append data of file 75_2.dat in f...
C
#include <unistd.h> #include <fcntl.h> #include <errno.h> #include <string.h> #include <stdlib.h> #include <stdio.h> int main(int argc,char **argv) { if(argc < 2){ fprintf(stderr,"usage:%s\n",argv[0]); exit(1); } int fd; if((fd = open(argv[1],O_RDWR)) < 0){ perror("open...
C
/* Test for the MPI_Gather method Must run with 3 ranks Defaults to 10000 iterations Intended to be run with mana_test.py */ #include <assert.h> #include <mpi.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { // Parse runtime argument int max_iterations = 10000; // default if ...
C
/* Author: Brandon Tran * Partner(s) Name: * Lab Section: 22 * Assignment: Lab #6 Exercise #3 * Exercise Description: (Challenge) (from an earlier lab) Buttons are connected to PA0 and PA1. * Output for PORTB is initially 7. Pressing PA0 increments PORTB once (stopping at 9). Pressing * PA1 decrements PORTB on...
C
#include <stdio.h> #include <stdlib.h> #include "des.h" #include "helper_descrack.h" #include "input_descrack.h" int main(int argc, char **argv) { /* * Algoritmo: * * Calcola tutte le potenze da 0 a 8 (compreso) della dimensione dell'alfabeto * Per ogni valore della lunghezza della chiave e ...
C
/** * @file * Bitstream lib header */ #ifndef BITSTREAM_H #define BITSTREAM_H #include <stdint.h> #include <stdio.h> enum bs_type { BS_READ, BS_WRITE }; struct bitstream { uint8_t buf; ///< buffer int bufoffset; ///< offset (used bits in buffer) FILE *fp; ///< file point...
C
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include "sort.h" #define min(a, b) (((a) < (b)) ? (a) : (b)) void bubble_sort(int *nums, int numsSize) { if (numsSize < 2) return; for (int i = 0; i < numsSize; i++) { bool flag = false; for (int j = 0; j < numsSize - i - ...
C
/* * Author: Kentaro Wada * Mail: www.kentaro.wada@gmail.com * URL: http://wkentaro.com * Created: 2014-06-29 * Filename: camera_capture.c */ #include <cv.h> #include <ctype.h> #include <highgui.h> void camera_capture(int cam_id) { int c=0; // キーボード入力用 CvCapture *capture=0; // カメラキャプチャ用...
C
#include <string.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> #define tam 20 long double contador(long double n); int main(int argc,char * argv[]){ clock_t t_inicial,t_final; t_inicial=clock(); int i,j; long double num; long double matriz[tam][tam]; long double matrizResultant...
C
#include <stdio.h> #include <string.h> #define INDICE_NO_ENCONTRADO -1 int main(){ int fuente[] = { 1,2,3,4,5,6,7,8 }; int numero_elementos = sizeof(fuente)/sizeof(int); int numero_a_buscar = 4; printf("indice = %d",indice_donde_se_encuentra_numero(fuente, numero_a_buscar, numero_elementos)); } int indice_dond...
C
/* ** EPITECH PROJECT, 2019 ** ms ** File description: ** game */ #include <stdlib.h> #include <time.h> #include "my.h" #include "matchstick.h" int is_num(char const *s) { for (int i = 0; s[i] && s[i] != '\n'; i++) if (s[i] <= '0' || s[i] >= '9') return 0; return 1; } void print_win(int w...
C
#include <stdio.h> #define INT_INFINITE 1073741823 int capacity,nstation,goal,npath,nodeBikes[10000],rent = 0,bring = 0,top=-1; int bring_out = INT_INFINITE,bring_back = INT_INFINITE,min_length = INT_INFINITE; void best_path(int vertex,int mark[],int path[][nstation],int visited[],int stack[],int *ANS) { int i; ...
C
/* * Problem 3 - Discontinuities * TCSS 422 A Spring 2016 * Bun Kak, Chris Ottersen, Mark Peters, Paul Zander */ #include "OS.h" #define WRITE_TO_FILE false //static const word int REGNUM = sizeof(struct regfile)/sizeof(word); /*global declarations for system stack*/ static word SysStack[SYSSIZE]; static int Sy...
C
#include <stdio.h> #include <stdlib.h> struct el {int val; struct el *next;}; struct el *LIS1, *LIS2; int TRASP(struct el *l1,struct el **l2){ if(*l2 != NULL) { printf("La lista 2 deve essere vuota"); return 0; } if(l1 == NULL || l1->next == NULL){ printf("La lista 1 non è suffici...
C
/* Author :Joey Pinto Date :20 March 2014 Description:A program to sort the lsit of integer elements using a selection sort Algorithm Assumptions:The data inserted has to be an integer value Array size is initialized dynamically */ #include<stdio.h> //program to sort a list of elements using Sele...
C
#include <stdio.h> #include <stdlib.h> /** * 递归法求n! * */ int step(int n); int main() { int n; printf("Please enter the order:\n"); scanf("%d",&n); printf("The result is %d\n",step(n)); system("pause"); return 0; } /** * 阶乘函数递归实现 * */ int step(int n) { if(n == 1 || n == 0) //回溯...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_printl.c :+: :+: :+: ...
C
# include <stdlib.h> # include <stdio.h> # include <math.h> # include <time.h> # include "asa066.h" int main ( void ); void test01 ( void ); void test02 ( void ); void test03 ( void ); /******************************************************************************/ int main ( void ) /******************************...
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
/* * All necessary functions used for the 4 bit calculator * * functions.c * * Created on: 3.06.2017 ã. * Author: justbobi */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include "../headers/functions.h" /* * Checks if the input value is a whole number * and is it between 0 and 15. */ v...
C
#ifndef _PSEUDOASM_INC_MEMORY_H_ #define _PSEUDOASM_INC_MEMORY_H_ #include "hardware.h" #include "errors.h" #include "numberlist.h" typedef struct Memory { unsigned int address; MemCell cell; struct Memory *next; } Memory; /* Read data from an address */ MemCell readMemCell(Memory ** l, unsigned int address); /*...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* prompt.c :+: :+: :+: ...
C
/** * SD, 2021 * * Lab #9, BST & Heap * * Task #1 - Binary Search Tree implementation */ #include "bst.h" #include "utils.h" /** * Helper function to create a node * @data: the data to be added in the node * @data_size: data's size */ static bst_node_t *__bst_node_create(void *data, size_t data_size) { b...
C
#include<stdio.h> int main() { enum Demo{A = 10/3,B = 4*3,C,D = 7-2,E,F = A}; printf("%d\n",A); // 3 printf("%d\n",B); // 12 printf("%d\n",C); // 13 printf("%d\n",D); // 5 printf("%d\n",E); // 6 printf("%d\n",F); // 2 r...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <net/if.h> #include <sys/ioctl.h> #include <netinet/in.h> void die(const char *msg) { perror(msg); exit(EXIT_FAILURE); } int main() { char buf[1024]; struct ifreq ifr; struct ifconf ifc; struct ifreq *it; const struct ifreq...
C
#include <stdio.h> #define DIM 3 void popola(int *, int); void rimuovi_dupl(int *, int *); void stampaArray(int arr[], int dim); void intersezione(int arr1[], int arr2[], int *arr3, int dim1, int dim2, int *dim3); int isContained(int[], int, int); void popola(int *arr, int dim){ int i; for(i=0; i<dim; i++) ...
C
/* ============================================================================ Name : QuickSort.c Author : Nikhil Jagdale Version : Copyright : Your copyright notice Description : Hello World in C, Ansi-style ============================================================================ */ #in...
C
#ifndef TEST_CLIENT_REQUESTS_IMPORT #define TEST_CLIENT_REQUESTS_IMPORT #include "internal_request.h" /** * @brief A config file containing a list of all files with textually * serialized requests. */ #define FILES_LIST "../config/files_list" /** * @brief Provides a dynamically allocated buffer with a copy of *...
C
/****************************************Preliminary Prototype of Scan Schedular*******************************************/ /******************(c)Suhas Aggarwal(suhas@iitg.ernet.in)*****************/ #include<stdio.h> #include<stdlib.h> #include<errno.h> #include<sys/ioctl.h> #include<sys/types...
C
#include <stdio.h> #include <stdlib.h> int main() { int valor; printf("Digite um numero: "); scanf("%d", &valor); printf("O sucessor de %d %d \n", valor, valor+1); printf("O antecessor de %d %d", valor, valor-1); return 0; }
C
// here we use Naive Approach // time Complexity : O(n^3) #include<stdio.h> int main() { int arr[]={1,5,3,2}; int n=sizeof(arr) / sizeof(arr[0]); int count=0; for(int i=0;i<n-2;i++) { for(int j=i+1;j<n-1;j++) { for(int k=j+1;k<n;k++) { ...
C
//此头文件存放一些结构体 #ifndef HEADER_Model #define HEADER_Model #define String char* /** * 失物的实体类 * Cerbur */ typedef struct LostProperty { int lid; //主键唯一标识符 String name; //失物的名称 如果是校园卡/一卡通输入1 不是校园卡输入名称 String description; //失物的描述 String contact_details; //联系方式 String submit_user_schoolId; //提交者的scho...
C
#include <stdio.h> #include <stdlib.h> //Autor: Szymon Kącki //Data: 2017.11.06 int main() { int i; int tab[6]; for (i=0; i<6; i++){ printf("Podaj %d liczbe: ", i+1); scanf("%d", &tab[i]);} printf("\nliczby w tablicy: "); for (i=0; i<6; i++){ printf("%d ", tab[i])...
C
#include <stdio.h> int x; int y; int old_x; int counter; void main() { x = 0; y = 1; counter = 1; do { printf("fib(%d) = %d", counter++, x); sync; old_x = x; x = y; y += old_x; } while(x >= 0); }
C
#include <stdio.h> void my_memcpy(const void* src, void* dest, int size) { int i; const char* src_ptr = (const char*) src; char* dest_ptr = (char*) dest; for(i=0; i<size; i++) { dest_ptr[i] = src_ptr[i]; } } int main() { int arr1[100], arr2[100], n, i; printf("Enter the number...
C
#include <stdio.h> int main(void) { float age_year, age_second; printf("Enter your age in years: "); scanf("%f", &age_year); printf("Your age in seconds is %e.\n", age_year * 3.156E7); return 0; }
C
/** * A most basic test for fontconfig support. * * Without actually using fontconfig, passing an empty fontlist to * gdImageStringFT() would return an error ("Could not find/open font"). * We're checking that it returns NULL. */ #include "gd.h" #include "gdtest.h" int main() { gdImagePtr im; int blac...
C
/****************************************************************************** Determinant of a Matrix - Algorithm 6.0C ******************************************************************************* Computes the determinant of matrix A: INPUT matrix dimension n; the entries a(i)(j), 1 i,j n of the matrix ...
C
#ifndef HEAPLIST_H #define HEAPLIST_H typedef struct HeapBlock { size_t size; int mark; void* heapPtr; struct HeapBlock* next; struct HeapBlock* prev; } HeapBlock; typedef struct HeapBlockList { int listSize; HeapBlock* first; HeapBlock* last; } HeapBlockList; HeapBlockList* initHeapList(void); void ...
C
#include<stdio.h> int main(){ int sum,i,j; scanf("%d",&sum); for(i = 1; i <= 6; i++){ for(j = i; j <= 6; j++){ if(i+j==sum){ printf("%d %d\n",i,j); } } } }
C
#include <stdio.h> #include <stdlib.h> typedef struct _Node { struct _Node *left; int data; struct _Node *right; }Node; Node* insert(Node* ptr, int data) { if(ptr == NULL){ Node * tmp = (Node*) malloc(sizeof(Node)); tmp->data = data; tmp->left=NULL; tmp->right=NULL; return tmp; } else{ if(data <...
C
/* File: utility.h * --------------- * This file just includes a few support functions you might find * helpful in writing the projects (error handling, debug printing) */ #ifndef _H_utility #define _H_utility #include <stdlib.h> #include <stdio.h> /** * Function: Failure() * Usage: Failure("Out ...
C
#include <stdio.h> int busca_sequencial_recursiva(int vet[], int key, int size, int i){ if(i>=size){ return -1; } else if(vet[i] == key){ return i+1; } else{ return busca_sequencial_recursiva(vet, key, size, i+1); } } int main(){ int vetor[10] = {1,2 ,3 , 4, 5, 6, 7, 8, 9, 10}; int complexidade = bus...
C
// 단어의 개수 구하기 #include <stdio.h> #include <ctype.h> int main(void) { char arr[1000000]; int count = 0; int word = 1; scanf("%[^\n]s", arr); for(int i = 0; arr[i] != NULL; ++i) { if(isalpha(arr[i])) { if(word) { count++; wo...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> #define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};} //pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) typedef char* String; ...
C
#include <stdio.h> void main(){ int arr1[5]={1,2,3,4,5}; int arr2[]={1,2,3,4,5,6,7}; int arr3[7]={1,2,3,4,5,6,7}; int arr4[5]={1,2}; // 迭 Ϻΰ ʱȭ ϴ տ ӵǾ ʱȭ // 쿡 ϴ. // int arr4[5]={1,,3,,5}; // Ѳ 迭 ʱȭ ϴ 迭 // ȿ ̴. // arr1={6,7,8,9,10} // 迭 Ŀ 迭 ȸ // index ؼ ϴ. arr1[0]={6}; arr1[1]={7}; arr...
C
// // Final Programme.c // Learning C // // Created by Adam Campbell on 15/04/2012. // Copyright (c) 2012 __MyCompanyName__. All rights reserved. // #include <stdio.h> #include <stdlib.h> #include "math_functions.h" #include "song.h" #include "Final Programme.h" // global variables int yearCount = 12; int* allYea...
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 "holberton.h" #include <stdio.h> #include <stdlib.h> /** * *string_nconcat - function concatenates two strings. * @s1: pointer contains a string we are concatenating * @s2: pointer contains a string we are concatenating * @n: number of bytes from s2 we are concatenating * * Return: Always 0. */ char *s...
C
#include<stdio.h> typedef struct{ int i; }test; int main(){ char value[10]; char *p; int i,j; i = 11; memset(value, 0, 10); p = value; test my_test; my_test.i = 10; memcpy(p, &i, sizeof(int)); j = (int)(*p); printf("%s\n", value); printf("%d\n", j); return 0; }
C
#include <stdio.h> int main() { int array[11] = {2,3,4,5,6,7,8,9,22,33,45}; int low = 0; int high = 10; int flag = 0; int s = 4; while(low <= high){ int index = low+(high-low)/2; if(array[index] == s){ flag = 1; printf("Founded: %d...
C
#include "myLib.h" unsigned short *videoBuffer = (unsigned short *)0x6000000; // This sets a pixel to some color. void setPixel(int row, int col, unsigned short color) { videoBuffer[OFFSET(row, col, SCREENWIDTH)] = color; } // This draws a rectangle. void drawRect(int row, int col, int height, int width...
C
//stampa a console la media dei valori di un array #include <stdio.h> void esercizio_04() { int myarray[] = {2,4,6,-2,1}; int myarraylength = sizeof(myarray) / sizeof(int); int somma = 0; for(int i = 0; i < myarraylength; i++){ somma += myarray[i]; } float media = somma / myarraylength; printf("Med...