language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
/* ** EPITECH PROJECT, 2019 ** PSU_my_sokoban_2019 ** File description: ** check_map */ #include "sokoban.h" int check_how_many_o(char **map) { int a = 0; int b; int count = 0; while (map[a]) { b = 0; while (map[a][b]) { if (map[a][b] == 'O') count++; ...
C
#include <stdio.h> int main() { int num,i,p=2,result=1; scanf("%d",&num); for(i=1;i<=num;i++) { result=result*p; if(result==num) { printf("yes"); break; } else { continue; } } if(result!=num) { printf("no"); } return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #include "bubblefunc.h" #define ARRAY_NUM 20 /* program entry */ int main(int argc, char **argv) { int array[ARRAY_NUM] = {0}; int i, j, r; int fFind; srand(time(NULL)); /* 1 からARRAY_NUMの重複しない値をランダムにarrayに格納する。*/ for( i = 0; i < ARRAY_NUM; i++ ) { ...
C
#include"Stack.h" #include<stdio.h> #include<stdlib.h> void create(stack *s) { s->sz=500; s->top=0; s->A=(char *)malloc(s->sz*sizeof(char)); } void push(stack *s,char st) { if(isFull(s)==0) { printf("\nStack is Full!You cannot insert more\n"); return ; } s->A[s->top++]=st; ...
C
#include <stdio.h> #include <string.h> #include <stdio.h> #include <errno.h> #include <fcntl.h> #include <unistd.h> #include <stdlib.h> #include <stdbool.h> #include <stdint.h> #include <string.h> #include <getopt.h> static struct option main_options[] = { { "help", 0, 0, 'h' }, { "verbose", ...
C
/* * Board.h * * Created on: Mar 30, 2017 * Author: luke */ #ifndef BOARD_H_ #define BOARD_H_ #include "Piece.h" #include "Types.h" #define BOARD_SIZE 8 typedef struct _Board { Piece pieces[BOARD_SIZE][BOARD_SIZE]; } Board; typedef struct { Piece piece; Coordinate coordinate; } PlacedPiece; typedef s...
C
/* * keyboard.c * * Created on: 2015/12/19 * Author: koji */ #include "keyboard.h" #define PORT_KEYSTA 0x0064 #define KEYSTA_SEND_NOTREADY 0x02 #define KEYCMD_WRITE_MODE 0x60 #define KBC_MODE 0x47 void wait_KBC_sendready(void) { /* wait until KBC can send */ while(1){ if((io_in8(PORT_KEYSTA) & K...
C
#include "header.h" //to check the extension status extention(char *arr,FILE **fp,int *end) { //check for file extention int j; for(j=0;arr[j] != '\0';j++) { if(arr[j] == '.') { char *temp = &arr[j]; if(0 == strcmp(".c",temp)) { break; } else { puts("Not a C file"); ...
C
#include <stdio.h> #include <stdlib.h> int main () { /* greeting */ printf("hi\n"); /* farewell */ printf("bye\n"); /* all went well */ exit(0); }
C
#include <stdio.h> #include <stdlib.h> #include "tipusok.h" #include "econio.h" #include "start.h" #if defined(WIN32) || defined(_WIN32) #include <windows.h> #endif int main() { #if defined(WIN32) || defined(_WIN32) SetConsoleCP(1250); SetConsoleOutputCP(1250); #endif printf("Hel...
C
#include<stdio.h> #include<stdlib.h> struct node { int data; struct node *link; }*front = NULL, *rear = NULL; int isEmpty() { if(front == NULL) { return 1; } else { return 0; } } void insert(int item) { struct node *temp; temp = (struct node *)malloc(sizeof(struct node)); if(temp == NULL) { printf(...
C
/* Uri 1018 - Cedulas Autor: Carlos Henrique Silva Correia de Araujo Aluno de Engenharia de Computacao - UFPB (1° Semestre) */ #include <stdio.h> int main(void){ int valor, notas, resto; scanf("%d", &valor); printf("%d\n", valor); notas = valor / 10...
C
#include <stdio.h> void multiplicar_matrizes(int l1, int c1, int matriz1[][c1], int l2, int c2, int matriz2[][c2]) { //A matriz produto terá o número de linhas de A e o número de colunas de B int i,j, produto[l1][c2], ki, kj,aux; for (ki = 0; ki <= l1; ++ki) {//primeiro laço para fixar as linhas, percorre ...
C
#include <stdio.h> #include <stdlib.h> /* BUT Ecrire un programme en C qui dtermine la nime valeur 'un', 'n' fournit par l'utilisateur de la suite de fibonacci ENTREE Le numero de la Nieme valeur rechercher SORTIE La la Nieme valeur */ int main() { int nPremierNombre=0,nSecondNombre=1,nMem=0,nNiemeValeur=0,nCpt=0;...
C
#include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <netinet/in.h> #include <errno.h> #include <stdio.h> #include <string.h> #include <arpa/inet.h> #include <stdlib.h> int main(int argc, char *argv[]) { if (argc<2){ printf("Please provide at least one hostname\n"); exit(0); } ...
C
#include <unistd.h> #include <stdio.h> int main(int argc, char**argv) { char mesg[50]; while(1) { ssize_t bytes_read = read( 0, mesg, sizeof(mesg) ); //write( 1, mesg, bytes_read ); if(bytes_read == 0) { return 0; } mesg[bytes_read] = '\0'; puts(mesg); } return 0; }
C
/** * @file actor.h * * @brief file containing actor system for animation control */ #ifndef __ACTOR__ #define __ACTOR__ #include "types.h" /** * @brief defines the animation types */ typedef enum { ANIM_NO = 0, ANIM_PASS = 1, ANIM_LOOP = 2, ANIM_OSCI = 3 }Anim_Type; /** * @brief defines the Actor st...
C
#include<stdio.h> #include<conio.h> void main() { int select; int iq,mathss,english; char ans='y'; long sum; int exit; int a,b,c; clrscr(); printf("\t\t***Aptitude Test***\n"); printf("1.IQ\n2.English\n3.General knowledge\n4.Exit\n"); printf("Pr...
C
#include <stdio.h> /* Faça um programa em C para converter graus Celsius para Fahrenheit. Seu programa deve ler o valor em Celsius, calcular e imprimir o correspondente e, Fahrenheit. Fórmula: F = C × 1,8 + 32 */ int main() { float celsius, fah; printf("\nEntre com temperatura em Celsius:"); scanf("...
C
#ifndef GIT_CHAT_RUN_COMMAND_H #define GIT_CHAT_RUN_COMMAND_H #include <sys/types.h> #include "argv-array.h" #include "str-array.h" #include "strbuf.h" /** * run-command api * * The run-command api provides an interface for executing programs and shell * commands as child processes, manipulating their standard s...
C
#include <stdio.h> #include <stdlib.h> int main() { int x = 5; printf("Tipo inteiro\n"); printf("Conteudo %d\n", x); // Impresso do endereo printf("Endereo %p\n", &x); // Impresso da quantidade de bytes ocupada printf("Qtd bytes: %d\n\n\n", sizeof(x)); float y = 6.5; printf("Tipo ...
C
#include <stdio.h> #include <stdlib.h> #define p printf int len(char *stream) { int co=0; while (*stream) { ++stream; co += 1; } return co; /*including null character*/ } void key_seg(char *key) { int i; for (i=0; i<len(key) - 1; i++) { if (48 <= key[i] <= 57) ...
C
#pragma once #include <common_types.h> #include <limits.h> #include <openssl/ssl.h> #include <unistd.h> static const ErrorCode ERROR_INVALIDATED_SSL = 1; // Must be a multiple of 8 due to struct packing #define NODE_SIZE (0x1000) /* Represents a (node of a) potentially infinitely-long string that gets read from a p...
C
/* Single Author info: hmajety Hari Krishna Majety Group info: hmajety Hari Krishna Majety srout Sweta Rout mreddy2 Harshavardhan Reddy Muppidi */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> ...
C
#include <stdio.h> #include <stdlib.h> #include "experiment.h" LinkList* CreatList() { //创建链表 LinkList *head; head = (LinkList*)malloc(sizeof(LinkList)); head->next = NULL; return head; } int Size(LinkList *list) { //求链表的元素个数 LinkList *p = ...
C
/* * Copyright (c) 2008-2010 Sander van der Burg * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, m...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 10 void bubble_sort(int array[], int length); void print(int array[]); int main() { int i, buf[10]; srand(time(NULL)); for(i=0; i<10; i++) { buf[i] = (long) rand() % 100 + 1; printf("%3d ", buf[i]); } printf("\n"); bubble_sort(bu...
C
#include<stdio.h> void bubblesort(int k[], int n) { int i, j, tmp, flag = 1; for(i=1; i<=n-1 && flag==1; i++){ flag = 0; for(j=1; j<=n-i; j++){ if(k[j] < k[j+1]){ tmp = k[j+1]; k[j+1] = k[j]; k[j] = tmp; flag = 1; } } } }
C
#include <windows.h> #include <stdio.h> #define LECTION_EXAMPLE 1 #define QUANTITY_NEED_ITERATION_PROGRAMM 5 #define TIME_DELAY_PROGRAMM_IN_THOUSANDTH_OF_SECOND 5000 #if LECTION_EXAMPLE typedef int (*function)(int); //new type that is pointer function for return integer #endif int main() { int iteratio...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> void operate1(char *, char *, char *, char *, int, int);//Interval comparison void operate2(char *, char *, char *, char *, int, int);//Sequence comparison int main(int argc, char *argv[]){ int arg = argc, start, end; char filenameA[20], filenameB[20]; ...
C
#include "select.h" /** \Função que faz a seleção de dados * * \param CountryHead -> ponteiro para a head da lista de países * \param select_data -> Argumento dado pelo utilizador para o tipo de seleção de dados * \return * */ void select_d(Country* CountryHead, char select_data[12]) { Country* country = Co...
C
// // repository.c // Lab4 // // Created by andreio on 06.03.2017. // Copyright © 2017 Andrei. All rights reserved. // #include <string.h> #include "repository.h" #include <stddef.h> #include <assert.h> EstateRepo createRepo() { EstateRepo v; v.length = 0; return v; } int find(EstateRepo* v, char...
C
#include<string.h> #include<stdio.h> int main() { char *str=NULL; str = (char *)malloc(sizeof(char)); printf("enter a string::\n"); gets(str); int i=0,count=1; int j; int l; l=strlen(str); for(i=0;i<l;i++) { count=1; for(j=i+1;j<l;j++) { if(str[i] == str[j]) { ...
C
#ifndef CHESS_ #define CHESS_ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <SDL/SDL.h> #include <SDL_image.h> #include <math.h> #include <time.h> /* structs */ struct checker{ char x; int y; }; typedef struct checker checker; struct legalMovesRepository{ int size; int pos; char **l...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> #include <windows.h> #define N 20 void Names(char A[][25],int n) { srand(time(0)); int i,j,k; for(i=0;i<n;i++) { k=2*(rand()%10+3); // for(j=0;j<k;j++) A[i][j]=rand()%30+176; // A[i][j]='\0'; } } void NameBubble(char A[][25],in...
C
#include <stdio.h> #include <sys/ptrace.h> int main() { static int i;//静态全局变量,每次运行地址不变 int abc=9527;//临时变量,地址不固定 但是依然有办法修改。用内存扫描工具 scanmem printf("pid %d\n",getpid()); printf("i=%x abc=%x\n",&i,&abc); for(i=0;i<10000;i++) { printf("i = %d abc = %d\n",i,abc);//让i每10秒自增一次,然后我们用另一个程...
C
#include <stdio.h> #include <stdlib.h> #include "simpleCChatConfig.h" #ifdef _WIN32 #include <windows.h> #include "helloWindows.h" #else #include <pthread.h> #include "helloWorld.h" #endif int main(){ printf("Version %d.%d.%d\n", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH); printf("Hello World!\n"); #ifdef...
C
/*------------------------------------------------ *------------------------------------------------ * |id : 112 0821 042 * |name : Alim Ul Karim * |email : alim.karim.nsu@gmail.com * |course : CSE 115.2 * |blog : http://bit.ly/auk-blog * |linkedin : http://linkd.in/alim-ul-kari...
C
#include "../includes/putYesNo.h" int putYesNo(SDL_Surface *dest, TTF_Font *font, SDL_Color color) { SDL_Rect pos; pos.x = 64; pos.y = 148; if (!putFont(font, "Yes", color, dest, &pos)) { fputs("Error : Can't put yes\n", stderr); return (0); } pos.x += 270; if (!putFont(font, "No", color, dest, &pos)) {...
C
/* * badcnt.c - An improperly synchronized counter program */ #include "csapp.h" void *thread1 (void *vargp); /* Thread routine prototype */ void *thread2 (void *vargp); /* Thread routine prototype */ void *thread3 (void *vargp); /* Thread routine prototype */ /* Global shared variables */ volatile int cnt = 0; /*...
C
/* * thermometer.c * * Created: 2014-12-20 20:18:18 * Author: rgawron */ #include "thermometer.h" void thermometer_init_adc() { // set Aref as AVcc ADMUX = (1<<REFS0); ADCSRA = (1<<ADEN) | (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0); } uint16_t thermometer_read_adc(uint8_t ch) { // select ADC Channel...
C
#include <math.h> //#ifndef FOURIER_H //#define FOURIER_H inline void SWAP(float &a, float &b) {float dum=a; a=b; b=dum;} void fft(float* reales, float* imaginarios, int n, int isign) { int m, i, mmax, istep; float wtemp,wr,wpr,wpi,wi,theta,tempr,tempi; int j=0; // ordenamos con reversed byte order for (...
C
#ifndef ESCAPE_H #define ESCAPE_H #include "compiler.h" enum base { BIN, OCT, DEC, HEX }; const char *base_to_str(enum base); /* convert a (wide?) character to an int * is_wide dictates whether * 'abc' -> (('a' * 256) + 'b') * 256 + 'c' * or * L'abc' -> L'c' * * warn: EINVAL ('\z'), E2BIG ('abcde') * er...
C
#include <stdio.h> #include <stdint.h> #include <string.h> #include <mcc/treeset.h> #include <mcc/typehandlers.h> void print_treeset(uint16_t* set) { for (mcc_size_t i = 0; i < mcc_treeset_size(set); ++i) printf("%d ", set[i]); } int main(int argc, char** argv) { uint16_t count = 14; uint16_t* set...
C
/* * Esame del 09/09/2016 * * (Versione con ARRAY) * * Testo dell'esame completo: * http://dijkstra.di.unipi.it/#/task/LezEsami_2015-2016Esame20160909c1/statement */ #include <stdio.h> #include <stdlib.h> #define min(a, b) ((a < b) ? a : b) /* * Coda di interi. */ typedef struct { int* queue; /* La coda...
C
#pragma once #include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> #include "sprawdzanie.h" #include "wczytaj.h" #include "osoba.h" #include "firma.h" #include "umowa.h" /// Struktura, ktora zawiera wskazniki do wszystkich baz w programie /// /// Nie ma mozliwosci edycji bazy danych os...
C
#pragma once #include "SharedHeader.h" static const XMVECTOR KVectorZero{ XMVectorZero() }; static const XMVECTOR KVectorGreatest{ XMVectorSet(FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX) }; static bool IntersectRaySphere(const XMVECTOR& RayOrigin, const XMVECTOR& RayDirection, float Radius, const XMVECTOR& Center, XMVECTOR*...
C
/* ** EPITECH PROJECT, 2019 ** Task 04 ** File description: ** Write a function that displays either ** N if the integer passed as parameter is negative, P, if positive or null. */ void my_putchar(char c); int my_isneg(int n) { if (n >= 0) my_putchar('P'); else my_putchar('N'); my_putchar('...
C
#include <common.h> double makeSmall(u32int InBytes, char *out) { double Bytes = InBytes; if(Bytes < 2048){ *out = 'B'; return Bytes; } if(Bytes < 2048 * 1024){ *out = 'K'; return Bytes/1024; } *out = 'M'; return ((Bytes/1024)/1024); }
C
#ifndef _FTP_H_ #define _FTP_H_ #include <stdlib.h> #include <stdbool.h> typedef struct ftp_info { size_t size; bool valid; char *data; } ftp_info_s; /** * INPUT: * url - URL that cURL is going to get the data from * OUTPUT: * ftp - Stores the data of what was received * RETURN: * True if dat...
C
/* * openGL Rendering functions with minor GLUT involvement */ //Includes #include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include <GL/glut.h> //linux #include "rendering.h" #include "keyboard.h" #include "lorenz.h" #define GL_GLEXT_PROTOTYPES //Global Variables int number_of_points = 10000...
C
/*関数 複数の処理をまとめたもの、大体は数学で一般的に使われる関数と同じ*/ #include <stdio.h> int g = 1;//グローバル変数 float getmax(float a, float b){ if(a >= b){ return a; } else{ return b; /*これは下記のように書くことができこの書き方を三項演算子という 返り値 = (条件)? a:b; つまり return = (a>=b)? a :b; printfなどでも使える */ } } void Hello(void); /*関数はどこに書いてもいいがmainより下にあ...
C
/** Original Question : https://stackoverflow.com/questions/67025106/ **/ #include <string.h> #include <stdio.h> #include <stdlib.h> #include "mpi.h" int main( int argc, char *argv[] ) { MPI_Init(&argc, &argv); int myrank, size; MPI_Comm_rank(MPI_COMM_WORLD, &myrank) ; MPI_Comm_size(MPI_COMM_WORLD, &...
C
#include <stdio.h> /* i/o library */ #include <stdlib.h> /* exit call */ #include <string.h> /* string functions */ #include <netdb.h> /* net functions */ #include <unistd.h> /* closing fds */ #include <arpa/inet.h> /* inet ntop */ #define BUFFSIZE 1024 /* Function: createClient Description: Sets up a client connec...
C
#include <stdio.h> void main() { int x=2, y=6, z=5; int t=1; int i; for(i=0; i<y; i++) { t = (t*x)%z; } printf("%d\n", t); }
C
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <limits.h> #define true 1 #define false 0 int x = 158969851; bool main() { if (x < 0) { return false; } else { int temp = x; int rev = 0; while (x != 0) { int a = x % 10; ...
C
#pragma once #include <stdbool.h> #include "time.h" #ifdef __cplusplus extern "C" { #endif #define MIN(a,b) (((a)<(b))?(a):(b)) #define MAX(a,b) (((a)>(b))?(a):(b)) #define SCHEDULER_DELAY_LIMIT 10 #define TIMEUS_MAX UINT64_MAX #define TASK_PERIOD_HZ(hz) (1000000 / (hz)) #define TASK_PERIOD_MS(ms) ((ms) * 1000) #defin...
C
#include<stdio.h> int sum(int, int); void printglobali(void); int globali; int main() { extern int globali; int i, j; i = 6; j = 7; globali = sum(i, j); printglobali(); return 0; } int sum(int i, int j) { return i + j; } void printglobali(void) { extern int globali; printf("globali is...
C
#include<stdio.h> void print_odd_elements(int size,int *pointer){ int i; for(int i = 0; i < size; ++i) { if ( i % 2 == 1) { printf("array[%d]: %d\n", i, pointer[i]); } } } void print_odd_pointers(int size,int *pointer){ int i; for(int i = 0; i < size; ++i) { if ( i % 2 == 1) { ...
C
#include<stdio.h> int main() { double a,b,c,d,e,x,y; scanf("%lf %lf %lf %lf",&a,&b,&c,&d); x= (2*a+3*b+4*c+d)/10; printf("Media: %.1lf\n",x); if(x>=7){ printf("Aluno aprovado.\n"); } else if(x<5){ printf("Aluno reprovado.\n"); } else ...
C
//Programa que cria uma matriz 4x4 e calcula qual linha tem a maior soma #include <stdio.h> main() { int mat[4][4],i,j,loja1,loja2,loja3,loja4; for (i=0;i<4;i++)//atribuindo valores para o vetor { for (j=0;j<4;j++) { printf("\nDigite a posicao [%d][%d] do vetor: ",i,j); scanf("%d",&mat[i][j]); } } for (i...
C
/* * BitMath.h * * Created: 05-Dec-20 6:08:47 PM * Author: George Zaky */ #ifndef BITMATH_H_ #define BITMATH_H_ #define SetBit(Reg,BitNo) (Reg |= (1<<BitNo)) #define ClearBit(Reg,BitNo) (Reg &=~ (1<<BitNo)) #define ToggleBit(Reg,BitNo) (Reg ^= (1<<BitNo)) #define GetBit(Reg,BitNo) ((Reg>>BitNo)&1) #endif /...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> double add(double a, double b) { return a + b; } double subtract(double a, double b) { return a - b; } double multiply(double a, double b) { return a * b; } double divide(double a, double b) { if (b == 0) { printf("ERROR:...
C
#include <boxer/boxer.h> int main(int argc, char *argv[]) { boxerShow("Simple message boxes are very easy to create.", "Simple Example", kBoxerDefaultStyle, kBoxerDefaultButtons); boxerShow("There are a few different message box styles to choose from.", "Style Example", BoxerStyleError, kBoxerDefaultButtons); ...
C
#include <stdio.h> #include <stdlib.h> typedef struct Node{ int value; struct Node * next; } Node; typedef struct Stack{ Node * top; } Stack; Stack * create(){ Stack * q = (Stack*) malloc(sizeof(Stack)); q->top = NULL; return q; } void push(Stack * s, int value){ Node * new = (Node*) mallo...
C
#include <stdlib.h> #include <stdio.h> #include "freelanser.h" void freeLanser_print(freeLanser_t * fl) { printf("\nName: %s\nSurname: %s\nSalary: %0.2f\nCompletedProjects: %i\nBirth date: %s\n\n", fl->name, fl->surname, fl->salary, fl->completedProjects,fl->birthDate); }
C
#ifndef COMMON_H #define COMMON_H #include "openiboot.h" #include "util.h" #define FLIPENDIAN(x) flipEndian((unsigned char *)(&(x)), sizeof(x)) #define FLIPENDIANLE(x) flipEndianLE((unsigned char *)(&(x)), sizeof(x)) #define TRUE 1 #define FALSE 0 #define IS_BIG_ENDIAN 0 #define IS_LITTLE_ENDIAN 1 #define T...
C
#include<stdio.h> int main() { int i, cnt=0, p8[8]={6,7,8,9,1,2,3,4}; int p10[10]={6,7,8,9,10,1,2,3,4,5}; char input[11], k1[10], k2[10], temp[11]; char LS1[5], LS2[5]; //k1, k2 are for storing interim keys //p8 and p10 are for storing permutation key //Read 10 bits from user... printf("Enter 10 bits input:...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> int main() { srand(time(0)); char losuj_wyraz[10]; int i; char losowa; char *p; char *p2; int ilosc=0; losowa=(rand()%25)+97; for(i=0;i<10;i++) { losuj_wyraz[i]=(rand()%25)+97; ...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <math.h> #include <tgmath.h> #include <time.h> #include <errno.h> #include <fcntl.h> #include <mqueue.h> #include <sys/types.h> #include <sys/wait.h> #include <sys/mman.h> #include <semaphore.h> #define SIZE 4 int prime(int n); void main(int argc, ch...
C
#include <string.h> #include "haml_indent.h" enum indent_type haml_indent_type = undefined; int haml_indent_size = -1; int haml_current_indent = -1; int haml_get_current_indent() {return haml_current_indent;} void haml_set_current_indent(int indent_size) {haml_current_indent = indent_size;} int haml_get_indent_size(...
C
#include <stdio.h> /** * @synopsis insert_sort * * @param L[] * @param length * * 0. 基本思想 * 每次将一个待排序的数据,跟前面已经有序的序列的数字一一比较找到自己合适的位置,插入到序列中,直到全部数据插入完成。 * * 1. 时间复杂度 * 平均 O(n^2) 比冒泡和简单选择性能要好些 * 最坏 O(n^2) 逆序,移动 O(n^2) 次,比较 O(n^2) 次 * 最好 O(n) 全部有序,只需要比较,不需要移动 * * 2. 空间复杂度 * 只需...
C
#include <stdio.h> #include <stdlib.h> struct playerStruct{ char name[50]; int age,matches,avg; }p[20],s[20]; int cmpfncn(const void* s1,const void* s2) { if(((struct playerStruct*)s1)->avg > ((struct playerStruct*)s2)->avg) return 1; else return 0; } void main() { int i,j,n,av[20...
C
#include "../include/pbound.h" #include "../include/ptile.h" ///////////////////// // PBound comparison functions. Note that some of these are a bit unusual. //pbound equality bool eq(const PBound *lhs, const PBound *rhs){ switch(lhs->state){ case EMPTYSET: return (rhs->state == EMPTYSET); case SINGL...
C
#include <avr/io.h> #include <util/delay.h> #include <avr/interrupt.h> #define FOSC 16000000UL #define baud_rate 4800 #define baud FOSC/16/baud_rate-1 #define SYNC 0xAA #define RX_ADDR 0x21 #define LED_ON 0x11 char data=0; typedef enum state_t{LOW,HIGH}state; ...
C
#include<stdio.h> #include<conio.h> #include<math.h> int main(void) { double i,x,y=0,n; printf("This program displays the value of y in following expression.\n\n"); printf("\ty = 1 + x + x^2 + x^3 + ... + x^n .\n\n\n"); printf("Enter x : "); scanf ("%lf",&x); printf("Enter n : "); scanf ("%l...
C
#include <stdlib.h> #include <stdio.h> /* Codigo hecho por mi cuenta. */ int main (){ int N, cases, i, j, contX, contO, winX, winO; /* Ocupamos una matriz de 3x4 ya que almacenaremos las lineas escaneadas como string por lo tanto debe tener espacio para '\0'. */ char tictac[3][4]; scanf("%d", &N); for(cases=0...
C
#include "audit_lock.h" int file_set_lock(int fd, int cmd){ struct flock lock; lock.l_whence=SEEK_SET; lock.l_start=0; lock.l_len=0; lock.l_pid = getpid(); if(cmd == F_SETLK) lock.l_type=F_WRLCK; // printf("type:%d\n",lock.l_type); if(fcntl(fd,cmd,&lock)==-1) return -1; else return 1; } int file_get_loc...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_get_conversion.c :+: :+: :+: ...
C
#include <stdio.h> #include <malloc.h> #include <vld.h> #pragma warning(disable:4996) int main() { int *p = (int*)malloc(sizeof(int)); int *p1 = p; free(p); printf("%d", *p1); return 0; }
C
/* Rotated Triangle Pattern Given an integer N, print the pattern as given in Example Input/Output section. Note: N is always an odd number. Boundary Condition(s): 1 <= N <= 9999 Input Format: The first line contains N. Output Format: The first N lines contain the desired pattern. Example Input/Output 1: Input: 7 ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strsplit.c :+: :+: :+: ...
C
/* * log.c * Author: wangwei. * Custom logging functions. */ #include <stdarg.h> #include <stdio.h> #include <string.h> #include "../../include/sg/util/log.h" #include "../../include/sg/sys/time.h" #include "../../include/sg/sys/shell.h" #include "../../include/sg/str/vlstr.h" #include "../../include/sg/sys/module...
C
#include "search_algos.h" /** * exponential_search - search for value with exponential search algorithm * @array: pointer to the beginning of the array to be searched * @size: size of the array being searched * @value: value being searched for * Return: index of found number */ int exponential_search(int *array,...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include "fonctionsSocket.h" /* definition des types */ #include "types4.h" int main(int argc, char *argv[]) { int desc_sock; /* descripteur de socket */ int envoyes; mon_type_t foo = 42; ma_structure_t bar; bar.a = 10; bar.b[0] = 'H'; bar...
C
#include <pthread.h> #include <stdio.h> long long sum; long long outArr[1024]; void *runner(void *param); int main(int argc, char *argv[]) { pthread_t tid; pthread_attr_t attr; if (argc != 2) { fprintf(stderr,"usage: fib.out <integer value>\n"); return -1; } char *ptr = NULL; int upper ...
C
#include <stdio.h> int ft_recursive_factorial(int nb); int main(void) { int i; for (i=-1; i<=13; i++) printf("%d!\t= %d\n", i, ft_recursive_factorial(i)); return (0); }
C
#include <stdint.h> #include <stdbool.h> #include <inc/hw_memmap.h> #include "../inc/debugging_utilities.h" #include "../inc/computations.h" #include "../inc/buttons.h" #include "../inc/LCD.h" #include "../inc/initialization.h" #include "../inc/main.h" #include "../inc/images.h" #include "../inc/random.h" #include "dri...
C
/* * Sequential Turn Signal - main.c * This file contains the microcontroller code to implement sequential turn signals on the Corvette * (c) 2017 Michael Yuhas */ /* * Includes: * msp430.h - constants and pin mappings for msp430 */ #include <msp430.h> /* * Definitions: * TIMER_RESOLUTION_MS - resolution of ...
C
// Pentcho Tchomakov - 260632861 #include <stdio.h> #include <stdbool.h> #include <stdarg.h> #include <stdlib.h> // Method to insert spaces // Once we've added all the stars we wanted in the 2D array, we add spaces to every other coordinates. // We replace "" with " " when [x][y] doesn't contain a "*" void fillEmpty(...
C
#include <stdio.h> long long int fibo[1000000]; int main() { long long int t; scanf("%lld",&t); long long int i,j; fibo[0]=0,fibo[1]=1; for(i=2;i<=1000000;i++) { fibo[i]=(fibo[i-1]+fibo[i-2])%(1000000000+7); } while(t--) { long long int n; scanf("%lld",&n); printf("%ll...
C
#include <stdio.h> #include <stdlib.h> int main() { int *contro; int a = 10; contro = &a; printf("%d\n", a); printf("%d\n", *contro); printf("%d\n", &a); printf("%d\n", &contro); int mang[4]; int *contro; contro = mang; for (int i = 0; i < 4 ; ++i) { printf("%d\n", mang[i + 1]);...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "Common.h" //#define LEVEL1 TRUE #define LEVEL2 TRUE void main(int argc, char *argv[]) { #if defined(LEVEL1) /*Normal sample*/ struct _BOOKS book1; BOOK book2 = {"Let it go", "nick", 45}; strcpy(book1.name, "Game of war"); strcpy(book1.auth...
C
#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include "mysql.h" int main(int argc, char* argv[]){ MYSQL *conn; conn = mysql_init(NULL); if (conn == NULL){ printf("mysql_init failed!\n"); return EXIT_FAILURE; } conn = mysql_real_connect(conn, "127.0.0.1", "root", "kjzyw325", "grafan...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> //strlen #include <sys/socket.h> #include <arpa/inet.h> //inet_addr #include <unistd.h> #include <sys/wait.h> #include <sys/types.h> #include "fctServeur.h" // fonction qui s'occupe de la recuperation de donnee depuis le fichier text void recup_donne(struct tr...
C
#include <stddef.h> #include "slist.h" void init_list_node(list_node_t * node) { node->next = NULL; } void insert_list_node(list_node_t ** list, list_node_t * node) { if ((!list) || (!node)) return; if (!*list) { *list = node; } else { node->next = *list; *list = n...
C
#include <stdio.h> #include <stdlib.h> extern char **environ; void envlist(){ int i=0; char *str; while((str=environ[i])!=NULL){ printf("%s\n",str); i++; } } int main(int argv,char *argc[]){ //envlist(); if(argv<2){ printf("Error:"); exit(1); } char *s = getenv(argc[1]); printf("%s\n",s); return 0; ...
C
/************************************************************************* > File Name: mpipe.c > Author: > Mail: > Created Time: Fri 27 Jul 2018 04:07:53 PM CST ************************************************************************/ #include<stdio.h> #include<unistd.h> #include<errno.h> #define ERRNO_SUCCES...
C
/*** *fscanf.c - read formatted data from stream * * Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved. * *Purpose: * defines fscanf() - reads formatted data from stream * *******************************************************************************/ #include <cruntime.h> #in...
C
#include<stdio.h> #include<ctype.h> int main() { int i = 0; char l[50], u[50]; printf("enter lowercase string\n"); gets(l); printf("enter uppercase string\n"); gets(u); while (l[i] != '\0') { if (islower(l[i])) l[i] = toupper(l[i]); i++; } printf("string after converting to uppercase is : %s\n",l); i ...