language large_stringclasses 1
value | text stringlengths 9 2.95M |
|---|---|
C | #ifndef TCP_H
#define TCP_H
#include "includes/packet.h"
enum{
TRANSPORT_MAX_SIZE = PACKET_MAX_PAYLOAD_SIZE,
TRANSPORT_HEADER_SIZE = 8,
TRANSPORT_MAX_PAYLOAD_SIZE = TRANSPORT_MAX_SIZE - TRANSPORT_HEADER_SIZE,
TRANSPORT_MAX_PORT = 255
};
//Types of Packets
enum{
TRANSPORT_SYN = 0,
TRANSPORT_ACK = ... |
C | #include<stdio.h>
#include<stdlib.h>
struct node
{ int data;
struct node *next;
};
void create(struct node **head,int d)
{ struct node *new;
new=(struct node *)malloc(sizeof(struct node));
new->data=d;
new->next=NULL;
if(*head==NULL)
{ *head=new;
}
else
{ struct node *t=*head;
while(t->next!=NULL... |
C | #include <stdio.h>
int main()
{void avsco(float *,float *);
void avcour1(char (*)[10],float *);
void fali2(char course[5][10],int num[],float *pscore,float aver[4]);
void good(char course[5][10],int num[4],float *pscore,float aver[4]);
int i,j,*pnum,num[4];
float score[4][5],aver[4],*pscore,*paver;
char course[5]... |
C | typedef struct {
int top;
int limit;
int* list;
} Stack;
Stack create_stack(int limit);
void print_stack(Stack stack);
int stack_push(Stack *stack, int num);
int stack_pop(Stack *stack);
Stack create_stack(int limit)
{
Stack stack;
stack.top = 0;
stack.limit = limit;
stack.list = (int *)malloc(limit * sizeof(i... |
C | double ft_db_fibonacci(int index)
{
double pred;
double pre_floor;
if (index < 0)
return (-1);
else if (index == 0)
return (0);
else if (index == 1)
return (1);
else if (index == 2)
return (1);
else if (index == 3)
return (2);
else if (index == 4)
return (3.5);
else
{
pred = ft_db_fibonacci(ind... |
C | #include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
long int buyMaximumProducts(int n, long int k, int* a) {
// Complete this function
long int sum = 0;
long int counter = 0;
int i = 0;
while (i < n) {
int... |
C | #include<stdio.h>
int main()
{
int n,i;
float a[n],avg,sum;
printf("enter the no:");
scanf("%d",&n);
if(n<=10)
{
for(i=0;i<n;i++)
{
scanf("%f",&a[i]);
sum=sum+a[i];
}
avg=sum/n;
printf("%f",avg);
}
else
printf("error");
}
|
C | #include <stdio.h>
int main(){
int l,c,i,j,k,menor;
printf("Inf QT de Linhas: ");
scanf("%d",&l);
printf("Inf QT de Colunas: ");
scanf("%d",&c);
int m[l][c];
// Coloco os valores na matriz
for(i=0;i<l;i++){
for(j=0;j<c;j++){
printf("Inf Valor P/ L:%d C:%d : ",i,j);
scanf("%d",&m[i][j]);
}
}
// P... |
C | #include <stdio.h>
// Method 1
struct Location {
int x;
int y;
}; // <- ALWAYS remember to put a semicolon here.
int main(){
struct Location A; // also notice, when declaring, i'm writing 'struct Location', instead of just Location. if you do normal struct declaration, this is how you will be declaring va... |
C | #include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define ARRAY_LEN(ARR) (sizeof(ARR) / sizeof(*(ARR)))
/**
* Possible symbols that can be rolled.
*/
const char *const symbols[] = {"bell", "orange", "cherry", "horseshoe"};
#define NUM_SYMBOLS ARRA... |
C | #include <stdio.h>
#include <stdarg.h>
struct bogus {
int x;
char *y;
int z;
};
void
foo(char *dummy, ...) {
va_list va;
struct bogus b;
va_start(va, dummy);
b = va_arg(va, struct bogus);
printf("%d, %s, %d\n", b.x, b.y, b.z);
}
int
main() {
struct bogus b;
b.x = 123;
b.y = "hello";
b.z = 456;
foo... |
C | #include "config.h"
#include <bitcoin/varint.h>
size_t varint_size(varint_t v)
{
if (v < 0xfd)
return 1;
if (v <= 0xffff)
return 3;
if (v <= 0xffffffff)
return 5;
return 9;
}
size_t varint_put(u8 buf[VARINT_MAX_LEN], varint_t v)
{
u8 *p = buf;
if (v < 0xfd) {
*(p++) = v;
} else if (v <= 0xffff) {
(*... |
C | #include "stm32f10x.h"
#include "stm32f10x_gpio.h"
#include "stm32f10x_usart.h"
#include "motor.h"
#include "sg90.h"
#include "hcsr04.h"
#include "red.h"
#include "blue.h"
#include "delay.h"
int main(void)
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
Motor_Init(); //motorʼ
Bluetooth_Config();//óʼ
SystemI... |
C | /* Write a program in C to find the sum of the series 1!/1+2!/2+3!/3+4!/4+5!/5 using the function.*/
#include<stdio.h>
int fact(int x);
int main()
{
int sum;
sum=fact(1)/1+fact(2)/2+fact(3)/3+fact(4)/4+fact(5)/5;
printf("\nThe sum of the series is : %d\n\n",sum);
}
int fact(int n){
int num=0,f=1;... |
C | //Program menghitung rata2 nilai dg Iterasi
#include <stdio.h>
//main function
int main(void)
{
//declare variables
int counter, grade, total, average;
//inisialisasi var total & counter
total = 0;
counter = 1;
while (counter <= 10){ //loop 10x --> counter sbg nilai penjaga/sentinel value
... |
C | #include<stdio.h> /*ͷļ*/
int main()
{
printf("What a nice day!\n"); /*ַ*/
return 0; /**/
} |
C | #include <stdio.h>
#include <stdlib.h>
#include <limits.h>
int l=0;
int m,n,strt;
int dist[1000];
struct edge
{
int src,des,w;
};
struct edge *list[10000];
struct edge* createlist(int src,int des,int w)
{
struct edge*e=(struct edge*)malloc(sizeof(struct edge));
e->src=src;
e->des=des;
e->w=w;
li... |
C | #include "lpg_ecmascript_value.h"
ecmascript_value ecmascript_value_create_integer(uint64_t value)
{
ecmascript_value result;
result.type = ecmascript_value_integer;
result.integer = value;
return result;
}
ecmascript_value ecmascript_value_create_boolean(bool value)
{
ecmascript_value result;
... |
C | #include<stdio.h>
int main(){
int a, n, p;//定义变量a,n,p
int ret = 1;//定义变量ret并将其初始化为1
scanf("%d %d %d", &a, &n, &p);//输入a,n,p三个数的值
while (n)
{
if (n % 2 == 1)
{
ret = ret * a % p;
}
n = n / 2;
a = a * a % p;
}
printf("ret : %d\n", ret);
r... |
C | //Programa que impmie 10 numeros de forema descendente: DO-WHILE
#include <stdio.h>
#include <stdlib.h>
int main()
{
int contador=10;
do{
printf("%d\n",contador);
contador--;
}
while(contador>=0);
return 0;
}
/*
//Programa que impmie 10 numeros de forema descendente: WHILE
#include <stdio.h>
#include <st... |
C | #include <stdio.h>
int tak(int x, int y, int z){
if (x <= y){
return y;
}else{
return tak(tak((x - 1),y,z), tak((y - 1),z,x), tak((z - 1),x,y));
}
}
int main(void){
printf("%d\n",tak(16,15,0));
}
|
C | #include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sepol/policydb/policydb.h>
#include <sepol/policydb/services.h>
#include "context_internal.h"
#include "debug.h"
#include "context.h"
#include "handle.h"
#include "mls.h"
/* ----- Compatibility ---- */
int policydb_context_isvalid(const policydb_t ... |
C | #include<stdio.h>
int main(void)
{
int choice,i;
double price;
for(i=1;i<=5;i++)
printf("[1] select apples\n");
printf("[2] select pears\n");
printf("[3] select oranges\n");
printf("[4] select grapes\n");
printf("[0] exit\n");
printf("Enter choice:");
scanf("%d",&choic... |
C | #include <stdio.h>
#include <stdlib.h>
int main(){
int n,i,j;
int *a;
int sum=0;
scanf("%d",&n);
a=(int*)malloc(sizeof(int)*n);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(j!=i){
sum+=a[i]*10+a[j];
}
}
}
printf("%d",sum);
return 0;
}
|
C | /*
* uart.h
*
* Created: 12/27/2016 5:12:49 PM
* Author: ROHIT
*/
/*
* uart.h
*
* UART example for ATMega328P clocked at 16 MHz
*
* TODO :-
* - Implement string read function
* - Optimize for size
* - Add helper routines and compile to .a file
*
* Created on: 22-Jan-2014
* Author: Shrikant G... |
C | #ifndef NODE_H
#define NODE_H
#define MAX_STR 64
// This makes the header file work for both C and C++
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <pthread.h>
typedef struct list_node {
struct graph_node* graph_node;
struct list_node* next;
} list_node_t;
typedef struct graph_node {
... |
C | /*********************************************
*
* Proyecto: Practica 1 de SSOO2
*
* Programa: pb.c
*
* Descripcion: Copiar el modelo de examen en el directorio de un estudiante
*
* Fecha de Creacion: 27-02-2020
*
* Nombre: Paulino de la Fuente Lizcano
*
* Seguimiento: En github se puede ver el cronog... |
C | #include<stdio.h>
#include "genericll.h"
struct node *merge(struct node *left, struct node *right) {
if(left == NULL)
return right;
if(right == NULL)
return left;
struct node *head=NULL;
if(left->data <= right->data) {
head = left;
head->next = merge(left->next, right);
} else {
head = right;
head->ne... |
C | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#define N 4
#define M 5
// N行M列の行列を出力する関数
void print_matrix(char *s, int n, int m, double r[n][m]);
// 行列式の値を求める(戻り値は成功したかどうか,行列式の値はグローバル変数へ)
double det;
int cal(double p[M][N]);
// 転置(転置後の行列はグローバル変数へ)
void transposition(doub... |
C | /*
*********TMN3053/TMN4133-System Programming**********
* *
* ******************* *
* * Group Project * *
* ******************* *
* ... |
C | #include<stdio.h>
#include<stdlib.h>
int size,s[20],top=-1;
void push();
void pop();
void peek();
void traverse();
int main()
{
int n;
printf("++++STACK IMPLEMENTATION++++");
printf("\n\n Enter size of stack : ");
scanf("%d",&size);
do
{
printf("\n1. Push \n2. Pop \n3. Peek \n4. Travers... |
C | /*Errors*/
#include <stdio.h>
#include <math.h>
int main()
{
float sum=0,n,term;
int count;
printf("Enter Value of N\n->");
scanf("%f",&n);
term = (1.0)/n;
while (count <= n)
{
sum = sum + term;
count = count + 1;
}
printf("Sum = %f\n", sum);
}
|
C | /*
Description
计算两个整数a,b的和,整数范围为-1000<a,b<1000。
*/
#include<stdio.h>
int main(){
int a,b;
scanf("%d", &a);
scanf("%d", &b);
printf("%d\n",a^a^a^a^a^a^a^a^a-a-a-a-a+a+a+a+a+b^b^b^b^b-b-b-b-b+b+b+b+b);
return 0;
} |
C | /* runG.c a program that runs other programs!
* Alexandre Castro
*/
#include <unistd.h>
int main(int argc, char** args){
write(1, "Get ready!\n\n",12);
execvp(args[1], args + 1); //library wrapper for execve system call
write (1, "Ghosts\n", 17);
return 0;
} |
C | #include "Header.h"
void sig_handler(int signo)
{
if(signo == SIGUSR1)
{
puts("--------------------------------------------");
puts("부모 프로세스가 공유메모리를 모두 채웠습니다");
}
}
int main()
{
void *shared_Mem = (void*)0;
int shmid;
int *shmaddr;
pid_t my_pid, your_pid, fork_result;
int i;
FILE *fwp;
// Shared Memor... |
C |
#include "ArrayList.h"
struct arrayListStruct {
int length;
void * array;
size_t defaultSize;
};
static Boolean validateIndex(ArrayList * list, int index);
ArrayList * ArrayList_create(int initialSize, size_t objectSize)
{
if(initialSize < 1)
return NULL;
ArrayList * list = malloc(sizeof(struct arrayListS... |
C | /*
* NumberOf1Bits2.c
*
* Created on: Sep 16, 2016
* Author: xinsu
*
* Binary count: 24 arithmetic operations (bitwise shit, bitwise and, add)
*/
/*
Write a function that takes an unsigned integer and returns the number of ’1' bits it has
(also known as the Hamming weight).
For example, the 32-bit int... |
C | #include <stdio.h>
#include <string.h>
#define SIZE 32
int main(void) {
/*
char str1[10] = { 'a', 'b', 'c' };
char str2[10] = "abc";
char str3[] = "abc";
char str4[10] = "very long string";
int size = sizeof(str1) / sizeof(str1[0]);
int i;
printf("str = ");
for ( i = 0; i < size; i++)
{
printf("%c", str1... |
C | /*
** A rudimentary implementation of ping-pong timing for message passing.
*/
#include<stdio.h>
#include<stdlib.h>
#include<mpi.h>
#define proc_A 0
#define proc_B 1
#define ping 101
#define pong 101
float buffer[10001];
int processor_A (void);
int processor_B (void);
int main ( int argc, char *argv[] )
{
int ie... |
C | #include <stdio.h>
int main(int argc, char ** argv)
{
printf("int bytes: %lu\n", (sizeof (int)));
printf("float bytes: %lu\n", (sizeof (float)));
printf("doublebytes: %lu\n", (sizeof (double)));
printf("long int bytes: %lu\n", (sizeof (long int)));
printf("char bytes: %lu\n", (sizeof (char)));
printf("long bytes... |
C | /*
* Copyright (C) 2018 Brian Kubisiak <brian@kubisiak.com>
*/
#ifndef FSVM_OPS_H_
#define FSVM_OPS_H_
enum {
FSVM_DEX, /* ensure directory existence */
FSVM_DMK, /* make a new directory */
FSVM_FMK, /* make a new file */
FSVM_FMV, /* move a file */
FSVM_FRM, /* delete a file */
FSVM_LNK, /* create a symboli... |
C |
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <netinet/in.h>
#include "data.h"
#include "entry.h"
#include "tree.h"
#include "tree-private.h"
#include "serialization.h"
int data_to_buffer(struct data_t *data, char **data_buf){
if(!data || !data_buf){
return -1;
}... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BUFFER_SIZE 128
void bufferFill(FILE *, char *);
void inputBuffering(char *);
void identifiers(char *, char *);
int main(int argc, char const *argv[]){
char buffer[BUFFER_SIZE], filename[64] = "input.txt";
FILE *filePtr;
int i;
memset(buffer, 0,... |
C |
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#ifndef FRANK_TRIE_H_
#define FRANK_TRIE_H_
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*fFRANK_TRIE_DUMP_DATA)(const char *keyword, void *data, char *dump_buff, int dump_max);
typedef struct FRA... |
C | #include "libcgc.h"
#include "cgc_cgc_libc.h"
#include "cgc_cgc_malloc.h"
int read_fd = 8;
int write_fd = 8;
//char *pattern;
char pattern[1024];
char * cgc_read_buf(int fd) {
unsigned int recv_size;
unsigned int buf_size;
char *buf = NULL;
recv_size = cgc_receive_all(read_fd, (char *) &buf_size, s... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* koch.c :+: :+: :+: ... |
C | /**
\file hexfile.h
\author G. Icking-Konert
\date 2018-12-14
\version 0.2
\brief declaration of routines for HEX, S19 and table files
declaration of routines for importing and exporting Motorola S19 and Intel HEX files,
as well as plain ASCII tables.
(format descriptio... |
C | #include <stdio.h>
#include <string.h>
#include "bx_numbers.h"
#include "bx_usart.h" // For debugging
#include <avr/pgmspace.h> // For strings in flash
/* stdlib.h
Provides atoi for ascii to integer conversions.
*/
#include <stdlib.h>
/* asc2num()
Converts an ascii character representing a hexadecimal numbe... |
C | #include <stdio.h>
#include "snake.h"
int main()
{
printf("Enter the number of items: ");
scanf_s("%d", &obj.szCount);
int ekey = 0;
init();
int win = 0;
while (1)
{
if (_kbhit())
{
ekey = _getch();
_flushall();
switch (ekey)
{
case L:
if (kb_direction != RIGHT) kb_direction = LEFT;... |
C | #include <sys/types.h> // for open
#include <err.h> // for err.. duh
#include <fcntl.h> // for open flags
#include <unistd.h> // for read
#include <string.h> // for strcpy
#include "parameter.h"
#include "segment.h"
int openFile(char * filename, int flags) {
int fd = open(filename, flags);
if ( fd == -1) {
freeSe... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_split.c :+: :+: :+: ... |
C | /**
* @file ooc_template.h
* @brief Template header file
*
* Includes macros for templates
* Credits to:
* https://github.com/pfultz2/Cloak/wiki/C-Preprocessor-tricks,-tips,-and-idioms
* for preprocesser tricks
*
* @warning
* @date 8/7/2017
*/
#pragma once
#include "ooc_object.h"
#include "ooc_string.h"
#include <mat... |
C | #include "test.h"
#include "algorithm.h"
#include "encoder.h"
void enterTest(SmartCar * smartCar, uint8_t);
void segmentTest(SmartCar * smartCar);
void servoTest(SmartCar * smartCar);
void motorTest(SmartCar * smartCar);
void cameraTest(SmartCar * smartCar);
LEDData getLine(Camera * camera);
void test(SmartCar * sma... |
C | #include<stdio.h>
int i;
int** createMatrix(int r, int c){ //rows and columns
int ** m;
**m = malloc(r*sizeof(int));
for(i=0; ; i++){
*(m+1) = malloc(c*sizeof(int));
}
return m;
}
int main(){
int **matrix;
matrix = createMatrix(5,5);
for(){
}
free(matrix);
}
|
C | /* SAUVAGE Tao
19/10/11
Utils
*/
#ifndef DEF_UTILS
#define DEF_UTILS
#include <stdlib.h>
#include <stdio.h>
/* Boolean datatype */
#define TRUE 1
#define FALSE 0
typedef unsigned int Boolean;
/* Result: boolean
Data: data to test
Process: test if the data is empty (i.e NULL) */
int power(int, int);
void clea... |
C | #include <stdio.h>
#include <stdlib.h>
size_t maxSeq(int *array, size_t n);
size_t grader(int *array, size_t n, size_t correctSequence)
{
int funcAns = maxSeq(array, n);
if (correctSequence != funcAns)
{
return EXIT_FAILURE;
}
else
{
return EXIT_SUCCESS;
}
}
int main()
{
... |
C | #include <fcntl.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include <time.h>
#include <stdio.h>
#define MAX_BUF 1024
int main()
{
int fd;
char * myfifo = "/tmp/myfifo";
char buf[MAX_BUF];
/* open, read, and display the message from the FIFO */
while(1){
time_t timeBas... |
C | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
int read_line(char *line, char terminator, int maxlen) {
int c, i = 0;
while((c = getchar()) != terminator) {
if (i < maxlen) *line++ = c, i++;
}
*line = '\0';
return i;
}
struct vstring {
int len;
char *str[];
};
int c... |
C | /*
* Copyright (C) 1998, 1999, 2002, 2003, 2005 Hewlett-Packard Co
* David Mosberger-Tang <davidm@hpl.hp.com>
*
* Register stack engine related helper functions. This file may be
* used in applications, so be careful about the name-space and give
* some consideration to non-GNU C compilers (though __inline_... |
C | #include "SSSDT.h"
extern ULONG_PTR SSSDTDescriptor;
extern PDRIVER_OBJECT CurrentDriverObject;
extern PVOID SysModuleBsse;
extern ULONG_PTR ulSysModuleSize;
//SSSDTַ*4+SSSDT һ4λúƫơSSSDTõ Ӧַ
PVOID GetSSSDTFunctionAddress64(ULONG ulIndex)
{
LONG v1 = 0;
ULONG_PTR v2 = 0;
ULONG_PTR... |
C | #include <stdio.h>
void ft_swap(int *a, int *b)
{
int temp;
temp = *a;
*a = *b;
*b = temp;
}
int main()
{
int num1 = 7;
int num2 = 5;
int *pnum1 = &num1;
int *pnum2 = &num2;
printf("pnum1= %d\n",*pnum1);
printf("num1= %d\n", num1);
printf("pnum2= %d\n",*pnum2);
printf("num2= %d\n", num2);... |
C | #include <stdio.h>
#include <stdlib.h>
static int binary_search_first(const int *A, const int n, const int key)
{
int l = 0, r = n - 1, m = (n - 1) / 2;
while (l <= r){
if (A[m] < key)
l = m + 1;
else
r = m - 1;
m = (l + r) / 2;
}
return l;
}
static int binary_search_last(const int *A, const int n, con... |
C | #include <stdio.h>
#include <stdlib.h>
struct Node{
int data;
struct Node *next;
};
//struct Node *indertOrdered(struct Node, int);
//struct Node *deleteNode(struct Node, int);
struct Node *insertOrdered(struct Node* head, int data){
struct Node *ptr, *ptr2;
if(head== NULL){ // list is empty
head= m... |
C | #include <stdio.h>
#include "bitboard.h"
bitboard PDIAGS[15] = {0x0100000000000000ull, 0x0201000000000000ull, 0x0402010000000000ull, 0x0804020100000000ull, 0x1008040201000000ull, 0x2010080402010000ull, 0x4020100804020100ull,
0x8040201008040201ull, 0x0080402010080402ull, 0x0000804020100804ull, 0x0000008040201008ull,... |
C | //
// Created by Mario on 21.11.2020.
//
#define pageSize 4096
#define fenceSize 16
#define fenceVal 17
#define utilitySize (sizeof(struct control)+(2*fenceSize))
#define PAGES_AVAILABLE 16384
//#define hehe 1
#include "heap.h"
#include "custom_unistd.h"
#include <stdio.h>
#include <string.h>
#include ... |
C | //
// looks like you don't have to go #ifndef #define #end with functions (but you have to import the .h file in mx2)
//
//int Factorial(int M);
int Factorial_send_var(int M)
{
int factorial=1;
// Calculate the factorial with a FOR loop
for(int i=1; i<=M; i++)
{
factorial = factorial*i;
}
r... |
C | /*
* header.c
*
* Created on: 2 kwi 2019
* Author: X
*/
#include <stdio.h>
#include <stdlib.h>
#include "header.h"
struct element *wsk_str = NULL; //wskaźnik na strukture
void dodawanie_elementu(int i) {
struct element *aktualny;
struct element *first;
aktualny = (struct element*)malloc(sizeof... |
C | /*
* HEAP-SIFT.C --Fundamental operations for implicit (array) heaps.
*
* Contents:
* heap_sift_up() --Sift a value from the bottom of the heap to the top.
* heap_sift_down() --Sift a value from the top to its "correct" position.
* heap_ok() --Check the heap condition.
*
* Remarks:
* The heap data str... |
C | /*****************************
* 11875
* Brick Game
* Accepted
******************************/
#include <stdio.h>
int main()
{
int a[11],i,j,N,T;
scanf("%d",&T);
for(i=1;i<=T;i++){
scanf("%d",&N);
for(j=0;j<N;j++){
scanf("%d",&a[j]);
}
printf("Case %d: %... |
C | /* ************************************************************************** */
/* */
/* :::::::: */
/* get_commands.c :+: :+: ... |
C | #include<stdio.h>
#define nil 1<<30
int path[101][101],n,flag[101];
int dis[101];
int sum;
int dij(int i,int num)
{
int min=nil,t,j;
for(j=1;j<=n;j++)
{
if(dis[j]>dis[i]+path[i][j]&&i!=j&&path[i][j]>0)
dis[j]=dis[i]+path[i][j];
}
for(j=1;j<=n;j++)
{
if(flag[j]==0&&min>dis[j])
... |
C | #include <stdio.h>
#include <time.h>
int main()
{
struct timespec ts;
clock_getres(CLOCK_REALTIME, &ts);
printf("clock precision = %ld.%09ld\n",
ts.tv_sec, ts.tv_nsec);
return 0;
}
|
C | /*
* token.c Read the next token from a string.
* Yes it's pretty primitive but effective.
*
* Version: $Id$
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* v... |
C | #include "holberton.h"
/**
* print_binary - print binary representation of number
* @n: number, unsigned
* Do not use array, malloc, % and /
*
* Return: void
*/
void print_binary(unsigned long int n)
{
char c;
/*base case n == 0*/
if (n == 0)
{
_putchar('0');
return;
}
/*base case n at beginning > 0 I h... |
C | #include "main.h"
#include <stdio.h>
/**
* _strstr - a function that locates a substring.
* @haystack: an input string to search in
* @needle: an input string to locate into string haystack
* Return: a pointer to the beginning of the located substring,
* or NULL if the substring is not found.
*/
char *_strstr(... |
C | #include "SoundEffects.h"
#include <stdio.h>
SoundEffect_Queue* create_SoundEffect_Queue(int cap){
SoundEffect_Queue* ptr = (SoundEffect_Queue*) malloc(sizeof(SoundEffect_Queue));
return ptr;
}
// void EnqueueSoundEffect(SoundEffect_Queue* queue , int soundEffectSelector){
//
// if(!isQueueFull(queue) && soundE... |
C | #include <stdio.h>
/*
construction of a function that returns the arithmetic mean of two numbers
*/
float media(float n1, float n2);
int main()
{
float r;
r = media(10, 20);
printf("%f\n", r);
return 0;
}
float media(float n1, float n2)
{
float result = (n1 + n2) / 2;
return result;
}
|
C | #include<stdio.h>
int length;
int partition(int arr[],int p, int r)
{
int j, i, temp, x;
i= p-1;
x= arr[r];
for(j=p;j<r;j++)
{
if(arr[j]<=x)
{
i+=1;
temp = arr[i];
arr[i] = arr[j];
arr[j]=temp;
}
}
temp = arr[i+1];
arr[i+1] = arr[r];
arr[r] = temp;
return i+1;
}
void quickSort(int arr[], int p, ... |
C | #include <stdio.h>
#include <stdlib.h>
#define SIZE 64
int main()
{
char *string;
string = malloc(sizeof(char)*SIZE);
if( string == NULL )
{
puts("Unable to allocate memory");
return(1);
}
printf("Your name: ");
fgets(string,SIZE,stdin);
printf("Welcome %s\n", string... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char const *argv[]) {
char line[1044][255], c;
int i, j = 0, month[1044], day[1044], hour[1044], minute[1044], counter = 0;
FILE * fp = fopen("input1.txt", "r");
if(!fp)
{
printf("Error: File not opened\n");
return 0;
}
... |
C |
#define TYPE_FLOAT 0
#define TYPE_INTEGER 1
#define TYPE_STRING 2
#define COMMAND_SIZE 8
byte COMMAND_BUFFER[COMMAND_SIZE];
//Compare to bytes, ignoring casing.
bool equalsIgnoreCasing(byte a, byte b) {
if (a == b) return true;
if (a - ( 'a' - 'A' ) == b) return true;
if (a + ( 'a' - 'A' ) == b) return true;
retu... |
C | #ifndef LINKEDLIST_H
#define LINKEDLIST_H
#include <stdio.h>
#include <stdlib.h>
#include "Graph.h"
typedef struct tagNode
{
Vertex* Data;
struct tagNode* NextNode;
} Node;
/* Single Linked List (SLL) */
Node* SLL_CreateNode(Vertex* NewData);
void SLL_DestroyNode(Node* Node);
void SLL_DestroyAllNodes... |
C | /*
Author: Danchen Huang
Date Created: 09/15/2015
This file is dedicated to resemble a small graphics library for project 1 of CS1550
*/
#include <time.h>
#include <termios.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <linux/fb.h>
#include <sys/ioctl.h>
#include <s... |
C | /*
@Author: Raghav Maheshwari.
@Date: 26th May, 2019
@Topic: Prims Algorithm for MST
*/
#include<stdio.h>
int cost[20][20];
int visited[20] = {0};
int min_cost = 0;
void prims(int n){
int ne = 1; //This is to keep track of the number of edges in MST, should be n-1;
int a; //this is the source ... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* text.c :+: :+: :+: ... |
C | #ifndef GET_CH
#define GET_CH
#include <stdio.h>
#include "getint.h"
char buf[BUFFSIZE];
int bufp=0;
int getch(void)
{
return (bufp>0) ? buf[--bufp]:getchar();
}
void ungetch(int c)
{
if(bufp>=BUFFSIZE)
printf("Can't ungetch: too many\n");
else
buf[bufp++] = c;
}
#endif |
C | #include "basic.h"
void selection_sort(Array array, int n) {
int i, j, min;
for (i = 0; i <= n - 2; i++) {
min = i;
for (j = i + 1; j <= n - 1; j++) {
if (cmp(array[j], array[min]) < 0) {
min = j;
}
}
if (cmp(array[min], array[i]) < 0) {
swap(array, i, min);
}
}
}
|
C | /*
Um funcionario recebe um salario fixo mais 4% de comissao sobre as vendas. Faca
um programa que receba o salario fixo de um funcionario e o valor de suas vendas,
calcule e mostre a comissao e o salario final do funcionario.
*/
#include <stdio.h>
#define TAXA_COMISSAO 0.04
int main() {
double salario_fixo = 0.0... |
C | #include <stdio.h>
#define XMAX 200
#define YMAX 150
struct point makepoint(int, int, int, int, int);
struct point {
int x;
int y;
int z;
int a;
int b;
};
struct rect {
struct point pt1;
struct point pt2;
};
int main()
{
struct rect screen;
struct point middle;
screen.pt1 = makepoint(1, 2, 3, 4, 5);
s... |
C | /** \file caudales.c
* \author Abel N. Dammiani
*
* \brief Contiene la maquina de estados correspondiente al la medicion de caudales.
*
*/
#include "caudales.h"
#include "macros.h"
#include "inicio.h"
#include <stdio.h>
#include <stdlib.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
/***********************... |
C | #include<avr/io.h>
#include <util/delay.h>
#define LCD_port PORTA
#define LCD_ctrl PORTB
#define LCD_port_ddr DDRA
#define LCD_ctrl_ddr DDRB
#define LCD_RS 0
#define LCD_RW 1
#define LCD_E 2
#define SETB(x,y) x |= (1<<y)
#define CLRB(x,y) x &= ~(1<<y)
#define COMB(x,y) x ^= (1<<y)
void lcd_cmd(char cmd)... |
C | #include <stdio.h>
#include <string.h>
char nm[3][20], aux[20];
int main(){
for (int i = 0; i < 3; i++) {
printf("\nNome %i: ", i+1);
scanf("%s", nm[i]);
}
for (int i = 1; i < 3; i++) { /* 3 = qtde de palavras */
for (int j = 1; j < 3; j++) {
// verifica se tem que ser depois, se for troca de posio
... |
C | #include <stdio.h>
void *test(char target[]) {
printf("%s\n", target);
}
void run(void *func(), char args[]) {
func(args);
}
int main() {
run(test, "will it");
printf("%p\n", test);
return 0;
}
|
C | #include <string.h> // for memset
#include <avr/io.h>
#include "macro.h"
#include "switch.h"
#define GEN_PORT_GET_FUNC( PORTID ) \
char _port##PORTID##_get(char bitnum) \
{ \
if( ( PIN##PORTID & _BV(bitnum) ) == 0 ) \
return SW_ON; \
else \
return SW_OFF; \
} \
typedef struct _sw_map{
char (* port_get)(... |
C |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
const char in[63]={48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,\
81,82,83,84,85,86,87,88,89,90,95,97,98,99,100,101,102,103,104,105,106,107,108,109,110,\
111,112,113,114,115,116,117,118,119,12... |
C | #include<stdio.h>
#include<stdlib.h>
#define MAX_SIZE 10
int sorted[MAX_SIZE];
// i ĵ Ʈ ε
// j ĵ Ʈ ε
// k ĵ Ʈ ε
void merge(int list[], int left, int mid, int right) {
int i, j, k, l;
i = left; j = mid + 1; k = left;
// ĵ list պ
while (i<=mid && j <= right){
if (list[i] <= list[j]) sorted[k++] = list[i++];... |
C | // Program to convert celsius to Farenheit and vice-versa
#include <stdio.h>
#include <stdlib.h>
float degree(float);
float degrees(float);
int main()
{
float cel,farenheit=100;
cel=degree(farenheit);
printf("%f farenheit is %f celsius\n",farenheit,cel);
farenheit=degrees(cel);
printf("... |
C | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
#include "linkedList.h"
#include "mainAux.h"
node* current = NULL;
node* head = NULL;
node* last = NULL;
/* This method prints the undo-redo nodes from the beginning to the end */
void displayForward() {
... |
C | /**
* \file ctslab.c
* \author wzj
* \brief
a simple slab just like the nginx
* \version
* \note
* \date: 2012年11月02日星期五23:45:03
*
* discript your detail info.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <Jlog.h>
#include "ctslab.h"
/**
* \brief init the alloced buffer a... |
C | // one zero two zeros c soln for code eval by steven a dunn
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int find_start(char*);
int count_zeros(char*, int);
int main (int argc, char* const argv[])
{
FILE *fp = fopen(argv[1], "r");
if (fp)
{
char line[1024];
while(fgets(line, sizeof(line), fp))
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.