language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> #include <math.h> /* Function to sort an array using insertion sort*/ void InsertionSort (int arr[], int size) { int i, key, j; for (i = 1; i < size; i++) { key = arr[i]; j = i - 1; /* Move elements of arr[0..i-1], that are greater than key, to one position ahead...
C
#include <stdio.h> #include <stdlib.h> #define MAX 3 void main(void) { int *p2; int i, n=5; p2 = (int*) malloc(n * sizeof(int)); for (i = 0; i < n; i++) { *(p2+i) = i; } for(i=n-1; i>=0; i--) { printf("%d ",p2[i]); } int *v, n; printf("\nTamanho...
C
#include <ctype.h> #include <limits.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <signal.h> #include <sys/time.h> #include <sys/types.h> #include <sys/wait.h> #include <getopt.h> #include "find_min_max.h" #include "utils.h" char* itoa(int val, int b...
C
#include <stdio.h> //이진탐색 재귀함수로 구현 int binarySearch(int arr[], int start, int end, int value){ //arr의 start부터 end까지의 값들 중 value가 존재한다면 그 위치를 반환하고, //없다면 -1을 반환하는 함수 //기저조건: 숫자가 아예 없는 경우, 숫자가 1개 있는 경우 if(start>end){ return -1; }else if(start == end){ if(arr[start] == value) return sta...
C
#include <stdio.h> #include <stdbool.h> bool ehPerfeito(int x); int main(void) { int i,n,num; scanf("%d", &n); for(i=0; i<n; i++) { scanf("%d",&num); if (ehPerfeito(num)) printf("%d eh perfeito\n",num); else printf("%d nao eh perfeito\n",num); ...
C
/* ** client.c for MySlack in /home/nomad/mySlack/server ** ** Made by BARREAU Martin ** Login <barrea_m@etna-alternance.net> ** ** Started on Sun Feb 18 22:17:49 2018 BARREAU Martin ** Last update Fri Feb 23 09:33:53 2018 BRIAND Corentin */ #include <client.h> #include <srv.h> #include <libmy.h> #include <stdlib.h...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #define MEM 256 // 入力用関数 char* input(char* str, char* desc) { // char str[MEM]; printf(desc); fgets(str, MEM, stdin); return str; } int read_int_array_zero2(int lim, int *a, int endval) { char str[MEM], frmt[MEM]; // format ...
C
#include <stdlib.h> int ft_strlen(char *str) { int i; i = 0; while (str[i] != 0) { i += 1; } return (i); } char *ft_strdup(char *src) { int i; int len; char *buffer; len = ft_strlen(src); buffer = (char *) malloc(len + 1); if (buffer != 0) { i = 0; while (i < len) { buffer[i] = src[i]; ...
C
/* switch case with a while loop */ #include <stdio.h> void main() { char c; int done; float total=0; puts("please make a selection\n"); printf("1 - Cotton Candy\n"); printf("2 - Chocolate Bar\n"); printf("3 - Popcorn\n"); printf("4 - Jolly Ranchers\n"); printf("5 - Butterfinger\n"); done=0; while (!...
C
/* ** get_next_line.c for get_next_line in /home/sacha.riperto/B-CPE/CPE_2016_getnextline1 ** ** Made by Sacha Riperto ** Login <sacha.riperto@epitech.net> ** ** Started on Wed Feb 22 09:29:18 2017 Sacha Riperto ** Last update Sun Jun 18 17:06:37 2017 Jules Spender */ #include "my_h.h" char *reayoloc(char *buffe...
C
#include "teste.h" #include <stdio.h> #include <stdlib.h> // Exercício 1 int take (int n, LInt *l) { int r = 0; if (n == 0) free (*l); while (*l != NULL && n != 1) { l = &((*l)->prox); --n; ++r; } return r; } // Exercício 2 int maiores (ABin a, int x) { int r; if (a == NULL) r = 0; else if...
C
#include "isValidStructure.h" #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "../../stack/stack.h" #include "../../utils.h" char getOpenerFor(char closer) { switch (closer) { case '}': return '{'; case ']': return '['; case ')': return '('; } ...
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> #include <string.h> #include <stdlib.h> #include <windows.h> #include <ctype.h> #include <conio.h> #define MD_1 "e:\\1\\mingdan.txt" //ֶ¼Ϣʱ浽˴ #define M_S "e:\\1\\xuesheng.txt"//洢ѧļ #define M_T "e:\\1\\jiaoshi.txt"//洢ʦ˺ļ //temp ֻǸ void Show1(); struct student *Input(); void Tofile(st...
C
/* ============================================================================ Name : krishnamurthi_num.c Author : shiv Version : Copyright : Your copyright notice Description : Hello World in C, Ansi-style ============================================================================ */ #incl...
C
#include "pipe_networking.h" /*========================= server_handshake args: int * to_client Performs the client side pipe 3 way handshake. Sets *to_client to the file descriptor to the downstream pipe. returns the file descriptor for the upstream pipe. =========================*/ int server_handshak...
C
// interface to the OS Random Number Generator // the getrandom() detection code has been provided by Daurnimator // (https://github.com/daurnimator) #ifdef _WIN32 // --------------------------------------------------------------------- // randombytes() for windows - Use the Windows RNG (CryptGenRandom) // tes...
C
/* * my_strncpy.c * Takes in two strings and an integer n, copies the first n characters from the src * string into the dst string and returns the dst string * * * Created on: Feb 28, 2017 * Author: jcafiero * Pledge: I pledge my honor that I have abided by the Stevens Honor System */ #include "...
C
/* * Copyright (c) 2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * */ #ifndef FBI_...
C
// решение уравнения методом деления отрезка пополам #include <stdio.h> #include <stdlib.h> #include <assert.h> double dichotomia(double a, double b, double(*f)(double)) { assert(b>a); assert(f(b)*f(a)<0); double eps=0.00001; while (b-a>eps) { double m=(a+b)/2.0; if(f(m)==0.0) ...
C
#include <stdio.h> #include <mpi.h> int main(int argc, char *argv[]){ int rank, size; int i, n; int arr[4], arr2[4]; int recv; int sum=0; double t1, t2; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); if(rank==0){ scanf("%d",&n); for(i=0; i<n; i++)...
C
#include<stdio.h> #include<stdlib.h> #define MOD 998244353L typedef long long ll; int abs(int x) { return x<0?-x:x; } ll fact(ll n) { ll ans = 1; for(int i=1;i<=n;i++) { ans = (ans*i)%MOD; } return ans; } // Explanation // extended euclide's algorithm finds numbers such that /...
C
#pragma once #include "direction.h" enum Food { SMALL = 1, ENERGIZER = 2, FRUIT = 3, EXTRALIVE = 4 }; struct cell // = Nothing | Wall | Food(Type) | Pacman | Ghost(Id int) | // Eaten_Food(type) { enum { Nothing = 0, Wall = 1, Food = 2, Pacman = 3, Ghost = 4, ...
C
#include <stdio.h> #include <unistd.h> #include <pthread.h> #include <stdlib.h> #define CONSUMERS_COUNT 2 #define PRODUCERS_COUNT 2 struct msg{ struct msg *next; int num; }; struct msg *head = NULL; pthread_cond_t cond; pthread_mutex_t mutex; pthread_t threads[CONSUMERS_COUNT + PRODUCERS_COUNT]; void *cons...
C
#include<stdio.h> int main() { int age; printf("Enter your age:"); scanf("%d",&age); printf("Your age is %d years old\n",age); return 0; }
C
#include<stdio.h> int factorial(int n) { { return (n * factorial(n-1)); } } int main() { int n=0; return 0; }
C
/*-============================================================================/ Jeremy Audet, for micro, taught by Matt Gallagher. Homework assignment 10. Objective: create a sine wave using the PWM register. This will need to be done twice; once with C, and a second time using assembly. This file is the c impleme...
C
#include <stdio.h>/**< Data types */ #include <stdlib.h> int main() { int age = 40; /**< No quotation if using number. Integer is whole number. */ double gpa = 3.7; /**< Use to represent decimal number. For beginners. */ char grade = 'A'; /**< For only one letter */ char phrase[] = "Giraffe Academy"; /**< ...
C
#include <stdio.h> #include <sys/types.h> #include <unistd.h> #include <sys/wait.h> #include <stdlib.h> int main(int argc, char *argv[]) { int forkID = fork(); char *args1[] = {argv[1],NULL}; char *args2[] = {argv[2],NULL}; if(forkID == 0) { execvp(args1[0],args1); perror("Command 1 not ...
C
#ifndef _COMMON_H_ #define _COMMON_H_ #include "Type.h" #include "struct.h" #include <stdio.h> #define MAX_(bit1, bit2) ((bit1) >= (bit2) ? (bit1) : (bit2))// ֵ #define MIN_(bit1, bit2) ((bit1) <= (bit2) ? (bit1) : (bit2))// Сֵ #define TYPE_S8(data) (data) > 127 ? 127 : ((data) < -127 ? -127 : (data));//data>127ʱda...
C
#include "mex.h" // Matlab mex header file // C function multiply arrays x and y (of size) to give z void xtimesy(int size, double x[],double y[], double z[]) { int i; for(i=0; i<size; i++) z[i] = x[i]*y[i]; } // MEX interface function void mexFunction( int nlhs, mxArray *plhs[], ...
C
/*This is a header file of memoryWord.c * Contains memoryWord data structures and prototypes * *Writen by: *Tom Cherchy 302649397 *Avraham Yarblum 305567083 * */ #ifndef MAMAN14_MEMORYWORD_H #define MAMAN14_MEMORYWORD_H #include <stdlib.h> #include "assembler.h" #include "utils.h" /*=========data structures...
C
#ifndef FUNS_H #define FUNS_H #include "definitions.h" // *** Funkcje wartosci losowych *********************************************** /** @return {min, ..., max}*/ int irand( int min, int max ); /** @return {0,1} */ int irand_uni(); /** @return {-1,0,1} */ int irand_bi(); /** * @brief Losowy float *...
C
/* ************************************************************************** */ /* LE - / */ /* / */ /* main.c .:: .:/ . .:: ...
C
/* * C Implementation: server * * Description: * * * Author: Tomas Pospisek <tpo_deb@sourcepole.ch>, (C) 2006 * * Copyright: See COPYING file that comes with this distribution * */ #include <stdlib.h> // exit #include <stdio.h> #include <string.h> // strlen #include <unistd.h> // getopt #include "conn_...
C
// screenshot to jpeg for linux #include <stdio.h> #include <sys/time.h> #include "shot2jpeg.h" #define IMG_AT(x, y, i) image->data[(((y_width) + (x)) << 2) + (i)] #define RGBA_AT(x, y, i) rgba[(((y_width) + (x)) << 2) + (i)] #define RGB_AT(x, y, i) rgb[((y_width) + (x)) * 3 + (i)] xcb_image_t *take_screenshot(xcb_c...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* check_copy.c :+: :+: :+: ...
C
/*! \brief Постановка задачи. \details Написать программу, которая считывает из текстового файла вещественные числа и записывает их в массив. Далее на основе этого массива формирует второй по принципу: в новый массив попадают числа больше их среднего арифметического. Новый массив записывается в новый файл. ...
C
/* * IFJ 2017 project * File string.h * Description Header file for strings * Author Michal Zilvar (xzilva02) */ #ifndef STRINGH #define STRINGH #define STR_LEN_INC 8 // Size of the first alloc & next reallocs of the string typedef struct { char* data; int size; int capacity; } String; int stringInit(...
C
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <string.h> #define N 20 int cmp(const void *s1,const void *s2) { const char *str1,*str2; str1 = s1; str2 = s2; return strcmp(str1,str2); } void max_int(const int a[],int size) { int i; char b[N][N]; assert...
C
/*============================================================================= * | Source code: forker.c * | Author: Anthony Perez * | Student ID: 5456512 * | Assignment: Program #6 Final Project * | * | Course: COP4338 - Programming III * | Section: ...
C
#ifndef STR_BUILDER_H #define STR_BUILDER_H #include <ctype.h> #include <stddef.h> typedef struct str_builder str_builder_t; str_builder_t *create_str_builder(void); void destroy_str_builder(str_builder_t *sb); void sb_strcat(str_builder_t *sb, const char *str); void sb_putchar(str_builder_t *sb, char c); void sb_c...
C
/****************************************************************************** Nombre del m�dulo: seleccion.c Descripci�n: Funciones para la seleccion de las correctas funciones de acciones, Autor: I�aki Cadalso Fecha: 14-03-2013 Modulos propios que necesita: - seleccion.h - acciones.h Modificaciones: [14-03-20...
C
// 후위표기식으로 변환 1 - 괄호 없는 경우 // 피연산자는 그대로 output에 넣는다. // 2 - 10 / 5 * 6 + 4의 경우 // 2는 (피연산자는) 그대로 output으로. // -는 바로 출력할 수 없으므로 stack에 보관 // 10은 출력 // /도, 나눗셈에 필요한 피연산자가 나오지 않았으므로 /를 push에 넣는다. // 다음 5는 출력 // 곱하기 연산자도 stack에 push되어야 한다. // but 그전에, 나누기와 곱하기는 동일한 우선순위를 갖고 나눗셈에 적용되는 피연산자가 전부 출력되어 있으믈 // 나누기는 pop으로 출력된다. ...
C
/* Given a 6X6 2D Array, arr: 1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 An hourglass in A is a subset of values with indices falling in this pattern in arry's graphical representation: a b c d e f g There are hourglasses in . An hourglass sum is the sum of an hourglass' values. Calcu...
C
/* * LE TAN PHUC * MSSV: 50902003 * MT09KTTN * * LAB 2 Parallel Programming witH MPI * PROBLEM 3.1 PING-PONG PROCESS */ #include <mpi.h> #include <stdio.h> #define T_COUNT 30 int main(int argc, char **argv){ int rank,size; int count = 0; MPI_Status status; MPI_Init(&argc,&argv); MPI_Comm_rank(MPI_COMM...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <omp.h> #include <time.h> #include <sys/time.h> #define BUF_SIZE 1024 void print_matrix(FILE* file, int *matrix, int m, int n); int main(int argc, char **argv) { int m, n; int end_number; int *matrix; char filename[BUF_SIZE] = {0, };...
C
/* * ===================================================================================== * * Filename: thread.h * * Description: * * Version: 1.0 * Created: 2014年08月25日 17时19分58秒 * Revision: none * Compiler: gcc * * Author: jianxi sun (jianxi), ycsunjane@...
C
/** * Module: md.c * Author: Derek Williams * Created: 01/30/04 * Purpose: 3-D hard spheres simulation of water molecules with periodic boundaries */ #include <stdio.h> #include <stdlib.h> #include <malloc.h> #include <math.h> #include <assert.h> #include <time.h> #include <GL/glut.h> #include "list.h" #include ...
C
/* Napisz funkcję length, która przyjmuje napis i zwraca jego długość, czyli liczbę znaków poprzedzają- cych bajt zerowy. Funkcja nie używa żadnych zmiennych całkowitych, a jedynie wskaźników. Funkcja nie korzysta z żadnych nagłówków. Używając tej funkcji napisz program length, który przyjmuje jako argument wywołan...
C
#include<stdio.h> void ele(int A[],int l,int h){ int i; int B[14]={}; for(i=0;i<10;i++) { B[A[i]]++; } for(i=l;i<h;i++) { if(B[i]==0) printf("%d\n", i); } } int main() { int A[10]={2,3,6,4,5,9,12,13,14}; ele(A,2,14); ...
C
#include <stdio.h> #include <stdlib.h> int main() { int num; FILE *fptr; // create a file pointer fptr = fopen("file1.txt", "w"); // gives the path of a file and mode if(fptr == NULL) { // if fptr is null close the program printf("Error!\n"); exit(1); // close the program } printf("Enter number: ...
C
#include <stdlib.h> #include <stdio.h> #include "util.h" #include <math.h> #include <limits.h> #include <time.h> bool seq_search( int* arr, int value, int size) { int i; for(i = 0; i < size; i++) if( arr[i] == value) return true; return false; } bool check_arr( int* arr, int value) { int i; for( i = 0; a...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* dir_split.c :+: :+: :+: ...
C
#ifndef STRINGFUNCTIONS_copystr #define STRINGFUNCTIONS_copysource mystr c_StringFunctions::copyStr(const mystr source,int *returnRefLen=NULL){ const int sourceLen=getStringLen(source); mystr returnRef=NULL; if(sourceLen>0){ returnRef=reallocStringMemory(returnRef,(int)(sourceLen+1)); if(returnRef==NULL)re...
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
/* Napisati program koji postavlja na k-to mestu jedinicu u celom broju x. Celi brojevi k (neoznacen ceo broj) i x se unose sa standarnog ulaza. Pozicija se broji od najmanje tezine ka najvecoj pocevsi od 0. */ #include <stdio.h> int postavi_1(int x, unsigned k){ unsigned maska = 1<<k; return maska | x; } int main...
C
#include <msp430.h> #include <stdint.h> #include <math.h> /** * main.c */ void Config_IO(); void ConfigClock(void); void ConfigUART(void); void Send_UART(uint8_t); void Send_UART_word(char*); void Send_UART_numb(float); void ftoa(float, char*,uint16_t); //int intToStr(uint16_t, char*, uint16_t); int ...
C
#include <stdio.h> int main () { int s; double a, r, g; printf("Enter basic salary:"); scanf("%d", &s); a = s * 0.4; r = s * 0.2; g = s + a + r; printf("Gross salary = %0.2lf", g); return 0; }
C
// 图的邻接矩阵存储和基本操作 int LocateVex(MGraph G, VertexType u) { // 若G中存在顶点u,则返回该顶点在图中位置;否则返回-1 int i; for(i=0; i<G.vexnum; i++) // strcmp函数用于比较两个字符串 if(strcmp(u.name, G.vexs[i].name) == 0) //顶点与给定的u的顶点名称相同 return i; //返回顶点序号 return -1; } void CreateDG(MGraph &G) { // 采用邻接矩阵表示法,构造有向图 int i, j, k...
C
#include <stdio.h> int main() {static int a[3][4] = {1,2,3,4,5,6,7,8,9,10,11,12}; int *p; for( p = a; p<= a +11; p++) printf("%3d,", *p); } 
C
#include <stdio.h> #include <locale.h> int main() { setlocale (LC_ALL, ""); setlocale (LC_CTYPE, "pt_BR.UTF-8"); float f,c; printf("Digite a temperatura em graus Fahrenheit: "); scanf("%f", &f); c = (5*(f-32)/9); printf("A temperatura em graus Celsius %f",c); }
C
//// //// Map.h //// CS32Homework4 //// //// Created by Monil Patel on 3/1/16. //// Copyright © 2016 Monil Patel. All rights reserved. //// // //// Map.h // //#ifndef MAP_INCLUDED //#define MAP_INCLUDED // //template <typename KeyType,typename ValueType> //class Map //{ //public: // Map<KeyType,ValueType>(); ...
C
#include <stdio.h> int main(void) { char ch_a, ch_b, ch_c, temp; while(scanf("%c %c %c", &ch_a, &ch_b, &ch_c) != EOF) { if (ch_a > ch_b) { temp = ch_b; ch_b = ch_a; ch_a = temp; } if (ch_b > ch_c) { temp = ch_c; ch_c = ch_b; ch_b = temp; } if (ch_a > ch_b) { temp = ch_b; ...
C
// Function to get ctr_hi and ctr_low per frame void ctr(int X, int MAX, int ctr_hi, int ctr_low){ int vmax, vmin; for(col=0; col<col_max; col++){ for(row=0; row<row_max; row++){ // Change pixel ttn_rowcol(row, col); // Obtain V_min and V_max ttn_pxvo(0); vmin = read; ttn_pxvo...
C
#include "ft_printf.h" #include "ft_supportive.h" static int ft_numlen(long long in) { int cnt; if (in == 0) return (1); cnt = 0; while (in != 0) { in /= 10; cnt++; } return (cnt); } static void ft_printsign_fd(t_mask *mask, int var, int fd) { if (var >= 0) { if (mask->print_sign) { write(fd, ...
C
//jcmg@usal.es #include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> int main (void){ int num, ramd, x, temp, i=0; srand(time(NULL)); ramd=rand()%1001; puts("Introduce un numero"); do{ printf("%d intento:\n",++i); scanf("%d",&num); system("cls"); if(num<0)break; x=abs(num-ramd); if(x...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #define Max 124750 #define INFINITY 0x7fffffff typedef struct edge{ int city1; int city2; int cost; int status; }Way; Way path[Max]; int Root[Max]; int cost[Max]; int FindRoot(int x); void MergeSort(Way path[],int M); void MSort(Way A[],Way tmp[],int le...
C
#include "../structures/individu.h" #include "longueur_indiv.h" #include "../fonctions_math/puissance.h" unsigned long long decoder_indiv(individu personne) { unsigned long long somme = 0; for (int i = longueur_indiv(personne) - 1; i >= 0; i--) { somme += (personne->valeur - '0')*puissance(2, i); ...
C
/* * conv.c * * Created on: Sep 1, 2011 * Author: staffan */ #include <stdio.h> #include "conv_old.h" #include <stdlib.h> #include <stdint.h> #include <string.h> unsigned char* convimg( unsigned char* image_ptr, unsigned char* kernel_ptr) { uint16 col, row, conv_row, conv_col; int16 x, y; uint8 Y=55; ...
C
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include "c-client.h" #include "main.h" char _prog[] = "arfparse"; void usage() { fprintf(stderr, "usage: %s [options]\n", _prog); fprintf(stderr, "\t-m mailbox\n"); } int main(int argc, char **argv) { int ch; int m_...
C
//9_macro.c //Macros for bit operations #include<stdio.h> extern int showbit(int ); #define max(num1, num2) \ for(i=31; (i>=0) && ((num1 >> i ) ^ (num2 >> i));i--){ \ printf("%d\n",((num1 >> i)&1) ? num1 : num2); \ } #define min(num1, num2) \ for(i=31; (i>=0) && ((num1 >> i ) ^ (num2 >> i));i--)...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #include "mpi.h" #define MAX_VAL (1 << 10) int main(int argc, char **argv) { int rank, size, data, prev_result, result; double start, end; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); ...
C
#include "malloc.h" #include <stddef.h> // for NULL extern int __bss_end__; // Simple function to round up x to multiple of n. #define roundup(x,n) (((x)+((n)-1))&(~((n)-1))) static void *heap, *heap_max; struct header { size_t payload_size; int status; // 0 if free, 1 if in use }; struct header *rove...
C
#include "entity.h" int down=0,up=0; void init_tab_anim_entity(SDL_Rect *clip) { // dir vers droite clip[0].x = 0; clip[0].y = 0; clip[0].w = 100; clip[0].h = 100; int i = 1; for (i = 1; i < 15; i++) { clip[i].w = 100; clip[i].h = 100; clip[i].x = clip[i]...
C
/*-------------------------------------------------------------------------* * $Workfile : timer.c $ * Part of : ETL600 / O4CV * Language : C * Created by : Allen Notter (AN) * Remarks : * Purpose : Time delays and periodic interrupts * Copyright : ABB Switzerland Ltd., 2007 *--------...
C
//Escriba un programa que halle el menor de dos números pedidos al usuario. //Utilice una macro para resolver el mínimo. #include <stdio.h> #include <stdlib.h> #define MENOR(n1,n2) ((n1)<(n2)?(n1):(n2)) int main () { int n1; int n2; printf ("Ingresar número 1: \n"); scanf ("%d", &n1); prin...
C
/* * Check if initialzers are well done, where * initializer is constructed from various expression. */ #include <stdio.h> extern double func(void); extern void rel(int, int); extern void logic(int, int); int main(void) { int a = 1; printf("a = %d\n", a); int b = a; printf("b = %d\n", b); ...
C
#include<sys/types.h> #include<sys/socket.h> #include<netinet/in.h> #include<stdio.h> #include<netdb.h> #include<string.h> #include<stdlib.h> #include <arpa/inet.h> #include <sys/time.h> #include <netinet/in.h> #define PORT_NO 2018 #define BUFSIZE 1024+1 #define MAX_LINE_LEN 1024 /*1行に読み込める最大文字数*/ int cmd_read(char *...
C
// A street in Footown. // Mobydick@TMI-2, 9-3-92 #include <mudlib.h> inherit ROOM ; void create () { ::create(); set_outside("Fooland") ; set ("short", "North Main Street, Footown") ; set ("long", "You are walking along North Main Street. The town square is to\n"+ "the south and the town gates are to the nort...
C
#include <stdio.h> #include <stdlib.h> #include <float.h> #include <math.h> #include <pthread.h> // Type for points typedef struct{ double x; // x coordinate double y; // y coordinate int cluster; // cluster this point belongs to } Point; // Type for centroids typedef struct{ double x; // x c...
C
/* * BucketWater * des: Bucket and water question * day: 2016-08-23 */ #include "stdint.h" #include "daycode.h" #define BUCKET_COUNTS 3 uint32_t buckets[BUCKET_COUNTS] = {8, 5, 3}; int find = 0; typedef uint32_t bkt_stat[BUCKET_COUNTS]; typedef struct state { bkt_stat start; bkt_stat end; bkt_stat cur; stru...
C
#include <linux/init.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/cdev.h> #include <linux/device.h> #include <linux/uaccess.h> #include <linux/fs.h> static unsigned devnum; static struct cdev *atomiccdev=NULL; static struct device *dev=NULL; static struct class *atomicclass=NULL; /*****dec...
C
#include <stdio.h> #include <unistd.h> int main(){ int a = 5; int pid = fork();//a partir de aqui se crea el hijo if (pid == 0){ printf("Soy el proceso hijo; pid = %d\n",pid);//el porcentaje d es remplazado por el primer entero (en este caso pid) }//si se pone %f espera un flotante else{ ...
C
#include <stdio.h> #include "tree_list.h" int main() { Tree tree,tree1; tree_init(&tree); tree_init(&tree1); for(int i=0; i<6; i++) { tree_insert(&tree1,i); } tree_insert(&tree,4); tree_insert(&tree,7); tree_insert(&tree,2); tree_insert(&tree,1); tree_insert(&tree,5); tree_insert(&tree,3); tree_insert(&...
C
/****************************************************/ /* File: symtab.c */ /* Symbol table implementation for the TINY compiler*/ /* (allows only one symbol table) */ /* Symbol table is implemented as a chained */ /* hash table ...
C
#include "../net.h" char response[] = "HTTP/1.1 200 OK\r\n" "Content-Type: text/plain; charset=UTF-8\r\n" "Content-Length: 14\r\n\r\n" "Hello World!\r\n"; int main(int argc, char *argv[]) { int port = (argc >= 2) ? atoi(argv[1]) : PORT; net_t net; net_init(&net, TCP, SERVER, port, NULL); net_bind(&net); net_li...
C
#include<stdio.h> #include<math.h> #include<stdlib.h> long a,b,x,y,d; int gcd(long x, long y){ long t; if (x%y == 0){ a = 0; b = 1; } else{ gcd(y, x%y); t = a; a = b; b = t-(x/y)*b; } } int main(){ scanf("%ld%ld", &x, &y); d = b; gcd(a, b); printf("%d\n", (x%d + d)%d); }
C
#include "libi2c.h" /* * libi2c_write: * Send a complete write request to a given I2C slave module responding to * address 'addr'. The request shall be encoded in an array of UINT8 pointed * at by 'data' according to the specifications of your slave module, * with 'n' indicating the size in bytes of your request....
C
#include<stdio.h> int main() { int a,b,c,D; printf("Enter coefficients of the quadratic equation to check whether roots are real or imaginary.\n"); printf("\nCoefficient of x^2 = "); scanf("%d",&a); printf("\nCoefficient of x = "); scanf("%d",&b); printf("\nConstant = "); scanf("%d",&c); D=(b*b)-(4...
C
/*! \brief simple implement of quick sort * \author Shylock Hg * \date 2018-04-21 * \email tcath2s@gmail.com * */ #include <stddef.h> #include <stdio.h> #include <assert.h> #include "sort_common.h" static int pivot(array_t array, int lo, int hi){ int pivot = array.value[hi]; int i = lo; for(int j=lo; j<hi;...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* handle_pointer.c :+: :+: :+: ...
C
#ifndef SOCKET_H_INCLUDED #define SOCKET_H_INCLUDED #include <stdint.h> #define DEVICE_ID_INVALID 0 #define DEVICE_ID_SAIL 1 #define DEVICE_ID_HELM 2 #define DEVICE_ID_GPS 3 #define DEVICE_ID_ROLL 4 #define DEVICE_ID_WINDDIR 5 #define DEVICE_ID_COMPASS 6 #define DEVICE_ID_BATTERY 7 #define DEVICE_ID_TURNSPEED 8 stru...
C
/* ==================== fillTable ==================== This function fills the array rows with data. Pre array of pointers Post array filled */ void fillTable (int** table) { // Local Declarations int row = 0; // Statements printf("\n ============================="); printf("\n Now we fill the table...
C
#include <stdio.h> #include <stdlib.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main() { int dias, mes, anos, idade; printf("Digite dias:"); scanf("%d", &dias); printf("Digite mes:"); scanf("%d", &mes); printf("digite anos:"); scanf("%d"...
C
// This is the application which will make use of the library // Claude Zhang // John Weng // Victor Wibisono // modified from code by Eric McCreath, 2012 #include "library.h" uint16_t k = 48; uint16_t j = 48; uint16_t i = 0; main() { meggyInit(); // Serial out stuff sei(); while (1) { // the main function ...
C
// Desenvolvido por Bárbara Gabriele Lima Luz Santos e Rafael Correa Nagy #ifndef manager #define manager #include <stdlib.h> #include <stdio.h> #include <string.h> #include "queue.h" typedef struct mng{ fila** FdP; unsigned int tam; } gerenciador; /* * Função vazia_gerenciador * Verifica se o gerenciador está...
C
#include "utils.h" void error(const char *msg) { perror(msg); exit(1); } char* copy_string(const char *src) { size_t len = strlen(src); char *copy = malloc((len+1) * sizeof(char)); strcpy(copy, src); return copy; } int write_string(const int fd, const char* string) { int n = write(fd,string,strle...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* init_rooms.c :+: :+: :+: ...
C
#include "lista.h" #include <stdio.h> #include <stdlib.h> #include <string.h> header* initial_header() { header *init_header = (header*) malloc(sizeof(header)); init_header -> n_elem = 0; init_header -> head = NULL; init_header -> tail = NULL; return init_header; } list *new_list; list* initial...