language large_stringclasses 1
value | text stringlengths 9 2.95M |
|---|---|
C | // Test Bits ADT
#include <stdio.h>
#include "defs.h"
#include "reln.h"
#include "tuple.h"
#include "bits.h"
int main(int argc, char **argv)
{
Bits b = newBits(60);
printf("t=0: "); showBits(b); printf("\n");
setBit(b, 5);
setBit(b, 4);
setBit(b, 3);
setBit(b, 2);
setBit(b, 1);
setBit(b, 0);
/... |
C | /**
* FILENAME : debitub.c
* AUTHOR : Moragues Lucas, Perrot Gaëtan
*
**/
#define _GNU_SOURCE
#include <ctype.h>
#include "bor-util.h"
int pid_pere,pid_fils;
long long int octetlu;
void secend(){
if((int) getpid() == pid_fils){
alarm(1);
printf("octetlu : %lld\n",octetlu);
octetlu=0;
}
else { // use... |
C | #include "graphs.h"
/**
* dfs - traverse graph using depth-first algorithm
* @v: pointer vertex node being visited
* @visited: array specifying if vertex has been visited
* @action: function pointer to be called for each visited vertex
* @depth: current depth
* @max_depth: max depth reached during traversal
*/
... |
C | //Example program #1 from Chapter 16 of Absolute Beginner's Guide
//to C, 3rd Edition
//File Chapter16ex1.c
/* This program will ask users to input test grades for the 25 students in a class and
then compute an average test grade. If fewer tan 25 students took the test, the user
can enter -1 as a grade and break the ... |
C | #include <mpi.h>
#include <stdio.h> //Para el printf
#include <stdlib.h>
#include <ctype.h>
#include <time.h>
#define RANK_0 0
#define RANK_1 1
#define RANK_2 2
#define RANK_3 3
int *generarMatrizAleatoria(int tam)
{
int *vec = malloc(sizeof(int) * tam);
for (int i = 0; i < tam; i++)
vec[i] = rand() %... |
C | #include <stdio.h>
#include <unistd.h>
#include <iostream>
using std::cout;
using std::endl;
#include <sys/wait.h>
#include <pthread.h>
#include <thread.h>
#include <errno.h>
#define NUM_THREADS 3
int wait_for_time=2;
void *sleep_test(void *parameters)
{
int sleep_time = wait_for_time;
wait_for_... |
C | /*
cc4.5: Implement a function to check if a binary tree is a binary search tree.
IDEA: 1. use in-order to traverse the tree, compare the val of pre node and current node!!
need to return the FALSE or TRUE val from both left and right branch!!(cannot use
handle duplicate values, from left to right!!... |
C | #include <stdio.h>
#include <stdlib.h>
int ebs(int, int, int ); /* fonksiyon n bildirimi */
int main()
{
int a, b, c;
printf("3 adet tam sayi giriniz: ");
scanf("%d %d %d", &a, &b, &c);
printf("Girilen sayilarin en buyugu: %d\n", ebs(a, b, c));
return 0;
}
int ebs(int x, int y, int z)
{
int ebs = x;
... |
C | /* BC31± */
/* compile under Borland C++ 3.1 */
#include <stdio.h>
#include <dirent.h>
#include <dos.h>
#include <io.h>
#include <direct.h>
#include <string.h>
void show_directory(char *directory_name)
{
DIR *directory_pointer;
struct dirent *entry;
unsigned attributes;
if ((directory_pointer = opendi... |
C | #include<stdio.h>
#include<stdlib.h>
struct linked_list
{
int data;
struct linked_list *next;
};
typedef struct linked_list node;
node *createlist(node *head, int data)
{
node *temp, *start = head;
if(head == NULL)
{
head = (node*)malloc(sizeof(node));
head->data = data;
head->next = NULL;
}
else
{
wh... |
C | #include<stdio.h>
#include<stdlib.h>
#include "../utility.h"
typedef struct node {
int key;
struct node *parent;
struct node *left;
struct node *right;
} node_t;
typedef struct tree {
node_t *root;
size_t size;
} tree_t;
void inorder_tree_walk(node_t *root) {
if (root != NULL) {
i... |
C | #include <stdio.h>
#include <stdlib.h>
#include "genwave.h"
int main(int argc, char **argv){
genwave_t *wave1;
genwave_open(&wave1, NULL, 2, 11025, 8); // NULL filenames means "write to stdout"
fprintf(stderr, "Generating endless wav file to stdout...\n");
for(;;){
genwave_tone(&wave1, 0, 0.200, 0.5);
... |
C | int removeElement(int* nums, int numsSize, int val) {
int i = 0;
int n = 0;
int temp = numsSize - 1;
while(i <= temp)
{
if(nums[i] == val)
{
nums[i] = nums[temp--];
i--;
}
i++;
}
return temp+1;
... |
C | #include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include "message_transmission.h"
#include "tcp_connection.h"
#include "named_pipe_connection.h"
#include "authenticate.h"
/**
* Checkear credenciales contra el servidor de autenticación (mover a su propio .h)
*
* @... |
C | #include <stdio.h>
#include <string.h>
int trim(char s[]);
// 3.7 break 语句与 continue 语句
main()
{
char s[] = "demo \n\t ";
int n = trim(s);
printf("%d :%s:\n", n, s);
}
// 删除右侧空白符
int trim(char s[])
{
int i;
for (i = strlen(s) - 1; i >= 0; i--)
{
if (s[i] != ' ' && s[i] != '\t' && s[i]... |
C | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
void main()
{
int a[5]={}, i, mx, mn, n1=0, n2=0, n3=0, j;
// 乱数の初期化
srand((unsigned)time(NULL));
for (i=0;i<5;i++){
//1から10までの乱数を発生させる
a[i] = rand() % 100 + 1;
if(a[i]>=20 && a[i]<=50){
n1++;... |
C | /**
* example_02.c - moving sprite with music
* This example program displays a 15 color sprite (mandarin goby) in a fishtank
* that moves and changes directions with added sound.
* Originally example_04 from the tutorial: Amiga Hardware Programming in C: Sprites
*/
#include <stdio.h>
#include <string.h>
#include ... |
C | /*
Tool used to upload/flash a binary into a target board
using serial RS232.
Yaspr 2019
COSMOS License - Free of rights and charges everywhere in the COSMOS and at all times.
*/
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#includ... |
C | #include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
int main(int argc, char **argv) {
int fork_rc;
int wait_rc;
fork_rc = fork();
if (fork_rc < 0) {
fprintf(stderr, "couldn't fork\n");
} else if (fork_rc == 0) {
pri... |
C | #include <stdio.h>
int main()
{
float num, total = 0, average;
int count = 0, i = 0;
for (i = 0; i < 6; i++)
{
scanf("%f", &num);
if (num > 0)
{
count++;
total += num;
}
}
average = total / count;
printf("%d valores positivos\n", count);
printf("%.1f\n", average);
return 0;
}
|
C | /**
* @file main.c
* @brief Testing Program.
* @author rania hajyoussef
* @version 0.1
* @date Apr 25, 2020
*
* Testing program for background scrollilng
*
*/
#include "perso2.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include "SDL/SDL_mixer.h"
#include... |
C | #include <mpi.h>
#include <stdlib.h>
#include <stdio.h>
int function(int arr[], int min, int max){
int x,temporary=0;
for(x=min;x<max+1;x++){
temporary+=arr[x];
}
return temporary;
}
<<<<<<< HEAD
int main(int argc, char **argv){
=======
int main(int *argc, char **argv){
>>>>>>> 68146fe94c1355888b641769eefac8ffb... |
C | /* Giacomo Ritucci <ritucci@cs.unibo.it>
*
* Problem 1 - http://projecteuler.net/
*
* Add all the natural numbers below 1000 that are multiples of 3 or 5.
*
* If we list all the natural numbers below 10 that are multiples of 3 or 5,
* we get 3, 5, 6 and 9. The sum of these multiples is 23.
*
* Find the sum of ... |
C | #include <stdio.h>
#include <string.h>
char str[100];
void getStr(int *a,int len){
int i,j;
char *p=(char*)str;
for(i=0;i<a[0];i++){
*p='(';
p++;
}
*p=')';
p++;
for(i=1;i<len;i++){
for(j=0;j<a[i]-a[i-1];j++){
*p='(';
p++;
}
*p=')';
p++;
}
}
void handle(){
int len=strlen(str);
int i;
for(i=... |
C | #include <stdio.h>
#include <stdlib.h>
typedef struct position P;
struct position
{
int x;
int y;
};
void input_xy(P *p, int n) {
int i;
for (i = 0; i < n; ++i) {
scanf("%d", &p->x);
scanf("%d", &p->y);
p++;
}
}
void output_xy(P *p, int n) {
int i;
for (i = 0; i < n; ++i) {
printf("(%d, ", p->x);
print... |
C | #ifndef __UNDOFS_UTILS_H_
#define __UNDOFS_UTILS_H_
#include "config.h"
#include <sys/wait.h>
#include <limits.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#ifndef NOLOG
#define LOG(fmt, ...) { fprintf(undofs_logfile(), "%s:%d\t" fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__); fflush(undofs_logfile())... |
C | /* Yevgeniy Shevekhman
* Assignment 04
*/
#include <stdio.h>
#include <stdlib.h>
#define PARENT(i) (i - 1) / 2
#define LCHILD(i) 2 * i + 1
#define RCHILD(i) 2 * i + 2
#define MAX 80
int heap[MAX] = {0};
void build(void);
void insert(int n);
void print(void);
void delete(void);
int i;
int main(void)
{
int sel;... |
C | /**
* Utility functions
* -------------------
*
* Author: Christos Zonios
*/
#include <k-means.h>
#define _mat(i,j) (mat[(i)*n + (j)])
/**
* Function: rand_in_range
* -----------------------
* Generates a random number in the given range
*
* min: (float) start of range
* max: (float) end of range
*
* re... |
C | #include <stdio.h>
#include <conio.h>
void main()
{
int ar[50], siz, i, j, item;
clrscr();
printf("\n\nENTER THE SIZE OF ARRAY YOU WANT (MAX. LIMIT 50)...... ");
scanf("%d", &siz);
printf("\n\n\nENTER THE ELEMENTS......\n\n");
for (i = 0; i < siz; i++)
scanf("%d", &ar[i]);
printf("\... |
C | #include "unpthread.h"
static pthread_key_t rl_key;
static pthread_once_t rl_once = PTHREAD_ONCE_INIT;
static void
readline_destructor(void *ptr)
{
free(ptr);
}
static void
readline_once(void)
{
Pthread_key_create(&rl_key, readline_destructor);
}
typedef struct {
int rl_cnt; /* initialize to 0 */
char rl_... |
C | #include <stdio.h>
#include<string.h>
int main(void) {
char a[100];
gets(a);
int i,c=0;
printf("\n enter your string:");
for(i=0;a[i]!='\0';i++)
{
if(a[i]=='!' || a[i]=='@' || a[i]=='#' || a[i]=='%' || a[i]=='$' || a[i]=='^' || a[i]=='&' || a[i]=='*' || a[i]=='(' || a[i]==')' || a[i]=='_')
{
c++;
}
}
printf("\n The nu... |
C | #include <stdio.h>
#define M 8
void exchange(int*, int*);
void transpose_opt(int A[M][M])
{
int *DiagPtr;
int *ColPtr;
int *RowPtr;
int i, j;
for (i = 0; i < M; i++) {
DiagPtr = &A[0][0] + i * (M + 1);
ColPtr = DiagPtr;
RowPtr = DiagPtr;
for (j = i; j < M; j++) {
exchange(ColPtr, RowPtr);
Col... |
C | /*
* NIM/Nama : 13515071 / Daniel Pintara
* Tanggal : Fri Sep 9, 2016
* Topik : DFA
* Deskripsi : Implementasi DFA pada vending machine sederhana
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <assert.h>
#include "common.h"
#include "parse.h"
// Parse
#define... |
C |
int add_one(int value) {
value += 1;
return value;
}
|
C | #ifndef UTIL_H
#define UTIL_H
typedef long int integer;
typedef unsigned long int uinteger;
typedef char *address;
typedef short int shortint;
typedef float real;
typedef double doublereal;
typedef struct { real r, i; } complex;
typedef struct { doublereal r, i; } doublecomplex;
typedef long int logical;
typedef shor... |
C | // RUN: %clang_cc1 -analyze -analyzer-checker=alpha.different.LabelInsideSwitch -verify %s
void f1() {
int c = 7;
switch(c){
case 1:
c += 1; break;
defalt: // expected-warning{{Possible misprint: label found inside the switch statement}}
c -= 1; break;
}
}
|
C | #include "ipw.h"
#include "snow.h"
double
g_snow(
double rho1, /* upper snow layer's density (kg/m^3) */
double rho2, /* lower " " " (kg/m^3) */
double ts1, /* upper snow layer's temperature (K) */
double ts2, /* lower " " " (K) */
double ds1, /* upper snow layer's thickness (m) ... |
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"
int main()
{
int character, isspace;
isspace = 0;
while ((character = getchar()) != EOF) {
if (character == " ")
{
if (isspace == 0)
{
isspace = 1;
putchar(character);
} else
{
isspace = 0;
}
}
}
} |
C | #include <stdio.h>
int v[100001];
int q[100001];
int f=-1;
int r=-1;
int find(int n,int m);
int main(void)
{
int n,m;
scanf("%d %d", &n,&m);
printf("%d" ,find(n,m));
}
int find(int n,int m)
{
q[++r] =n;
v[n]=1;
while(f!=r)
{
int t=q[++f];
if(t==m)
return v[t]-1;
if(t>0&&v[t-1]==0)
{
q[++r]=t... |
C | /*
** EPITECH PROJECT, 2017
** File Name : init_map.c
** File description:
** by Arthur Teisseire
*/
#include <stdlib.h>
#include "my.h"
#include "rpg.h"
#include "tile.h"
#include "texture.h"
#include "scene.h"
#include "define.h"
#include "parse.h"
#include "tool.h"
static int init_row(rpg_t *rpg, map_t *map, sfIma... |
C | #include "holberton.h"
/**
* is_delim - check if char is equal to delim
* @c: character
* @delim: " "
* Return: 0 if no match, 1 if matched
*/
int is_delim(char c, const char *delim)
{
while (delim && *delim)
{
if (c == *delim)
{
return (1);
}
++delim;
}
return (0);
}
/**
* _strtok - mimics strt... |
C | #include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
int wait_flag;
void stop();
int main(void){
int pid1, pid2, pid3;
signal(3, stop);
printf("Register a signal handler for signal 3.\n");
while((pid1 = fork()) == -1); //创建子进程1
if(pid1 > 0) //... |
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 <arpa/inet.h>
#include <netdb.h>
#include <math.h>
#include "helpers.h"
void usage(char *file)
{
fprintf(stderr, "Usage: %s server_address server_port\n", file... |
C | #include "lab2_io.h"
#include "lab2_omp.h"
#include <stdlib.h>
#include <omp.h>
#include <stdio.h>
#include <string.h>
/*
Arguments:
arg1: input filename (consist M, N and D)
arg2: retention (percentage of information to be retained by PCA)
*/
int main(int argc, char const *argv[])
{
if (argc < 3){
printf("... |
C | /**
* @\file POSIX_timer.h
* @\author Sanju Prakash Kannioth and Steve Antony X
* @\brief This files contains the function definitions for POSIX timer
* @\date 04/29/2019
*
*/
/*****************************************************************
Includes
*******************************************************... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* small_sort.c :+: :+: :+: ... |
C | /*
** EPITECH PROJECT, 2020
** map.c
** File description:
** map.c
*/
#include "sources/lib/my/my.h"
char **setting_map(game_t *game, char **str)
{
str = malloc(sizeof(char * ) * 12);
for (int i = 0; i < 11; i++)
str[i] = malloc(sizeof(char) * 18);
str[0][0] = ' ';
game->y = 2;
for (int i... |
C | #include <stdint.h>
#include <stdbool.h>
#include "console.h"
/*
* Core UART functions to implement for a port
*/
static uint64_t potato_uart_base;
#define PROC_FREQ 50000000
#define UART_FREQ 115200
#define UART_BASE 0xc0002000
#define POTATO_CONSOLE_TX 0x00
#define POTATO_CONSOLE_RX 0x08
#define POTATO_CONSO... |
C | #include <stdio.h>
#include <string.h>
#include <ctype.h>
int main (int argc,char * argv[])
{
char ch;
if (argc != 2)
{
puts("-p putsoure");
puts("-u putupper");
puts("-l putlower");
puts("I just get one argument");
return 0;
}
if ( !strcmp(argv[1],... |
C | /*
Author: Yansong Li
Banner number: B00755534
Date: 2019-11-11
Courese: CSCI3120
Assignment3
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXROW 50
//a sturct that keep one task
typedef struct{
char *name;
int arrival_time;
int burst_time;
}task;
int String_Split(char *argv[], cha... |
C | #include<stdio.h>
#include<stdlib.h>
int bubble_sort(int n,int *ar)
{
int i,j,temp;
for(i=0; i<n;i++)
{
for(j=0; j<n-i-1;j++)
{
if(*(ar + j)>*(ar + j + 1))
{
temp = *(ar + j);
*(ar + j) = *(ar + j + 1);
*(... |
C | #include <stdio.h>
#define SIZE 5
int i,k;
void sort_selection(int vetor[], int tamanho);
int main()
{
int array[SIZE] = {5,2,4,3,-1};
puts("SELECTION SORT:");
sort_selection(array, SIZE);
for (i = 0; i < SIZE; i++)
{
printf("[%d]", array[i]);
}
puts("\n");
return 0;
}
void sort_selection(int vetor[], i... |
C | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main(void)
{
double n, k;
scanf("%lf",&n);
n--;
k = (18.0 * 60) / n;
printf("%lf\n",k);
return 0;
}
|
C | #ifndef _LAYOUT_H_
#define _LAYOUT_H_
#include <stdint.h>
#include <string.h>
#define LAYOUT_FLAG_KEYUP 0x01 /* ʱӦ */
#define LAYOUT_FLAG_LRSEP 0x02 /* ҶԳƲ */
#define LAYOUT_FLAG_SPACE 0x04
#define LAYOUT_FLAG_BIAODIAN 0x08 /* Żlr=1,up=1ʱЧ */
#define LAYOUT_KEY "yuiophjkl;'nm,./qwertasdfgzxcvb"
#define LAYO... |
C | #include "libft.h"
void ft_lstiter(t_list *lst, void (*f)(void *))
{
t_list *elem;
elem = lst;
while (elem != NULL && f != NULL)
{
(*f)(elem->content);
if (elem->next == NULL)
break ;
elem = elem->next;
}
}
|
C | #include "playfield.h"
#include "stats.h"
Playfield playfield_constructor (void) {
Playfield new_playfield;
for (int row = 0; row < PLAYFIELD_HEIGHT; row++) {
for (int col = 0; col < PLAYFIELD_WIDTH; col++) {
new_playfield.active_tetromino[row][col] = false;
new_playfield.fill_... |
C | #include "holberton.h"
/**
*_puts - will be same as normal puts (prints string followed by newline)
*@str: accepted string pointer
*Return: void
*/
void _puts(char *str)
{
int i;
for (i = 0 ; *str != '\0' ; str++)
_putchar(str[i]);
_putchar('\n');
}
|
C | void efficient( const int source[], int val[], int pos[], int size);
void reconstruct( int source[], int m, const int val[], const int pos[], int n);
efficient(const int source[], int val[], int pos[], int size){
int j= 0;//Variable to index the new val and pos arrays
for(int i=0; i<size; i++){
i... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putstr.c :+: :+: :+: ... |
C | #include <stdio.h>
typedef struct lock_t {
int ticket;
int turn;
} lock_t;
int main(int argc, char const *argv[])
{
return 0;
}
//硬件原语 fetch-and-add
int FetchAndAdd(int *ptr) {
int old = *ptr;
*ptr = old + 1;
return old;
}
void init(lock_t *lock) {
lock->ticket = 0;
lock->turn = 0;
... |
C | #include <stdio.h>
void f(int param[]) {
printf("sizeof(param): %d\n", sizeof(param) );
param[3] = 6;
};
void g(int* param) {
printf("sizeof(param): %d\n", sizeof(param) );
param[6] = 6;
};
int main(){
int array[] = { 1,2,3,4,5,6,7,8 };
f(array);
g(array);
//3. Hacer procedimiento p... |
C | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define GRANDEZZA_INPUT 100
//Dichiaro una funzione per ogni stato dell'automa.
void stato0(char carattere);
void stato1(char carattere);
void stato2(char carattere);
void stato3(char carattere);
void stato4(char carattere);
void stato5(char carattere);
void ... |
C | # include <stdio.h>
# include <conio.h>
void main()
{
int i,sum;
for (i=1,sum=0;i<=1000;i++)
{
sum=sum+i;
}
printf("\n\a The sum is %d.",sum);
getch();
}
|
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 | /*
** concatenate t to end of s
** s must be large enough
*/
strcat(s, t) char *s, *t; {
char *d;
d = s;
--s;
while (*++s) ;
while (*s++ = *t++) ;
return (d);
}
|
C | /**
Copyright Notice:
Copyright 2021 DMTF. All rights reserved.
License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
**/
/** @file
Montgomery-Curve Wrapper Implementation.
RFC 7748 - Elliptic Curves for Security (Curve25519/Curve448)
N... |
C | /*
* code.h
*
* Created on: May 23, 2012
*
*/
#ifndef CODE_H_
#define CODE_H_
#include "type.h"
#include "rtc.h"
#include "irq.h"
#define CODE_LEN (4) // number of digits in a code
#define MAX_CODES (16) // maximum possible number of codes (valid or invalid)
enum expire_times {
... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "traffic.h"
extern struct intersection isection;
/**
* Populate the car lists by parsing a file where each line has
* the following structure:
*
* <id> <in_direction> <out_direction>
*
* Each car is added to the list that co... |
C | /*!
* DP算法:数塔问题, DP算法只能得到一个最优解
* 使用数字来构建一座塔,要求从顶层走到底层,每一步
* 只能走到相邻的节点,则经过的节点的数字之和最大(小)是多少?
*
* 8
* / \
* 12 15
* / \/ \
* 10 6 8
* / \ / \ / \
* 2 18 9 5
* / \ / \ / \ / \
* 19 7 10 4 ... |
C | #include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <string.h>
#include <unistd.h>
// Utility
int bytes_received;
// Server address
struct sockaddr_in my_address;
// Gestione giocatori
#define BACKLOG 10
int listening_socket;
struct player* players = ... |
C | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<unistd.h>
#include<arpa/inet.h>
#include<sys/socket.h>
#define BUF_SIZE 30
void error_handling(char *message);
//接受文件的客户端,省略了一些错误判断
int main(int argc,char *argv[])
{
if(argc!=3)
{
printf("Usage:%s <ip> <port> \n",argv[0]);
exit(1);
}
in... |
C | #include<stdio.h>
#define INF 99999
int V;
int i,j;
void printSolution(int dist[][V]);
void floydWarshall (int graph[][V])
{
int dist[V][V], i, j, k;
for (i = 0; i < V; i++)
for (j = 0; j < V; j++)
dist[i][j] = graph[i][j];
for (k = 0; k < V; k++)
{
for (i = 0; i < V; i+... |
C | #include <stdio.h>
/*
黒板に N 個の正の整数 A1,...,AN
が書かれています.
すぬけ君は,黒板に書かれている整数がすべて偶数であるとき,次の操作を行うことができます.
黒板に書かれている整数すべてを,2
で割ったものに置き換える.
すぬけ君は最大で何回操作を行うことができるかを求めてください.
*/
int main(void) {
int n;
int i = -1;
int flag = 0;
scanf("%d", &n);
int listn[n];
// input
for (int j=0; j < ... |
C | #include <stdio.h>
#include <stdlib.h>
#include <signal.h>
int main()
{
sigset_t set;
if(sigfillset(&set)==-1) {
perror("sigfillset failed");
exit(1);
}
if(sigdelset(&set, SIGINT)==-1) {
perror("sigdelset failed");
exit(1);
}
if(sigismember(&set, SIGPIPE))
printf("SIGPIPE is a member\n");
else
p... |
C | /*
Student Name : Shyrush Shrestha
Subject : Programming Fudamen.
Roll No :
Program : Write a c program to swap two n numbers from users.
*/
#include<stdio.h>
//#include<conio.h>
void main (){
int a,b,tem;
printf("Enter first Number :");
scanf("%d",&a);
printf("Enter second number :");
scanf("%d",&b);
tem=a... |
C |
//Aici este declarat structura pentru liste
struct linked_list
{
int numar;
struct linked_list *mru;
};
typedef struct linked_list node;
node *head = NULL, *last = NULL;
void adsfarsit(int value)
{
node *temp_node;
temp_node = (node *) malloc(sizeof(node));
temp_node->numar=value;
... |
C | // Copyright Arina Turcu 313CA
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
int x, max, old, *freq;
max = 0;
freq = calloc(1, sizeof(int));
if (freq == NULL) {
fprintf(stderr, "Error: Nu s-a putut aloca memorie");
return -1;
}
while (!feof(stdin) &... |
C | #ifndef MOVEMENT_H
#define MOVEMENT_H
#include "../gpio/gpio.h"
#include "../pwm/pwm.h"
#include "../math/math.h"
#define MOTOR_PWM PWM0
#define MOTOR_PERIOD_VALUE 8500 // this value works for the motors that we have
#define MOTOR_DIR_FORWARD 1
#define MOTOR_DIR_REVERSE -1
#define MOTOR_FR... |
C | #include <stdio.h>
#include <stdlib.h>
int main(int argc, const char *argv[])
{
if(argc < 3){
printf("\nBitte gib min. zwei Zahlen ein!\n");
return 0;
}
int max = atoi(argv[1]);
int min = max;
int maxPos = 1;
int minPos = 1;
for(int i = 2; i < argc; ++i) {
int numb... |
C | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "list.h"
#include "algorithms.h"
int alea(int n, int m){
return (int)(n + (m-n)*((float)(rand()) / (float)(RAND_MAX)));
//produit des nombres aléatoires entre n et m.
//RAND_MAX = 16 * ((2^31) - 1)=34 359 738 352
}
char menu(){
char c;
printf... |
C | // vector.c
#include <stdio.h>
#include <stdlib.h>
#include "vector.h"
void vector_init(Vector *vector) {
// initialize size and capacity
vector->size = 0;
vector->capacity = VECTOR_INITIAL_CAPACITY;
// allocate memory for vector->data
vector->data = malloc(sizeof(int) * vector->capacity);
}
void vector_a... |
C | int cmpfunc (float a, float b) {
return (a > b);
}
void mySort(float *base, unsigned int nitems, int (*compar)(float, float) )
{
for(int i=0; i < nitems; i++)
{
float menorValor = base[i];
int indiceMenor = i;
for(int j=i+1; j<nitems; j++)
{
if( compar(menorValor,... |
C | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "die.h"
extern int debug;
int initPWMcontr() {
unsigned char buff[2];
if(debug) printf("Initializing PWM controller\n");
PWMhandle = i2c_open(1,0x42);
//POTENTIAL_BUG: If the motor spontaneously turns on, put code here to write... |
C | #include "Wizard.h"
#include <math.h>
#include "EntitiesManager.h"
#include "PlayerManager.h"
#include "MapManager.h"
#include "Fireball.h"
#define VIEW_DISTANCE 3
#define MAX_HEALTH 150
#define ATTACK_RANGE 2.8
#define COOL_DOWN 280
#define WIZARD_SPEED 0.015
void* WizardSpecialDataInit()
{
WizardSpecialData* sd ... |
C | #include "central.h"
#include <stdio.h>
int pipefd1;
void pipeencomenda(){
if ((mkfifo(NAMED_PIPE, O_CREAT|O_EXCL|0600)<0) && (errno!= EEXIST)) {
perror("Não foi possivel criar pipe: ");
exit(0);
}
char msg[MAXLENGTH],msg2[MAXLENGTH];
while(1){
if ((pipefd1 = open(NAMED_PIPE, ... |
C | /* CSC 345 Reference String Project
Part 3, Reference String Simulator
Nate Milkosky */
#include <stdio.h>
#include <stdlib.h>
// linked list node structure
typedef struct ll_node
{
int value;
struct ll_node *next;
} ll_node;
/* sim_fifo takes a reference string (and its length) as parameters, and returns th... |
C | #include <linux/kernel.h>
/* Max read/write errors/sector */
#define MAX_ERRORS 7
#define MAX_HD 2
/*
* This struct defines the HD's and their types.
*/
struct hd_i_struct {
int head,sect,cyl,wpcom,lzone,ctl;
};
struct hd_i_struct hd_info[] = { {0,0,0,0,0,0},{0,0,0,0,0,0} };
static int NR_HD = 1;
static struc... |
C | #include <stdio.h>
#include <pcap.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netinet/ip.h>
#include <net/ethernet.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <stdint.h>
int main(int argc, char *argv[])
{
char *dev; /*Device to sniff on*/
pcap_t *handle; ... |
C | /*
* ow.c
*
* Created on: 09-05-2018
* Author: psm8
*/
#include "OW.h"
uint8_t OW_reset(void)
{
uint8_t result;
_delay_us(delG);
OW_low;
_delay_us(delH);
OW_high;
_delay_us(delI);
result = OW_check;
_delay_us(delJ);
return result;
}
void OW_send_bit(uint8_t bit)
{
if(bit==1)
{
OW_low;
_d... |
C | #include <stdbool.h>
#include <string.h>
#include <sys/socket.h>
#include "../logging/logging.h"
#include "config.h"
static config_t *config_globalConfig = 0;
config_t *config_getGlobalConfig() {
return config_globalConfig;
}
void config_setGlobalConfig(config_t *config) {
config_globalConfig = config;
}
void... |
C | #include<stdio.h>
#define n 5
int main()
{
int a[10],i,j,temp;
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
j = 0;
for(i = 0; i < n; i++)
{
if(a[i] < 0) //1)Declare an array and input the array elements.
{ //2)Start traversing the array and if the current element is negative,swap the current... |
C | /*cose varie con le liste*/
#include <stdio.h>
struct nodo
{
char nome;
int array [5];
struct nodo * next;
};
typedef struct nodo Nodo; //non devo scrivere sempre struct nodo, ora basta Nodo
typedef Nodo * PNodo; // idem per il puntatore a tipo nodo, non serve *
void cazzoPuntatore(int * numero)
{
... |
C | /*
** 2strto1.c for PSU_2015_minishell2 in /home/fortevg/rendu/PSU/PSU_2015_minishell2/resource
**
** Made by Forteville Gabriel
** Login <fortevg@epitech.net>
**
** Started on Thu Apr 07 15:17:30 2016 Forteville Gabriel
** Last update Fri May 6 14:37:17 2016 Forteville Gabriel
*/
#include <stdlib.h>
#include "min... |
C | /**
* op_add - add two integer numbers.
* @a: first integer
* @b: second integer
*
*
* Return: the result
* On error: -1 inapropiate entry
*
*/
int op_add(int a, int b)
{
return (a + b);
}
/**
* op_sub - substract two integer numbers
* @a: first integer
* @b: second integer
*
*
* Return: the result
*... |
C | #include<stdio.h>
#include<string.h>
#include<stdlib.h>
enum{MAX_LEN = 20
};
char *my_strcat(char *str1,char *str2)
{
int len1,len2;
char *result;
len1 = strlen(str1);
len2 = strlen(str2);
result = (char *)malloc((len1 + len2 +1)*sizeof(char));
/*kich co cua mang result phai la len1 + len2 +1 vi ham strlen() tra ... |
C | #include "usart.h"
#pragma interrupt_handler uart_rx:12
static u8 reciveLen = 0;
static u8 reciveBuff[256];//256
extern const u8 cmdStart[cmdSTART_LEN] = { 's','t','a','r','t' };
extern const u8 cmdStop[cmdSTOP_LEN] = { 'e','n','d' };
extern void usartInit(u16 baud)
{
UCSRB = 0x00;
UCSRA = 0x00;
UCSRC = (1 <<... |
C | #include <stdio.h>
#include <netdb.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/sendfile.h>
#include <errno.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#define POR... |
C | #include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include "get_time.c"
extern double get_time (void);
void merge(int a[], int size, int size1, int temp[]) {
int i1 = 0;
int i2 = size1;
int tempi = 0;
while (i1 < size1 && i2 < size) {
if (a[i1] < a[i2]) {
temp[tempi] = a[i... |
C | #pragma once
#include "Hydra/Core/Common.h"
#include "Hydra/Input/InputCoreTypes.h"
struct InputActionKeyMapping
{
String ActionName;
Key KeyType;
uint8 bShift : 1;
uint8 bCtrl : 1;
uint8 bAlt : 1;
uint8 bCmd : 1;
bool operator==(const InputActionKeyMapping& Other) const
{
return (ActionName == Other.Actio... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.