language large_stringclasses 1
value | text stringlengths 9 2.95M |
|---|---|
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* craft_piece.c :+: :+: :+: ... |
C | int solution(int a[], int n){
int i,min = 0,minTemp = 0,total = 0;
int sum1 = 0,sum2 = 0;
for (i = 0; i < n; i++){
total = a[i]+total;
}
for (i = 0; i < n-1; i++){
sum1 = a[i]+sum1;
sum2 = total - sum1;
minTemp = (sum1 - sum2) < 0 ? (sum1 - sum2)*(-... |
C | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<sys/types.h>
#include<sys/stat.h>
FILE *file;
struct LinkedList {
int count;
char link_word[200];
char link_url[200];
struct LinkedList *next;
};
typedef struct LinkedList *node;
struct LinkedList *head = NULL;
node createNode() {
node temp1;... |
C | #include <stdio.h>
#include <stdlib.h>
#include "graph.h"
#include "./list/linkedlist/doublylinkedlist/dlinkedlist.h"
int WhoIsPrecede(int data1, int data2);
// 그래프의 초기화
void GraphInit(ALGraph * pg, int nv)
{
int i;
pg->adjList = (List*)malloc(sizeof(List)*nv);
pg->numV = nv;
pg->numE = 0; // 초기의 간선 수는 0개
... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define QUESTION_LENGTH 100
#define ANSWER_LENGTH 30
#define ADDITIONAL_SIGNS 2
typedef struct {
char Question[QUESTION_LENGTH];
char Answer[ANSWER_LENGTH];
}QuestionData;
int getNumberOfFileQuestions(FILE* file)
... |
C | #include <stdio_ext.h>
#include <stdlib.h>
#define LIMITE_ARRAY 3
int main()
{
/* int valorUno;
int valorDos;
int valorTres;
int valorMax;
int valorMin;
printf("\tIngrese 1er valor: ");
while (scanf("%d",&valorUno)!= 1)
{
printf("\nError al ingresar valor solicitado");
... |
C |
#include "op.h"
int power(int x, int y) //x=base, y= exponent
{
if(y == 0)
return 1;
else
return(x * power(x,y-1));
}
int fact(int n)
{
if(n==1)
return 1;
else
return (n*fact(n-1));
}
//3_7
int recursive(int x, int n)
{
int sum=0;
for(... |
C | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
//
#include <GL/glut.h>
#include <math.h>
#include <stdio.h>
//
#include "mpi.h"
//rather than passing arrays back and forth, just pass the array of colors back, you know everything else as long as you know what column number you're on
#include <sys/time.h>
#i... |
C | #include "SPMiniMaxNode.h"
int spMiniMaxNodeEvaluate(SPFiarGame* board, unsigned int depth, unsigned int maxDepth, bool sign){
// sign is True -> return max score (find best move for 1st player)
SPFiarGame* tempBoard;
int choice = 0;
int score = 0;
int bestScore = sign ? INT_MIN : INT_MAX;
for(int i = 0; i < SP... |
C | #include <Vk2D/Vk2d.h>
#ifdef _DEBUG
static int debug = 1;
#else
static int debug = 0;
#endif
int main()
{
// Initialises Vk2D
vk2d_init(vk2d_init_everything);
// Creates a window with the given width, height, and title
vk2d_window* window = vk2d_create_window(1280, 720, "Hello, Vk2D!");
// Creat... |
C | // Author : Varun Rathi
// Github : https://github.com/varunrathi28/Hacker-Earth
// Problem : Monk and Rotation
// Link : https://www.hackerearth.com/practice/data-structures/arrays/1-d/practice-problems/algorithm/monk-and-rotation-3/
#include <stdio.h>
void scan_int(int *x){
register int c=getchar_unlocked();
... |
C | /*===========================================================================
* FILENAME : A/D {A2D.C}
* PURPOSE : A/D driver module
* DATE CREATED : 11/07/2002
* PROGRAMMER : Nir Sade
*===========================================================================*/
#include <string.h... |
C | /* --------------------------------------------------------------------------
* ROMBuild - Written by Logiqx (http://www.logiqx.com/)
*
* A simple little utility for re-building ROMs
* -------------------------------------------------------------------------- */
/* --- Version information --- */
#define R... |
C | /**
* @file stm32f1_rcc.c
* @brief Driver for Reset & Clock Control module of STM32F103
* @author Visakhan
* @date June 8, 2017
*/
#include "stm32f1_rcc.h"
#include "system_stm32f1xx.h"
void RCC_HSE_OscInit(bool prediv)
{
/* Turn on HSE clock */
__HAL_RCC_HSE_CONFIG(RCC_HSE_ON);
/* Wait until HSE clock read... |
C | #include "lists.h"
/**
* get_dnodeint_at_index - Function that returns a node
* indicated by a given index
* @head: The head node
* @index: index that identifies the node
*
* Return: Node found by the index
*/
dlistint_t *get_dnodeint_at_index(dlistint_t *head, unsigned int index)
{
unsigned int i;
if (!head)... |
C | #include <stdio.h>
#include <malloc.h>
//ֵɸı
const int* function()
{
static int count = 0; //̬
count++;
return &count; //countĵַ
}
int main()
{
int i = 0;
const int *p = function(); //constεıܽյconstֵ
printf("%d\n",*p);
printf("%d\n",i);
return 0;
} |
C | //****************************************************************************
// @Module Arduino-compatible clock implementation.
// @Filename wiring_clock.c
// @Project Arduino_XMC
//----------------------------------------------------------------------------
// @Controller Infineon XMC1x00
... |
C | #include <stdio.h>
#include <bsd/string.h>
unsigned int ft_strlcat(char *dest, char *src, unsigned int size);
int main(void)
{
char src1[] = "world";
char dest1[] = "Hello";
char src2[] = "world";
char dest2[] = "Hello";
char src3[] = "world";
char dest3[] = "Hello";
char src4[] = "world";
char dest4[] = "Hel... |
C | #ifndef ELVM_LIBC_RAW_PRINT_H_
#define ELVM_LIBC_RAW_PRINT_H_
#include "_builtin.h"
int putchar(int c);
static void print_str(const char* p) {
for (; *p; p++)
putchar(*p);
}
static char* stringify_int(long v, char* p) {
*p = '\0';
do {
--p;
*p = v % 10 + '0';
v /= 10;
} while (v);
return p... |
C | #include <stdio.h>
#include <conio.h>
int main()
{
float km;
printf("Enter the Distence in KM :");
scanf("%f",&km);
double nanom =1000000000000.0*km;
double microm=1000000000.0*km;
double mim=1000000.0*km;
float cm =100000.0*km;
float dm =10000.0*km;
float m ... |
C | #include <math.h>
#include <stdio.h>
int ncount(long n) { //Функция подсчитывает количество цифр в числе
int count = 0; //счетчик цифр
while (n > 0) { //пока в числе есть цифры
n = n / 10; //убираем последнюю цифру (берем целую часть от деления на 10)
count++; //увеличиваем счетчик
}
ret... |
C | #include "12.9.2.h"
#include <stdio.h>
static int mode;
static int dis;
static float fuel;
void set_mode(int mo)
{
if (mo != 0 && mo != 1)
{
printf("Invalid mode specified. ");
if (mode == 1)
printf("Mode 1(US) used\n");
else
printf("Mode 0(metric) used\n");
... |
C | #include <stdio.h>
#include <stdlib.h>
typedef struct node{
int data;
struct node * prev;
struct node * next;
} Node;
void add(Node ** head, Node ** tail, int data){
if(*head == NULL){
*head = (Node*)malloc(sizeof(Node));
(*head)->data = data;
(*head)->prev = NULL;
(*he... |
C | #include <stdio.h>
//Enter an integer: 25
//You entered: 25
int main(void){
int number;
printf("Enter an interger: ");
scanf("You entered:%d", &number);
} |
C | /*****************************************************
* Datei: urle.c
* Desc.: Implementiert die Lauflängencodierung
* Autor: Thomas Schmiedel
* Datum: 02.11.2010, , 5.5.2011 Strutz
******************************************************/
#include <string.h>
#include <limits.h>
#include <assert.h>
#include "urle.h"
/... |
C | #include <stdio.h>
int linear_search(int arr[], int n, int key){ //function definition
for(int i = 0; i < n; i++){ //for loop starts
if (arr[i] == key){
return i;
}
}
return 0;
}
int main()
{
int n, key, arr[20]; ... |
C | #include "userprog/syscall.h"
#include <stdio.h>
#include <syscall-nr.h>
#include "threads/interrupt.h"
#include "threads/thread.h"
#include "threads/vaddr.h"
#include "threads/init.h"
#include "userprog/pagedir.h"
#include "userprog/process.h"
#include "filesys/off_t.h"
#include <string.h>
static void syscall_handler... |
C | /*
** sunriset.c - computes Sun rise/set times, including twilights
** Written as DAYLEN.C, 1989-08-16
** Modified to SUNRISET.C, 1992-12-01
** (c) Paul Schlyter, 1989, 1992
** Released to the public domain by Paul Schlyter, December 1992
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "sunspy.h"
... |
C | /******************************************************************************
摜f[^t@C( lenna.256 )vOŎgpɂ
摜ł͉摜f[^t@Cgp܂Bȉ
悤ɋLq邱ƂŁAt@C̓ezɊi[
zɊi[ꂽf[^t@CɏނƂł܂B
******************************************************************************/
#include <stdio.h>
#include <math.h>
#define N... |
C | #include "dma.h"
void DMA_init(void)
{
DMA_InitTypeDef DMA_InitStructure; //ʹDMA1ͨ1
NVIC_InitTypeDef NVIC_InitStructure;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); //ʹDMA
/***********************************************ʼDMA1*************************************************/
DMA_DeIni... |
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>
unsigned long long MULT_unsigned(unsigned long long a, unsigned long long b)
{
if(b==0) return 0;
else
return a+MULT_unsigned(a, (b-1));
}
unsigned long long Remainder (unsigned long long dividend,unsigned long long divisor)
{
while (dividend >= divisor)
{
dividend -= divisor;
}
... |
C | //variveis globais:
//variveis de protocolo
char lido;// l o byte de inicio do protocolo
char ID[4];// armazena protocolo de identificacao
char ME[11];// armazena protocolo de envio ao ME {[M0X](IXX)}
char RE[4];// armazena protocolo de resposta
//flags
int flag;
//----------------------------------------------------... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line_utils.c :+: :+: :+: ... |
C | /*
ID: ronak.b1
LANG: C
TASK: ariprog
*/
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define i64 long long
#define uint unsigned int
#define MAX(a, b) ( a > b ? a : b )
#define MIN(a, b) ( a < b ? a : b )
int N, M, largest_bisquare;
char bisqu... |
C | //
// Created by user on 04/08/2018.
//
#include <stdio.h>
double raiseToPower(double base, double power)
{
double result=1;
int i;
for (i=1; i<=power; i++)
{
result = result * base;
}
return result;
}
double sinCalculator(double input)
{
const double BASE_C... |
C | #include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
int i,n;
double low,high;
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
scanf("%d",&n);
for(i=0;i<n;i++)
{
int count=0;
scanf("%lf%lf",&low,&high);
... |
C | #include "elevator_control.h"
int elevator_init(){
while(elevator_at_floor() == NOT_IN_FLOOR){
hardware_command_movement(HARDWARE_MOVEMENT_DOWN);
}
hardware_command_movement(HARDWARE_MOVEMENT_STOP);
for (int floor = 0; floor<HARDWARE_NUMBER_OF_FLOORS; floor++){
if (hardware_read_floor_sensor(floor)){
... |
C | #include<stdio.h>
#include<stdlib.h>
int min(int x,int y)
{
if(x>y)
return y;
else
return x;
}
void belman(int source,int cost[10][10],int dist[20],int n)
{
int i,k,j;
for(i=1;i<=n;i++)
{
if(i!=source)
dist[i]=999;
else
dist[i]=0;
}
for(k=1;k<=n;k++)
{
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
dist[j]=min(dist[j],... |
C | #ifndef SS_STRING_H
#define SS_STRING_H
#include <string.h>
/**
* This function replaces the given ``token`` in the ``input`` string.
*
* @param input The input string to replace characters in.
* @param output A buffer that will have the new string written to. Should
* be the ``size`` specified.
* @para... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "funciones.h"
#include "movie.h"
#include "utn.h"
Movie* crearPelicula(void);
void cargarArchivo(Movie* pelicula);
int main()
{
Movie* pelicula = NULL;
char seguir='s';
int opcion=0;
/*
char titulo[] = "volver al futuro";
char ge... |
C | #include <math.h>
#include <ncurses.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "gameInfo.h"
gameInfo computeHearts(gameInfo incomingInfo) {
//Computes the heart by dividing each interestPoints by 100
for (int i = 0; i < 3; i++) {
incomingInfo.hearts[i] = floor(incomingInfo.... |
C | #include<stdio.h>
struct node
{
int data;
struct node* next;
};
void insert(struct node **headref,int data)
{
struct node *temp=(struct node*)malloc(sizeof(struct node));
temp->data=data;
temp->next=*headref;
*headref=temp;
}
void print(struct node **headref)
{
struct node* temp=*headref;
while(temp!=NU... |
C | #ifndef FILA_H
#define FILA_H
#define MAX 10
typedef struct{
int valor;
}elemento;
struct nodo{
elemento chave;
struct nodo *next;
};
struct desc_fila{
struct nodo *head;
struct nodo *tail;
int tamanho;
};
struct desc_fila *init();
int enqueue(elemento *x, struct desc_fila *descritor);
int dequeue(elemento ... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
/* 堆(heap)
* 满足两个要求:
* 1. 完全二叉树
* 2. 父节点的元素大于(或小于)子节点的元素
*/
typedef struct _heap {
int *heap; //堆
int n; //堆的大小
int count; //堆目前的元素
} heap;
// 交换数组的元素arr[idx1]和arr[idx2]
void swap(int *arr, int idx1, int idx2)
{
int tmp = arr... |
C | /*
* @Author: shuqiang
* @Date: 2020-08-10 20:39:13
* @Last Modified by: Administrator
* @Last Modified time: 2020-08-11 23:09:00
*/
/**
* 问题:
* N个人围成一圈,第一个人从1开始报数,报M的将被杀掉,下一个人接着从1开始报。如此反复,最后剩下一个,求最后的胜利者。
*
* 思路:
* 1. 循环列表完成,每次被“杀掉的人”,其节点被删除,时间复杂度 O(mn)
* 2. 公式法
* 因此我们可以推出递推公式f(8,3) = [f(7, 3) + 3] \% 8f(8,... |
C | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <pthread.h>
#include <unistd.h>
#include <stdbool.h>
typedef struct state {
int *resource;
int *available;
int **max;
int **allocation;
int **need;
} State;
int **allocate_double_matrix(int m, int n);
bool is_safe(State *state);
// Global ... |
C | #include <stdio.h>
#include <stdint.h>
int main() {
uint8_t ad = 6;
uint8_t x = 0;
// print the numbers till ad from 0
while (x <= ad)
{
printf("%d\n", x);
x++;
}
printf("\n\n");
x = 0;
do
{
printf("%d\n", x);
x++;
}while(x <= ad);
printf("\n\n");... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Programa que gerencia um cadastro de pessoas
#define MAXIMOPESSOAS 5
struct Pessoa {
char nome[30], telefone[20], email[70];
};
struct Pessoa dados[MAXIMOPESSOAS];
int menu() {
int op = 0, c = 0;
system("cls");
printf("--- Menu Principal ---\n\n"... |
C | #include<stdio.h>
#include<string.h>
#include<pthread.h>
#include<stdlib.h>
#include<unistd.h>
pthread_mutex_t mutex;
void *tfn(void *arg)
{
srand(time(NULL));
while(1)
{
pthread_mutex_lock(&mutex);
printf("hello");
sleep(rand()%3);
printf("world\n");
pthread_mutex_... |
C | #include <stdio.h>
#define MAX_VALUE 10001
int n, m;
int a[MAX_VALUE];
int main()
{
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
// 값을 입력하면 해당 값 인덱스의 배열값이 1씩 늘어남
// 인덱스 1의 배열값이 3이라면, 정렬시에 1을 3번 출력하면 되는 것
scanf("%d", &m);
a[m]++;
}
// 인덱스에 있는 배열 값만큼 인덱스를 출력하면 됨.
... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
typedef char const* (*char_function)();
typedef struct
{
char_function* functions;
} Animal;
typedef Animal* (*animal_function)(char const*);
typedef Animal (*animal_function2)(char const*);
const char* str_concatenate(... |
C | #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <errno.h>
#include <mqueue.h>
int N,B,P,C;
int EMPTY_QUEUE = -1;
struct timeval time_val;
mqd_t may_produce;
mqd_t may_consume;
c... |
C | #pragma once
// йȣ ϳ о Լ
//ϸ 1, ϸ 0 ȯ
//0 ȯϸ Ŀ ó ư
int readFile(char str[]);//str : йȣ
//ڷ ϴ йȣ Լ
void saveNumberCnt(int ary[]);
//ĺ ϴ йȣ Լ
int returnAlphaCnt();
|
C | #include <stdio.h>
#include <string.h>
#include <unistd.h>
int
main() {
int p[2];
pid_t pid;
char buf[128];
memset(buf, 0, sizeof(buf));
if (pipe(p) != 0) {
perror("pipe");
return 1;
}
pid = fork();
if (pid < 0) {
perror("fork");
return 1;
}
i... |
C | #include<stdio.h>
#include<math.h>
int main()
{
float a,b,c,r;
printf ("Enter the value of a,b and c");
scanf ("%f%f%f", &a,&b,&c);
printf ("the equation of circle is x^2 +y^2 +%fx +%fy +%f", a,b,c);
printf ("\nradius = %f", sqrt((a/2*a/2)+(b/2*b/2)-c));
printf ("\nvertices of radius are (%f,%f)", -a/2,-b/2);
... |
C | /*
** EPITECH PROJECT, 2020
** test_my_printf_part_four.c
** File description:
** test_my_printf_part_four.c
*/
#include <criterion/criterion.h>
#include <criterion/redirect.h>
#include "my_printf.h"
Test(my_printf_char, basic, .init = cr_redirect_stdout)
{
my_printf("%c", 'X');
cr_assert_stdout_eq_str("X");
... |
C | #include <stdio.h>
int min(int x1, int x2){
if(x1>x2) return x2;
else return x1;
}
int main(void){
int a,b;
scanf("%d %d",&a,&b);
printf("%d", min(a,b));
}
|
C | // euler23.c
/*
Solves problem 23 in project euler.
Problem statement:
A perfect number is a number for which the sum of its proper divisors is
exactly equal to the number. For example, the sum of the proper divisors of 28
would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number.
A number n is calle... |
C | #include "debug.h"
#include "hal.h"
static struct debug_entry {
uint32_t value;
const char * file;
int line;
uint32_t time_ms;
} _debug_log[DEBUG_LOG_SIZE];
static size_t _debug_log_count = 0;
void debug_log(uint32_t value, const char * file, int line) {
memmove(&_debug_log[1], &_debug_log[0], si... |
C | #pragma once
#include <stddef.h>
#define STATIC_POOL_TYPE(type, size, ...) struct __VA_ARGS__ { \
type stk[size], *sp; \
}
#define pool_init(pool) ((pool)->sp = (pool)->stk)
#define pool_sizeof(pool) (array_sizeof((pool)->stk))
#define pool_alloc(pool) (*--(pool)->sp)
#define pool_free(pool, x) (*(pool)->sp++ = (x... |
C | #define EOL -1
typedef struct node_sorted {
int sortval;
void* data;
struct node_sorted * next;
}node_sorted_t;
node_sorted_t* sll_create();
void sll_add(node_sorted_t *head, int sortval, void* data);
int sll_remove(node_sorted_t *head, void* data);
void sll_print_process(node_sorted_t *head);
void sll_pr... |
C | /* Name: largestInt.c
* Purpose: Finds the largest and smallest Int among 4 ints
* Date implemented: 03-03-2017
*/
#include <stdio.h>
int main(void)
{
int one, two, three, four;
printf("Enter four integers: ");
scanf("%d %d %d %d", &one, &two, &three, &four);
int largest1 = three, smallest1 = four... |
C | #include<cs50.h>
#include<stdio.h>
int main (void)
{
int s;
do
{
s=get_int("Please enter desired size: ");
}
while (s<1);
for (int i =0;i<s;i++)
{
for (int j=0;j<s;j++)
{
printf("#");
}
printf("\n");
}
}
|
C | #include <stdio.h>
#define MINUS 10
int main(void)
{
double total = 100;
double icre = 0.08;
int year;
for (year = 1; total > 0; year ++) {
total += total * icre;
if (total > MINUS) {
total -= MINUS;
} else {
printf("have $%3.2f at end of %d year\n", tota... |
C | #include <stdlib.h>
#include "command_table.h"
#include "libft.h"
void del_command_tab(t_command_tab **tab)
{
size_t i;
if ((*tab)->cells != NULL)
{
i = 0;
while (i < (*tab)->len)
{
free_string_arr((*tab)->cells[i].argv);
i += 1;
}
free((*tab)->cells);
}
(*tab)->cells = NULL;
free(*tab);
*ta... |
C | #include <mpi.h>
#include <stdio.h>
#define INTERVAL 100000
int main (int argc, char **argv)
{
int size,rank;
double area,localsum, globalsum, mi;
int i;
double elapsed_time;
long start,end;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
... |
C |
#ifndef HASHTABLE_H_ /* Include guard */
#define HASHTABLE_H_
typedef struct {
char **arr;
size_t size;
} tHashtable;
bool hashtable_init(tHashtable *ht, size_t size);
bool hashtable_destroy(tHashtable *ht);
bool hashtable_set(tHashtable *ht, char *key, char *value);
bool hashtable_get(tHashtable *ht, char... |
C | #include <stdio.h>
#include <math.h>
// funcao trigonometricas
// tem que compilar na mao
// gcc b-math-1.c -o b-math-1 -lm
// cos(); // calcula o cosseno de um angulo em radianos
int main() {
int angulo = 45;
float resp = cos(angulo);
printf("O cosseno de %d é %f\n", angulo, resp);
return 0;
}
|
C | /*The program for merging and sorting two array*/
#include <stdio.h>
int main (){
int a[10], b[10], i, j, n, m, p;
//all about 1st array
printf ("\nEnter the size of 1st array :");
scanf ("%d",&n);
printf ("Enter the elements :");
for ( i = 0; i < n; i++ )
scanf ("%d",&a[i]);
//all ... |
C | // string inversion using pointer arithmetics
#include <stdio.h>
int meustrlen(char *str) {
int n = 0;
while(*(str++)!=0) n++;
return n;
}
int main(void) {
char entrada[100];
fgets(entrada, 100, stdin);
int tam = meustrlen(entrada);
entrada[--tam] = 0;
char *ptr1 = entr... |
C | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <unistd.h>
#define ALPHABETSIZE 256
int main(void)
{
int i, k, counter = 0;
double prob, entropy = 0;
unsigned char buf[99];
int fa[ALPHABETSIZE]={0};
while(i=read(0, &buf, sizeof(buf))){
for(k=0; k<i; k++){
fa[buf[k]]++; //steps... |
C | /* W. H. Bell
** A C header file containing declarations of a fortran subroutine and
** function
*/
#ifndef FORTRAN_H
#define FORTRAN_H
/* The C side of the fortran common block definition. */
typedef struct {
int intarray[2][3];
float realarray[3][2];
char somestring[50];
} forcom;
/* The memory is allocated ... |
C | #include "interface.h"
#include "internals.h"
#include "misc.h"
#include <ctype.h>
#include <stdarg.h>
#include <string.h>
#ifdef _WIN
# include <conio.h>
#else
# include <sys/ioctl.h>
#endif
bool_t m_askYN(const char* question)
{
#ifdef INTERACTIVE
char answer;
MysakLib_internals_assertInitialized();
printf("%s ... |
C | #include <stdio.h>
#include <stdlib.h>
long combn(int n, int k);
int main(void) {
printf("%ld \n", combn(100, 5) );
system ("pause");
return(0);
}
long combn(int n, int k){
long c_nk = 1; // initial value
int i; // iterator
// C(n, k) = C(n, n - k). If k > (n - k), replace k with n-k
if( k ... |
C | #include "lists.h"
/**
* insert_node- Inserts a number into a sorted singly-linked list
* @head: Pointer to head of the linked list
* @number: Number to insert
* Return: new (address of the new node) or NULL (if it failed)
*/
listint_t *insert_node(listint_t **head, int number)
{
listint_t *nod = *head, *new;
new = ... |
C | #include<stdio.h>
#include<fcntl.h>
main(){
int file1,file2,n;
char buf[100];
file1=open("1.txt",O_RDONLY);
file2=open("2.txt",O_CREAT|O_EXCL|O_WRONLY,777);
n=read(file1,buf,100);
write(file2,buf,n);
close(file1);
close(file2);
}
|
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 500000
typedef struct _NODE
{
int data;
struct _NODE *next;
}NODE;
NODE* student[MAX];
int visited[MAX];
int recursive(int index,int cnt);
void create_node(int src,int data);
int main()
{
int total, couple;
int num1, num2;
int i;
int valu... |
C | #pragma once
// parameters to go along with every module
typedef struct dt_ui_param_t
{
// TODO: make it so this maps 1:1 to binary input if any.
// TODO: this means if this is a string argument, put it to the end
// TODO: such that the zero terminated string is in the right spot after this struct
dt_token_t n... |
C | //A hack to make scanf accept multi-word string
#include<stdio.h>
int main(void){
char str[30];
printf("Enter a string:\t");
scanf("%[^\n]s",str); //%[^\n]s tells to accept the string till new line character is not input
printf("%s\n", str);
return 0;
} |
C | #include <stdio.h>
void print_line();
int main()
{
print_line();
printf("й ̸ \n");
print_line();
return 0;
}
void print_line()
{
int i;
for (i = 0; i < 50; i++)
{
printf("-");
}
printf("\n");
} |
C | /*
* CS 11 C track, Winter 2019
* Shubh Agrawal, Class of 2022
* Assignment 3
*
* sorter.c
*/
#define CAPACITY 32
#include <stdlib.h>
#include <stdio.h>
#include <string.h> /* For comparing strings */
#include <assert.h>
/* Prints the usage message.
*
* Passed Arguments:
* name: string representing the ... |
C | /*
** print_ret.c for print_ret in /home/charla_n/projects/strace/strace
**
** Made by nicolas charlas
** Login <charla_n@epitech.net>
**
** Started on Mon May 6 00:18:47 2013 nicolas charlas
** Last update Fri May 17 16:51:30 2013 nicolas charlas
*/
#include <stdio.h>
#include <sys/user.h>
#include "strace.h"
vo... |
C | #include "holberton.h"
/**
* _isalpha- checks for alphabetical chars
*
* @c: ASCII character
* Return: 1 if [A-Za-z], 0 if not
*/
int _isalpha(int c)
{
if ((c >= 'A' && c <= 'Z')
|| (c >= 'a' && c <= 'z'))
return (1);
return (0);
}
|
C | #include <stdio.h>
int main ()
{
int nilai;
for (nilai=1;nilai <= 10 ; nilai++)
{
printf("%d\n",nilai);
}
printf("Cakra Bhirawa,Universitas Brawijaya - Teknik Komputer 175150307111037");
return 0;
}
|
C | #ifndef JSON_C_PARSER_H
#define JSON_C_PARSER_H
#include <limits.h>
#include <stdbool.h>
#include <json-c/json.h>
typedef void (*json_parser_func)(struct json_object *j, void *ctx);
typedef struct {
json_parser_func f;
void *ctx;
} json_parser_cb_t;
typedef struct {
const char *name;
enum json_type type;
json... |
C | #include<avr/io.h>
#ifndef F_CPU
#define F_CPU 4000000UL // 16 MHz clock speed
#endif
#define LED PD6
#define output_low(port,pin) port &= ~(1<<pin)
#define output_high(port,pin) port |= (1<<pin)
#define set_input(portdir,pin) portdir &= ~(1<<pin)
#define set_output(portdir,pin) portdir |= (1<<pin)
void delay_ms(ui... |
C | /// @file
/// Test creation, use, and destruction of a blocked element restriction with multiple components in the lvector
/// \test Test creation, use, and destruction of a blocked element restriction with multiple components in the lvector
#include <ceed.h>
int main(int argc, char **argv) {
Ceed ceed;
CeedVector... |
C | #include <stdio.h>
/*
* Given input a number put each digit into
* array, each digit in seperate element.
* Ex: input a=987654321
* output arr[0]=1; arr[1]=2;....arr[8]=9
*/
int arr[100];
int in_array(int num, int pos)
{
int lsb, msb;
lsb = num % 10;
msb = num / 10;
arr[pos++] = lsb;
if(msb)... |
C | // gcc -Wall -o jogo main.c -lcurses -lpthread
#include <curses.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <time.h>
#include <pthread.h>
#include <semaphore.h>
#define NUM_TOKENS 5
#define EMPTY ' '
#define CURSOR_PAIR 1
#define TOKEN_PAIR 2
#define EMPTY_PAIR 3
#define LINES... |
C | #include <stdio.h>
unsigned long long factorial (int n)
{
if (n <= 0)
{
return 1;
}
return factorial (n - 1) * n;
}
int main ()
{
int n;
unsigned long long factor_n;
if (scanf ("%d", &n) != 1)
{
printf ("try again \n");
return -1;
}
else if (n < 0 )
{
printf ("input positive number \n");
return -... |
C | /*
* File: FN_COLADEESPERA.c
* Author: tobias-pc
*
* Created on 25 de noviembre de 2019, 18:33
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include "FN_COLADEESPERA.h"
#include "ESTRUCTURA.h"
#include "FN_ESTACION.h"
#include "FN_TRENES.h"
#include "FN_COMANDOS.h"
#d... |
C | /****************************************************************************\
* @brief Main function and CLI utilities
\****************************************************************************/
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include "../lib/ppm... |
C | /*
개인 공부 with C++
포인터 공부 1(기초)
*/
#include <stdio.h>
int main(){
int *HerAddress = NULL; //변수명 앞에 *을 붙이면 이것은 포인터 변수(= 즉 일종의 주소 저장소)를 선언하는 것임
int HerValue = 9503; //정수형 변수 선언(즉, 값 자체를 의미)
//HerValue의 메모리 주소를 HerAddress에 할당, & 연산자는 변수의 메모리 주소를 가져옴
HerAddress = &HerValue;
printf("Her ad... |
C | #include "../cafe.h"
int add(int a, int b) { return a + b; }
int sub(int a, int b) { return a - b; }
Cafe(main) {
Describe("Calculator") {
Describe("add()") {
It("should work with positive numbers") {
Assert(add(2, 2) == 4);
}
It("should work with negat... |
C | #include<stdio.h>
void main()
{
int pos,i,r,c=0,num;
printf("enter the number\n");
scanf("%d",&num);
for(pos=0;pos<=31;pos++)
{
r=num>>pos&1;
if(r==1)
break;
else
... |
C | #include <stdio.h>
int main()
{
int num1, num2, temp = 0;
printf("Enter first and second number: \n");
scanf("%d%d", &num1, &num2);
//swapping
temp = num1;
num1 = num2;
num2 = temp;
printf("After swapping, \nFirst number: %d \nSecond number: %d\n", num1, num2);
return 0;
} |
C | #ifndef __RING_BUFFER_H__
#define __RING_BUFFER_H__
#include "base.h"
typedef struct _ring_buffer_t {
uint8_t *buf;
uint32_t size;
uint32_t read_idx;
uint32_t write_idx;
} ring_buffer_t;
#define RING_BUFFER_CAPACITY(_rb_p_) ((_rb_p_)->size - 1)
#define RING_BUFFER_FREE_SIZE(_rb_p_) ... |
C | /*
* Copyright 2016 Purdue University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable... |
C | /*******************************************************************
> File Name: va_start.c
> Author: Larry Eppes
> Mail: larryleifeng@163.com
> Created Time: Sat 22 Apr 2017 06:47:09 PM CST
*******************************************************************/
#include<stdio.h>
#include<stdarg.h>
voi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.