language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> void error(const char *msg) { perror(msg); exit(0); } void normalize(char * a, int n) { for (int i = 0 ; i < n ; ++i) { if (a[i]...
C
#include<stdio.h> /** * This program adds to vectors a and b * and returns c as an array using parameter. * http://codeforwin.org/2017/12/pass-return-array-function-c.html */ // define globals #define VEC_LEN 3 // init function declarations void fill_vec(double vec[], double scalar); void add_2vec(double c[],dou...
C
/****************************************************************************** * Copyright (C) 2020 by Ahmed AbdulAzeem * *****************************************************************************/ /** * @file stats.c * @brief Example c programming file * * A simple c-programming example that exhibits a han...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "tableHeader.h" #include "Macro.h" /************************************************************************* * Func: printTable(Table) * Para: table_t *p, int n * retrurn: void ****************************************************...
C
#include<stdio.h> int main() { int num, slryprhr; float time; scanf("%d%d%f", &num, &slryprhr, &time); printf("NUMBER = %d\n", num); float salary=slryprhr*time; printf("SALARY = U$ %.2f\n", salary); return 0; }
C
/* @(#)test-c.c */ #include <stdio.h> int fib(int n) { if (n < 3) return 1; return fib(n-1) + fib(n-2); } int main(int argc, char *argv[]) { printf ("%d\n", fib(45)); return 0; }
C
/********************************************************************* Nome do arquivo: main_13.c Data: 07 de janeiro de 2009 Versao: 1.0 MPLAB IDE: v8.20a Autor: Wagner Zanco *********************************************************************/ #inclu...
C
#include <assert.h> #include <stdbool.h> #include <string.h> #include "intersectors/dumb_bs.h" #include "algorithms/binary_search.h" size_t dumb_bs_intersect(size_t lists_sz, const list_t * lists, size_t how_much, uint32_t * result) { // Iterator analog typedef uint32_t * iter_t; // O...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_move_one.c :+: :+: :+: ...
C
/*************************************************************************************** * Authors: Jeffrey Cirka, Andy Pat * Date: 04/09/2013 * ASU email: jscirka@asu.edu, apat1@asu.edu * Course: CSE 430 TTH 4:30-5:45 * Project#: 3 * Language: c * Compiler: gcc * Description: * This file contain...
C
/*Program for applying newton forward difference formula for differentiation*/ #include<stdio.h> #include<math.h> int fact(int n) //function to find the factorial of n { int f=1,i; for(i=2;i<=n;i++) f*=i; return f; } int main() { FILE *fp; //file pointer declared fp=fopen("18.txt","w"); int n,i,j; ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* distance.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> #define MAX 100 /* Assume that global data is initialized to 0. */ int NUM; int a[MAX][MAX]; float b[MAX][MAX]; double c[MAX][MAX]; int check_a() { int check = 0; int i,j; for ( i= 0 ; i < MAX; i++ ) { for ( j= 0 ; j < MAX; j++ ) { check += a[i][...
C
// This is the prayer the darkling cleric casts. It's supposed to // work like a cleric lightning, but with aligns reversed #pragma strict_types #include "../def.h" inherit CLERIC_LIGHTNING; int check_target(object who,object cross,int boolean = 1); int test_spell(string casting_spell,int bonus); float query_alignment...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <complex.h> #include <fftw3.h> #include <omp.h> #ifndef PI #define PI 3.1415926535897932384626433832795028841971693993751 #endif #ifndef FABS #define FABS(a) ((a)>=0?(a):-(a)) #endif double f(double x, void* data) { return sin(x); ...
C
/** @file rpoly.h * @brief Function prototypes for the computation of the * roots of a polynomial with real coefficients. * * This header file contains the prototypes for the computation of the roots * of a polynomial with real coefficients. * * @author Miguel Alonso Angulo. * @bug No known bugs. */ #if...
C
#ifndef _RBUF_H_ #define _RBUF_H_ #include <types.h> typedef struct Rbuf_t { uchar* buffer; /* Buffer pointer */ uint element_size; /* Size of each element */ uint count; /* Number of elements that can be fit in */ uint put; /* Write to here */ uint get; /* Read f...
C
/** * @file utils.c * @author Pablo Cuesta, Álvaro Zamanillo * @brief functions to read files of the project to buffers * to avoid constant file reading */ #include "utils.h" #include <stdlib.h> extern char *strndup(const char *, size_t ); /** * @brief This function reads the whole file with name * ...
C
// Exercício 12 - Leia um vetor de 10 posições e elimine as posições com valor zero avançando uma posição, com os valores subsequentes do vetor. Dessa forma todos "zeros" devem ficar para as posições finais do vetor. # include <stdio.h> int linha(void) { char x = '-'; printf("\n\033[33m"); for (int co...
C
/** ** Triangle of * Program ** Ahasanul Basher Hamza ** Date: 23/02/18 ***/ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <strings.h> #include <math.h> #include <ctype.h> int main() { int i,j,n; scanf("%d",&n); for(i = 0;i < n;i++) { int d,k; scanf("%d", &d); ...
C
#include <stdio.h> #include <stdlib.h> #include <sys/socket.h> #include <arpa/inet.h> #include "./Utils/Util.h" int main(int argc, char *argv[]) { if (argc != 2) ExitError("Usage: %s <port>\n", argv[0]); int serv_sockfd = socket(AF_INET, SOCK_STREAM, 0); if (serv_sockfd == -1) ExitError("socket error"); str...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* bfs.c :+: :+: :+: ...
C
#include<stdio.h> void main() { int number; printf("##### Program to check if number is Even or Odd #####\n\n"); printf("Enter the number: "); scanf("%d", &number); if(number%2 == 0 && number !=0) { printf("\n%d is an Even number", number); } else if (number == 0) { ...
C
//! @file main.c //! @brief Main logic for 7-Min //! //! File contains all logic for 7-Min Workout Pebble application. //! The program runs much like a timer, simply logging the start time, offsetting it each time //! it is paused or resumed, and then calculating all figure states based off the difference //! between t...
C
#include<stdio.h> #define SIZE 10 #define PAR 72 int main() { int index, score[SIZE]; int sum = 0; float ave; printf("enter %d golf scores:\n",SIZE); for(index = 0; index < SIZE; index++) { scanf("%d",&score[index]); } for(index = 0; index < SIZE; index++) { printf("%5d ",score[index]); } printf("\n...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* set_level.c :+: :+: :+...
C
#include <stdio.h> int main() { int id; printf("\nBefore forking\n"); id=fork(); if(id!=0) { printf("\nParent process is running \n parent process id is %d\n parent's parent id is (i.e bash id) %d \n",getpid(),getppid()); sleep(1); printf("Parent process terminated\n"); exit(0); } else { printf("Child...
C
/***************************************************************************** * Name: split2.c * * Summary: Extract substrings from a delimited string. Improves on split.c * because you don't need to know how many delimiters your string * should have. * * Created: Tue 06 Aug 20...
C
#ifndef DYNSTACK_H_ #define DYNSTACK_H_ #include <stdlib.h> #include <assert.h> #include "pj_inline.h" /* A simple, geometrically growing stack implementation using * void * as value type. All API functions are static, many inline. */ /* If set in the flags, this will cause remaining elements * on the stack to be...
C
// recat.c - create pipe using popen() and pclose() #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <limits.h> #include <fcntl.h> #define BUFSZ PIPE_BUF int main() { FILE * fp; char * cmd = "cat file1"; char buf[BUFSZ]; if ((fp = popen(cmd, "r")) == NULL) { perror("fail to po...
C
#include <stdio.h> #include <stdlib.h> #define STRINGSIZE 1024 void printarray(char** array, int n) { for (int i = 0; i < n; ++i) printf("[%d]: %s\n", i+1, array[i]); } void array_add(char** array, int n) { array[n] = malloc(STRINGSIZE*sizeof(char)); scanf("%s", array[n]); } void array_rem(char** array, int n) ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* printf_copy.c :+: :+: :+: ...
C
#include<stdio.h> #include<stdlib.h> #include<malloc.h> /*Structure representing nodes of linked list forming the team. */ struct Node { float run; struct Node *next; }; /*Function to create a node of a linked list*/ void create_node(int x,struct Node **temp) { struct Node *r, *z; z =...
C
/* ** EPITECH PROJECT, 2020 ** cpp_d01_2019 ** File description: ** Ex01 */ #include "menger.h" bool string_isdigit(char* str) { for (int i = 0; str[i]; ++i) { if (!isdigit(str[i]) && str[i] != '-') return (false); } return (true); } bool has_error(int ac, char** av) { if (ac != 3...
C
/* SSE# bit mask jump LUT generator Author : Dimitris Vlachos (DimitrisV22@gmail.com) */ #include <stdio.h> #include <string.h> #include <stdint.h> void emit_text(FILE* f,const char* t) { fwrite((const void*)t,1,strlen(t),f); } void generate_eq(FILE* f,const char* field) { uint32_t i; uint32_t j; emit_tex...
C
//Է 1òִprintcoutֱۿг 2ִлöϵִг򣻲鿴ϵ㴦ֵԤֵȽϣظ˹ /*ʶ *constȫд *ࣺշHumanBoy *СշgetName *ֲСշ */ /*C&C++ ʹò裺 -> 壨ڴ棩-> á *C&C++ ⣺ *Կ֣Ͷ壬ݶ *Ͷ岻ڴģĶ壬ṹĶ壬ǶһͶ *ݶڴ棬壬ͱ壨ָ룬ָָڴַûб޷ݵģ *һԭ *ڴģͷļ *ڴķcppļֹظ */ /*ԶתʽתtmǸӵ *1ͬͣԭͣ int / intСʱԶתΪ int ɾȽͣ * c = (double)(2/3) c = 0.000 c = ((double)2/3) c = 0.6666 ˵ ʽת ǿת *...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> // ó⸦ #define CUTOFF 70 void getNumber(int *pNum) { printf("input your number! : "); int num; scanf_s("%d", &num, sizeof(num)); *pNum = num; } void printNumber(const int *pNum) { printf("your number is %d. \n", *pNum); } void getName(char *pszName,...
C
#include <dirent.h> #include <stdio.h> #include <fcntl.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <time.h> #include <errno.h> #include <pwd.h> void mkdirPamUsb(){ struct stat st = {0};//0 diretorio inexiste, -1 existente if (stat("/etc/p...
C
#include "holberton.h" /** * _puts - prints a string followed by a new line * * @str: char to check * Description: This will print a string with a new line to stdout * * Return: 0 is success */ void _puts(char *str) { int string; for (string = 0; *(str + string) != '\0'; string++) _putchar(*(str + string));...
C
#include<stdio.h> int main(void){ FILE *file; file = fopen("test2.txt","w"); fprintf(file,"Hello World 2019"); fclose(file); return 0; } /* INFOMATION */ /* ◆このプログラムの動作 文字が書かれた test2.txtというファイルを生成する。 ◆ファイル型ポイント変数のモード一覧 ・r 読み込み(ファイルが存在しない場合は失敗となる) ・r+ 読み書き(ファイルが存在しない場合は失敗となる) ・w 書き込...
C
/*һƳַһȽȳÿڵһַĵַ Ȼʾеַ óַࣨһֽڵĴ洢ռ䣩شŵһ̬ͨ洢䴴ַУ ͨprintfʾóַ 룺һַ# ĽԻзַĽ(Իз)֮һи ע⣺ϸʹͶ̬ڴ䣬 δɡ Hello! How are you!# Hello! How are you! Hello! How are you! */ //#include<iostream> #include<stdio.h> #include<math.h> #include<stdlib.h> #include<string.h> //#include<algorithm> //using namespace std; struct Node { char c; struct...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "setup.h" #include "globals.h" void clr(char** walls, int size) { // clears board and wall placements int i, j; for (i=0;i<size;i++) { for (j=0;j<size;j++) { walls[i][j]=' '; white.pathing[i][j]=-1; black.pathing[i][j]=-1; } } white....
C
#include <stdio.h> #include <stdlib.h> #define QUEUE_MAX 100 #define STACK_MAX 100 #define N 8 int graph[N][N] = { {0, 1, 1, 1, 0, 0, 0, 0}, {1, 0, 0, 0, 1, 1, 0, 0}, {1, 0, 0, 0, 0, 0, 0, 0}, {1, 0, 0, 0, 0, 0, 0 ,0}, {0, 1, 0, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0, 1, 1}, {0, 0, 0, 0, 0, 1, 0, 0}, {0, 0, 0, 0, 0, 1, 0, 0...
C
/* Relation operator: All operators here will return true(1) or false(0) *** 1 or 0 *** */ #include<stdio.h> int main() { int a = 5,b = 6,c = 7; int d; d = a<b<c; printf("%d/n",d); return 0; }
C
// The number of prepositions 'in' is displayed on the screen. #include <stdio.h> #include <ctype.h> int main() { int ch, state, count; state = 0; count = 0; printf("Enter a sentence.\n"); for (ch = getchar(); ch != '\n'; ch = getchar()) { switch (state) { case 0: // state 0 : wait state if...
C
/** ****************************************************************************** * @file MotorDriver.c * @author Basile Dufay * @version V1.0.0 * @date 18-Sept-2017 * @brief This file provides a set of firmware functions to manage: * + Sparkfun ROB-09457 dual Motor Bridge based ...
C
struct B{ int z[3]; }; struct A{ int x; struct B y; }; int main(){ struct B b; struct A a; a.y = b; a.y.z[1] = 2; return a.y.z[1]; }
C
#define maxn 10 typedef int STACK; STACK stack1[maxn]; STACK stack2[maxn]; int top1; int top2; int count; void toStation() { stack2[--top2]; } void RtoReady() { int temp; temp=stack1[--top1]; stack2[top2++]=temp; } void toStart() { int temp; temp=stack2[--top2]; stack1[top1++]=t...
C
#include "cryptbaselib.h" FILE *open_file(const char *name) { FILE *f; if ((f = fopen(name, "rb")) == NULL) { printf("Не удалось открыть файл\n"); exit(201); } return f; } int close_file(FILE *name) { fclose(name); return 0; } long long mod(long long x, long long p) { int result = x % p; int l ...
C
#include <stdio.h> #include <stdlib.h> #include "holberton.h" /** * get_bit - function that returns the value of a bit at a given index * @n: int * @index: index int * Return: the value of the bit at index index or -1 if an error occured */ int get_bit(unsigned long int n, unsigned int index) { unsigned int i; ...
C
// PARAM: --set ana.activated[+] 'maylocks' --set ana.activated[+] 'pthreadMutexType' #include<pthread.h> #include<stdio.h> #include<unistd.h> #include <assert.h> #include <stdlib.h> pthread_mutex_t mut[8]; void* f1(void* ptr) { int top; int x = 2; if(top) { x = 3; } pthread_mutex_lock(&m...
C
/** * @src/multiplier.h */ #include <GFraMe/GFraMe_error.h> #include <GFraMe/GFraMe_object.h> #include <GFraMe/GFraMe_tilemap.h> #include "global.h" #include "player.h" #include "multiplier.h" /** * Tilemap used to display the multiplier */ static GFraMe_tilemap tm_multi; /** * Current data used by the multiplier...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* flag_handler.c :+: :+: :+: ...
C
#include <stdlib.h> #include <string.h> #include <unistd.h> #include <stddef.h> #include <fcntl.h> const char* usage1 = "Usage: ./gen <minlen> <maxlen>\n"; const char* usage2 = "Lower bound is bigger than upper bound\n"; int main(int argc, char** argv) { if (argc != 3) { write(2, usage1, strlen(usage1...
C
#include <stdio.h> #include <stddef.h> #include <string.h> #include <stdlib.h> #include <assert.h> /* An implementation of regex evaluation based on Thompson's NFA algorithm */ struct listnode { struct listnode *prev; struct listnode *next; }; #define node_to_item(node, container, member) \ (container *...
C
/** * @file inputlog.c * @author Vivek Kumar Yadav SFID:256217 * @brief to display the user inputs opted for the washing-process * @version 0.1 * @date 2021-04-10 * * @copyright Copyright (c) 2021 * */ # include "wmcs.h" void inputlog() { printf("\n********************((The Machine is Ready t...
C
/* * Copyright 2008 Freescale Semiconductor, Inc. * Copyright 2013 Wolfgang Denk <wd@denx.de> * * SPDX-License-Identifier: GPL-2.0+ */ /* * This file provides a shell like 'expr' function to return. */ #include <common.h> #include <config.h> #include <command.h> static ulong get_arg(char *s, int w) { ulong *...
C
#include <stdio.h> #include <stdlib.h> int main() { int i=10; loopwwe: // goto ȵ { int hah; //Ի᲻ض ŵڲ //a label can only be part of a statement and a declaration is not a statement printf("poop棡\n"); } int hah; //swith loop 治ҪֱӸ ǸһǿԵ if...
C
/* * user_interface.c * * Created on: 14/10/2019 * Author: gastonvallasciani */ /*=========================[inclusiones]============================================*/ #include "user_interface.h" #include "sapi.h" #include "stdint.h" #include "stdlib.h" #include "audioProcessor.h" /*=========================[...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> typedef enum{matrix,header,entry}tagfield; typedef struct matrixnode *matrixpointer; typedef struct entrynode { int row; int col; int value; }E; struct matrixnode { matrixpointer down; matrixpointer right; tagfield tag; union { matrixpointer next;...
C
#include "imagem.h" Imagem alocarImagem(Imagem referencia) { Imagem img; int i, j; img.h = referencia.h; img.w = referencia.w; img.numCanais = referencia.numCanais; img.m = malloc(sizeof(guchar **)*img.h); for(i = 0; i < img.h; i++) { img.m[i] = malloc(sizeof(guchar *)*img.w); for(j = 0; j < img.w; j++) ...
C
/* SFont: a simple font-library that uses special .pngs as fonts Copyright (C) 2003 Karl Bartel License: GPL or LGPL (at your choice) WWW: http://www.linux-games.com/sfont/ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as...
C
#include "../../General/general.h" #define STACKTYPE "Linked" /* Stack -> Implement Reverse Polish calculation */ typedef enum bool{false,true} bool; typedef struct dataframe { double i; struct dataframe* next; } dataframe; typedef struct stack { dataframe* start; int size; } stack; /* Create an em...
C
#include<stdio.h> extern int(*Q)[10]; extern int gs,bs;//ڼ //ͼ int output(void) { int I, J; printf("%d %d\n",gs,bs); for (I = 0; I<10; I++) { for (J = 0; J < 10; J++) { switch (*(*(Q+I)+J)) { case 0:printf(" "); break; case 1:printf(""); break; case 2:printf(""); break; ...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include "common.h" #include "tree.h" #include <assert.h> extern char* strdup(const char*); //behålla denna? //_____________ // typdefs //_____________ typedef struct node { elem_t elem; tree_key_t key; struct node* left; struct node* right; } n...
C
#include "hardware.h" #include "door.h" #include <stdlib.h> #include <stdio.h> #include <time.h> #define DOOR_OPEN_INTERVAL 3 int is_door_open = 0; /* time_t door_time_opened_pointer; time_t *init_time = NULL; door_time_opened_pointer = time(init_time); */ // Open = 1, closed = 0 /* typedef struct {int *is_d...
C
#include "userprog/syscall.h" #include <stdio.h> #include <syscall-nr.h> #include <string.h> #include "threads/interrupt.h" #include "threads/thread.h" #include "threads/vaddr.h" #include "devices/shutdown.h" #include "devices/input.h" #include "filesys/filesys.h" #include "filesys/file.h" #include "userprog/pagedir.h"...
C
#import "bootstrap.h" #import <mach.h> #import <stdarg.h> #import <stdio.h> #import <sys/boolean.h> #define NELEM(x) (sizeof(x)/sizeof(x[0])) #define LAST_ELEMENT(x) ((x)[NELEM(x)-1]) print(const char *format, ...) { va_list ap; va_start(ap, format); vfprintf(stderr, format, ap); fprintf(stderr, "\n"); va_end...
C
/* Talha Uçar 171418008 Hafta2 - Odev2 */ #include <stdio.h> #include <stdlib.h> #include <inttypes.h> #include "GetPrime.h" int main(int argc, char **argv) { printf("5. Prime: %" PRIu64 "\n", GetPrime(5)); printf("60. Prime: %" PRIu64 "\n", GetPrime(60)); printf("98. Prime: %" PRIu64 "\n", GetPrime(98)...
C
/* Q: WAP to find greatest among 3 nos Q: Factorial Q: Sum of digits and reverse it (341 -> 143) */ #include<stdio.h> main(){ int n, sum = 0; printf("Enter the number: "); scanf("%d", &n); printf("Reverse of %d is: ", n); while(n > 0){ printf("%d", n%10); sum += n%10; n /= 10; } printf("\nSum of digits a...
C
#include<stdio.h> #include<time.h> /////////////////////////// void swap(int *x,int *y) { int temp; temp = *x; *x = *y; *y =temp; } //////////////////////////// int partition(int A[],int low,int high) { int i,j,pivot; pivot = A[high]; i=low-1; for(j=low;j<=high-1;j++) { if(A[j]<=pivot) { i++; swap(&A[i],&A[j]); } } swa...
C
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* * File: main.c * Author: jmpram * * Created on 6 de octubre de 2019, 17:58 */ #include <stdio.h> #include <stdlib.h> /* ...
C
/****************************************************************/ /*Nicolas Ambal-Theo GODARD 2020*/ /*--------------------------------------------------------------*/ /* liste_chainne.c */ /* Fonction pour la liste chainee des empru...
C
/************************************************************************* > File Name: shm_writer_reader.c > Author: liujizhou > Mail: jizhouyou@126.com > Created Time: Wed 02 Mar 2016 08:37:51 PM CST ************************************************************************/ #include<unistd.h> #include <sys/types...
C
/* * Copyright (C) 2013 Sonu Abraham * Copyright (C) 2013 Tech Training Engineers * * The source code in this file can be freely used, adapted, * and redistributed in source or binary form, so long as an * acknowledgment appears in derived source files. * */ /* * DMA Memory Allocation (new API solution) * * W...
C
#include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> int main() { unsigned char uc1, uc2, uc3; signed char sc1, sc2, sc3; unsigned short ui1, ui2, ui3; signed short si1, si2, si3; printf("\n Taille de char : %lu octets \n\n",sizeof(char)); uc1 = 200 ; uc2 = 60 ; uc3 = uc1 +...
C
"""Método iterativo de Gauss Jacobi para resolução de Sistemas lineares Desenvolvedor: Luiz Carlos da S.F. Junior """ ordem = int(input("Digite a ordem do sistema: ")) solucao = [] #solução do sistema(irá armazenar o resultado da iteração k) solucao_aux = [] #solução anterior do sistema(irá armazenar o resultado da...
C
#include<stdio.h> int main() { int n,max=0,i,p,r,z; printf("enter any number\n"); scanf("%d",&n); for(i=1;n!=0;i++){ r=n%10; if(r>max) z=r; n=n/10; p=n%10; r=p; if(z>p) z=p; } printf("%d",z); }
C
#include "fillit.h" void print_list(t_piece *cursor) { if (cursor == NULL) ft_putendl("Error: Cursor is NULL."); else { ft_putnbr(cursor->x[0]); ft_putendl(""); ft_putnbr(cursor->x[1]); ft_putendl(""); ft_putnbr(cursor->x[2]); ft_putendl(""); ft_putnbr(cursor->y[0]); ft_putendl(""); ft_putnbr(c...
C
#include <stdio.h> int comp(int, int); int main(void){ int n,k; scanf("%d%d",&n,&k); if(n>=k){ printf("%d\n",comp(n,k)); }else{ printf("n must greater than k."); } return 0; } int comp(int n, int k){ if(n==k || k==0){ return 1; }else { return comp(n-1,k...
C
#include <string.h> #include <stdlib.h> #include <stdio.h> #include <assert.h> #include <time.h> struct node{ int data; struct node* next; }; //Prints list void list_print(struct node** head); //builds a list with 10 random values void build_rand_list(struct node** head, int size); //Insert at the top -> {1...
C
#include <stdio.h> int CRCTABLE[256]; void initCRCTable() { int currentCRC = 0, v3 = 0, counter = 0; while ( 1 ) { counter = 8; currentCRC = v3 << 24; do { while ( currentCRC >= 0 ) { currentCRC *= 2; if ( !--counter ) goto LABEL_6; } currentCRC...
C
#define maxchars 40 //(hopefully) enought space for comments ;) int load_car_data (const char *filename, car_struct *carp) { printf ("\n> \"load_car_data\" will load the car settings from \"%s\"\n", filename); char string[maxchars]; FILE *lstp = fopen (filename, "r"); if (!lstp) { printf("file doesn't exist!...
C
#include <LPC214X.H> #include "lcd.h" #include "uart.h" main() { VPBDIV=0X02; //set the clock speed for 30 mhz PINSEL0=0X00000005; //selecting uart o port pins IODIR1 |= 0X003F0000; //calling direction for lcd pins uartini(); //calling uart inilization function delay(5...
C
#include <postgres.h> #include <miscadmin.h> #include <libpq/password.h> #include <libpq/libpq.h> #include <storage/fd.h> #include <string.h> #include <unistd.h> #ifdef HAVE_CRYPT_H #include <crypt.h> #endif int verify_password(char *auth_arg, char *user, char *password) { char *pw_file_fullname; FILE *pw_file...
C
#include <stdio.h> int main() { char string[6]; while(gets(string) != NULL) { printf("%s\n", string); } return 0; }
C
#include "mesh.h" static int is_blank_line(const char *s) { for (; *s != '\0'; s++) { if (!isspace(*s)) { return 0; } } return 1; } static int line_num = 0; static int get_line(char buf[], const int bufsize, FILE *file) { line_num++; return (fgets(buf, bufsize, file) != NULL) && (!((buf[0] == '#') || i...
C
#include "binary_trees.h" /** * binary_tree_is_perfect - checks if a binary tree is perfect. * @tree: pointer to the root node of the tree to check. * Return: 1 if binary tree is perfect, 0 otherwise. */ int binary_tree_is_perfect(const binary_tree_t *tree) { size_t depth = 0; if (!tree) return (0); depth = ...
C
#ifndef _H_COMMON_MACROS #define _H_COMMON_MACROS // Define pre-processor flag values TRUE and FALSE. #define _T 1 // TRUE #define _F 0 // FALSE /* Processor Clock Frequency 1. If F_CPU is already defined by an ATmega header, the preprocessor issues a warning. 2. F_CPU depends on the CKDIV8 f...
C
/*number left rotation input: 7867 output: 7786 6778 8677 7867 */ #include<stdio.h> #include<math.h> int main(){ int n,count=0,w; scanf("%d",&n); int k=n,rem,div,i; while(k){ count++; k/=10; } for(i=0;i<count;i++){ rem=n%10; div=n/10; n=(pow(10,count-1))*r...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <stdbool.h> #include "sha256.h" bool passed = true; unsigned char* key = "\xe5\xaf\x6e\xb2\x2b\xce\x17\xb2\x7f\xd5\x5e\xd3\x2d\x72\xc6\xd4\xe1\xa7\x9c\x7e\x9c\x83\x91\x4a\xcf\x8f\x33\xf5\x12\xae\x69\x07"; const int CHALLENGE_SIZE ...
C
/** * Krishna Thiyagarajan * Scheduler * scheduler.c * 12/25/2016 */ #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> #include <signal.h> #include <sys/time.h> #include <sys/mman.h> #include <limits.h> #include <stdarg.h> #include "scheduler.h" #include "adjstack.c" #define STACKLEN ...
C
#pragma once #include "utils.h" struct cfl_list_node { struct cfl_list_node *next; struct cfl_list_node *prev; }; struct cfl_list { struct cfl_list_node head; }; #define cfl_list_foreach(node, list) \ for(node = (list)->head.next; node != &((list)->head); node = node->next) /* * List based API *...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include "LRC.h" #include "../base16/base16.h" void showHelp() { printf("usage: LRC hex xxxx\n"); printf(" LRC str xxxx\n"); exit(1); } int main(int argc, char *argv[]) { if (argc == 3) { if (strcmp("hex", argv...
C
/* Um programa simples de lista postal que ilustra o uso e a manutenao de listas duplamente encadeadas. */ #include <stdio.h> #include <stdlib.h> #include <string.h> struct address { char name[30]; char street[40]; char city[20]; char state[3]; char zip[10]; /* guarda ceps dos EUA e Canad */ ...
C
#include <stdio.h> int main() { int n, m, i, j, flag; printf("Enter lower bound "); scanf("%d", &n); printf("Enter upper bound "); scanf("%d", &m); printf("\nPrime numbers between %d and %d are " ,n,m); for (i = n; i <= m; i++) { if (i == 1 || i == 0) continue; flag = 1; for (j = 2; j <= i / 2...
C
#include "ALL.h" Node *Create_new_23_node() { Node *temp = (Node*)malloc(sizeof(Node)); temp->Link[0] = NULL; temp->Link[1] = NULL; temp->Link[2] = NULL; temp->nData.Left = 0;//Left temp->nData.Right = 0;//Right ū return temp; } //忡 ִ Ȯϴ Լ int Count_node_data(Node *target_node) { if (target_node->nData...
C
#include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/stat.h> #include<unistd.h> #include <netinet/in.h> #include <netdb.h> #include <stdlib.h> void error(char *msg) { perror(msg); exit(0); } int main(int argc, char *argv[]) { int sockfd, portno,lngth,len,cid[1]; struct soc...
C
/* Program to make all rows and columns of a cell 0 if it's 0 in a given 2D array. The 3 X 4 matrix (2D array - row value as 3 and column value as 4) will be given as an input. Need to make all rows and columns of a cell 0 if any of its corresponding row value or column value is zero. For example, Input: 1 1 1 1 1 0 1 ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strtrim.c :+: :+: :+: ...