language large_stringclasses 1
value | text stringlengths 9 2.95M |
|---|---|
C | #include <stdio.h>
//#include <malloc.h>
#include <assert.h>
#include <stdlib.h>
#include <math.h>
#include "board.h"
// Initialize a new Game for the nQueens problem: an empty board..
Item *initGame()
{
int i;
Item *node;
char* initial = (char*)malloc(MAX_BOARD*sizeof(char));
for (int i=0; i... |
C | #include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
struct Node
{
int val;
struct Node *next;
};
typedef struct Node Node;
Node* create_list(int val, Node* head)
{
printf("\n creating list with headnode as [%d]\n",val);
Node *ptr = (Node*)malloc(sizeof(Node));
if(NULL == ptr)
{
... |
C | #include "thpool.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/wait.h>
#include <semaphore.h>
#include <pthread.h>
struct th_pool_job
{
pthread_t threads;
void (*fun)(void*);
void* arg;
sem_t mutex;
};
... |
C | #include "rnggraph.h"
const int BIG_POWER_OF_TWO = 2 << (sizeof(int)*8 - 3);
unsigned int current_seed;
/*
* Resets the seed for randomly generated graphs.
*
* The same series of `set_seed` and `generate_graph` calls
* should produce the same series of graph reliably,
* but not when used in parallel.
*/
void s... |
C | #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
//һеֵ´
//ԭ˳8,6,5,4,1
//ҪΪ 1,4,5,6,8
#define N 5
int main() {
int a[5], i, temp;
printf(":\n");
for (i = 0; i < N; ++i) {
scanf("%d", &a[i]);
}
printf("Ϊ:\n");
for (i = 0; i < N; ++i) {
printf("%5d", a[i]);
}
for (i = ... |
C | #include "main.h"
void outbound_url(char *packet_data, UINT16 payload_len)
{
static const char get_request[] = "GET /";
static const char post_request[] = "POST /";
static const char http_host[] = "HTTP/1.1\r\nHost: ";
char domain[MAXURL];
char uri[MAXURL];
UINT16 i = 0, j;
// Verify that the packet contains... |
C | /*
** EPITECH PROJECT, 2020
** my put nbr
** File description:
** put nbr
*/
#include "my.h"
#include <stdarg.h>
#include <stdlib.h>
void my_putfloat(va_list *ap)
{
double a = va_arg(*ap, double);
int before = 1;
double after;
my_putnbr(before);
my_putchar('.');
after = a - before;
after *... |
C | #include "../include/ft_printf.h"
int equals_zero(char *str)
{
int i;
i = -1;
while (str[++i])
{
if (str[i] >= '1' && str[i] <= '9')
return (FALSE);
}
return (TRUE);
}
|
C | #define _XOPEN_SOURCE
#include<unistd.h>
#include<stdio.h>
#include<string.h>
#include<cs50.h>
int main(int argc, string argv[])
{
if(argc !=2)
{
printf("Usage: crack<hash>\n");
return 1;
}
int idriss= 53;
string letters ="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
s... |
C | #include <stdio.h>
#include <stdlib.h>
#define MAX_BUFFER_SIZE 1024
//#define MAX_BUFFER_SIZE 5
int main(int argc, char *argv[], char* envp[])
{
char buffer[MAX_BUFFER_SIZE];
FILE *fp = NULL;
if (argc == 1)
{
fputs("error: file not specified\n", stdout);
return -1;
}
else if (argc > 1)... |
C | #include <stdio.h>
int main(void)
{
int num,i;
printf("Number:");
scanf("%d",&num);
num++;
for(i=2;i<=num/2;i++)
{
if(num%i==0)
{
num++;
i=2;
}
}
printf("\n%d",num);
// your code goes here
return 0;
}
|
C | /* This file contains inserted assert macro statements. It is given to CBMC. */
unsigned int timeElapsed = 0;
volatile int P1_is_marked
#ifndef __INPVARS_EXE__
= 3
#endif
;
volatile long P1_marking_member_0 [ 3 ] ;
volatile int P2_is_marked
#ifndef __INPVARS_EXE__
= 5
#endif
;
volatile long P2_markin... |
C | /*
Seguindo o conceito de listas, desenvolva um algoritmo de estrutura de dados, que colete as 2 notas
durante o bimestre de todos os acadêmicos da disciplina de estrutura e armazene em uma lista...
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
typedef struct student {
char *name;
float grades[2];... |
C | #include <stdio.h>
void lirechaine (char tableau[Max])
{
int a=0;
char c;
c=getchar();
while((c!='\n') && (a<Max))
{
tableau[a++]=c;
c=getchar();
}
tableau[a]='\0';
}
int main()
{
char tableau2 [100][2];
char lettres;
int nombre;
char tableau[Max];
int x=0, a, j, k,repete = 0;
printf("Entrez une cha... |
C | #include "data.h"
unsigned long hash_code(unsigned int size, const char* key)
{
unsigned long int value = 0;
unsigned int i = 0;
unsigned int key_len = strlen(key);
for (; i < key_len; ++i)
value = value * 37 + key[i];
value = value % size;
return value;
}
struct has... |
C | #include "holberton.h"
/**
* _memset - fill memory with a constant byte.
*
* @s: Pointer to the memory.
* @b: Character to fill the area with.
* @n: Number of bytes.
*
* Return: Returns a pointer to the memory area s.
*/
char *_memset(char *s, char b, unsigned int n)
{
unsigned int j;
char *mem = s, by = b;... |
C | /*
* This file is part of the AprilTag library.
*
* AprilTag 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 version 2.1 of
* the License, or (at your option) any later version.
*
* April... |
C | #include <stdio.h>
int main()
{
int x;
for( x='A'; x<='Z'; x++ )
printf("%c%c",x,x+32);
putchar('\n');
return(0);
}
|
C | #include<stdio.h>
#define SIZE 20
main()
{
char letter[SIZE];
int count;
/*read in the line*/
for(count=0;count<SIZE;++count)
letter[count]=getchar();
for(count=0;count<SIZE;++count)
putchar(toupper(letter[count]));
} |
C | #include "lists.h"
/**
* add_node - add elements to list.
*
* @head: list
* @str: string
* Description: add elements to list
* Return: return element list
**/
list_t *add_node(list_t **head, const char *str)
{
list_t *copy;
char *c_str;
int i;
if (head == NULL || str == NULL)
{
return (NULL);
}
for (... |
C | #include "timer.h"
static void timer_tick( timer_list_t* list );
static void timer_add_from_cur( timer_list_t* list,timers_t* timer );
static pthread_mutex_t timer_mutex = PTHREAD_MUTEX_INITIALIZER;
/*****************************************************************************
: timer_add
: ʱڵӽ
... |
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 i,n,sum;
char str[3];
scanf("%d", &n);
for (i=1;i<=n;i++)
{
scanf("%s",str);
sum=str[0]+str[1]+str[2];
printf("%d\n",sum);
}
return 0;
}
|
C | #include "fmi/fmiFunctions.h"
#include "HopsanEssentials.h"
#include "ComponentSystem.h"
#include "ComponentUtilities/num2string.hpp"
#include "model.hpp"
#include <stdbool.h>
#include <stdio.h>
#include <string>
#include <string.h>
<<<data>>>
#define UNUSED(x)(void)(x)
hopsan::HopsanEssentials gHopsanCore;
typedef... |
C | # include <stdio.h>
# include <stdlib.h>
char itoc(int v)
{
if (v < 10)
return v + '0';
else if (v < 36)
return v + 'A' - 10;
else if (v < 62)
return v + 'a' - 36;
else {
fprintf(stderr,"出错了\n");
exit (1);
}
}
int main(int argc, char* argv[])
{
int i=0;
int obase, tbase, onum;
char tnum[... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/file.h>
#include <sys/wait.h>
#include <limits.h>
/**** esercizio 14 ***
è dato il tipo dati contact_type, dovrebbe servire ad implementare una rubrica telefonica... |
C | #include <stdio.h>
#include <conio.h>
int main(){
double L, K;
printf("Coloque um valor em Libras: ");
scanf("%lf", &L);
K = L * 0.45;
printf("O valor em Quilogramas e: %.2lf", K);
getch();
return 0;
}
|
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 | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* exec_operations.c :+: :+: :+: ... |
C | #include <stdio.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#define COPYSIZE (1024*1024) // 一次拷贝1M大小(因为程序要用它来计算off值,所以必须是4096的整数倍)
int main(int argc, char const *argv[])
{
int fin, fout;
void *src, *dst;
siz... |
C | #include<stdio.h>
void main()
{
int n,i,j=0;
printf("Enter no. of processes:");
scanf("%d",&n);
int Arr[n],BT[n],Bt[n],Ct[n],count=0;
printf("Enter the Arrival time & Burst time for:-\n");
for(i=0;i<n;i++) {
printf("Process (%d): ", i+1);
scanf("%d %d",&Arr[i],&BT[i]);
printf("\n");
... |
C | //
// ported from https://github.com/Force67/rpftool with XBOX360 define
//
#pragma once
//------------------------------------------------------------
inline void DecodeDXT1(const uint8_t *data, uint8_t *pixData, int width, int height)
{
typedef uint8_t byte;
typedef uint16_t ushort;
typedef uint32_t ui... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstnew.c :+: :+: :+: ... |
C | #include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <linux/i2c-dev.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <assert.h>
#include "i2c.h"
#define DEV_ADDR 0X48
int fd;
int file;
void
sign... |
C | /*
* Copyright (c) 2013,
* National Instruments Corporation.
* All rights reserved.
*/
#include <stdio.h>
#include <time.h>
#include "AIO.h"
#include "MyRio.h"
#if !defined(LoopDuration)
#define LoopDuration 60 /* How long to output the signal, in seconds */
#endif
/**
* Overview:
* Demonstrates using the... |
C | #include<stdio.h>
#include<string.h>
void reverse(char str[ ]) {
int left = 0;
int right = strlen(str) - 1;
while (left < right) {
char tmp = str[left];
str[left] = str[right];
str[right] = tmp;
left++;
right--;
}
}
void reverseString(char str[]) {
int len = strlen(str) - 1;
if (len == 0 || len == 1... |
C | #include <stdio.h>
void trick1()
{
int arr[] = {1, 2, 3};
int *ptr;
ptr = arr;
printf("arr[0] = %d, arr[1] = %d, arr[2] = %d, ptr = %p, *ptr = %d\n",
arr[0], arr[1], arr[2], ptr, *ptr);
*ptr++ = -1;
printf("arr[0] = %d, arr[1] = %d, arr[2] = %d, ptr = %p, *ptr = %d\n",... |
C | /*
char ַ
short
int
long
long long
float ȸ
double ˫ȸ
*/
//1.ٶ2015ϵͳDZ⣺
#include <stdio.h>
int check_sys(){
int i = 1;
return (*(char *)&i);
}
int main(){
int ret = check_sys();
if (ret == 1){
printf("С\n");
}
else{
printf("\n");
}
system("pause");
return 0;
}
//2.
#include <stdio.h>
int check_sy... |
C | #include "mystring.h"
/*
* Compares two strings lexically.
* If a is greater than b it returns Greater
* If a is equal to b it returns Equal
* If a is smaller than b it returns Smaller
* If a is a prefix of b and not equal to b, a is considered smaller
* The empty string is smaller than all other strings... |
C | #include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
int main(){
char pai[52][2];
int x, i = 0, y;
char temp[4];
for(x = 0; x < 13; x++){
for(y = 0; y < 4; y++){
pai[x+13*y][0] = x;
pai[x+13*y][1] = y;
}
}
srand(time(NULL));
whi... |
C | #include <stdio.h>
int main() {
// ǽ 1 - 1
short i; // short Ÿ Ѵ.
i = 32767; //i 32767 ´
printf("20184071 赵\n");
printf("i=%d\n", i); // ڸ Ͽ i Ѵ.
printf("i=%o\n", i);// 8 ڸ Ͽ i Ѵ.
printf("i=%x\n", i);// 16 ڸ Ͽ i Ѵ.
return 0; //main Լ ۵Ǿ 0 Ѵ.
}
|
C | //
// main.c
// LinkedList
//
// Created by Luca Pascarella on 4/10/19.
// Copyright © 2019 Luca Pascarella. All rights reserved.
//
#include <stdio.h>
#include "ll.h"
int main(int argc, const char * argv[]) {
char test1[] = "1 ";
char test2[] = "2 ";
char test3[] = "3 ";
char test4[] = "4 ";
... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include "utils.h"
#include "constants.h"
#include "transaction.h"
int main (int argc, char **argv){
char *fileName;
char *client_id;
if(argc != 3){
fprintf(stderr, "Wrong number of parameters. Expec... |
C | #include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <graphics.h>
#include <math.h>
#include <dos.h>
int x[10][4], y[10][4], n = 0;
void bezier (){
int i, j;
double t;
char coord[10];
for(j=0;j<n;j++){
for (t=0.0;t<1.0;t+=0.001){
double xt = pow (1-t, 3) * x[j][0] + 3 * t * pow (1... |
C | /****************************************
*Name : reg.c
*Data : 2020.8.12
*Description : 注册功能实现
*Author : 万家庆
*Modification: 无
*
****************************************/
#include<stdio.h>
#include<string.h>
#include"client.h"
#include"reg.h"
#include"msg.h"
extern msg_t msg;
/*******... |
C | #include <stdlib.h>
#include <stdio.h>
#include "queue.h"
typedef struct node{
void * data;
struct node * next;
} NODE;
struct queue {
int size;
NODE *head;
};
void printQueue(queue_t queue);
int main() {
int x = 5;
int y = 6;
int z = 7;
int a = 8;
int b = 9;
int c = 10;
void *ptr;
q... |
C | #include "utils.h"
/* flag = 0 -> TCP
* flag = 1 -> UDP */
void client_function(int port, char* hostname, char flag) {
int sockfd, n;
struct sockaddr_in serv_addr;
struct hostent *server;
char buffer[256];
/* Create a socket point */
if (flag) {
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
} else {
s... |
C | #include <stdio.h>
int main()
{
printf("I have $20. I can buy one chocolate bar ($10 each) and two packs of candy ($4 each).");
}
|
C | #include <Windows.h>
#include <stdio.h>
#include <unistd.h>
#define Max_Sem 4
#define Thread_Num 8
HANDLE Semaphore;
void ThreadProc(LPVOID);
int Thread_ID[8];
int main( void )
{
HANDLE Thread[Thread_Num];
DWORD ThreadID;
int i;
Semaphore = CreateSemaphore(NULL,Max_Sem,Max_Sem,NULL);
if (Sema... |
C | #include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
int main(void){
pid_t child;
int dumb;
if(child=fork()){
fprintf(stderr,"\nFork devolvio %d por tanto soy el padre con ID = %d",child,getpid());
dumb=wait();
}
else{
fprintf(stderr,"\nFork devolvio %d por tanto soy... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* printf_stuff.c :+: :+: :+: ... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* convert_u_unsigned_decimal_number.c :+: :+: :+: ... |
C | #include "menu.h"
#include <time.h>
#include <stdlib.h>
#include <string.h>
/**
* reads the leftover bytes from stdin and throws them away, resetting
* the error state
**/
static void clear_buffer(void) {
int ch;
while (ch = getc(stdin), ch != '\n' && ch != EOF)
;
clearerr(stdin);
}
/**
* func... |
C | #include "Har_LED.h"
void Sys_LED_PinInit()
{
GPIO_InitTypeDef GPIO_InitStructure;
/* GPIOE Periph clock enable */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
... |
C | //Warning! this file assumes rounding to -\infty
#ifndef INTERVALS_H_
#define INTERVALS_H_
#include "control_types.h"
typedef __plant_precisiont control_typet;
control_typet _zero = 0.0; //added in by EP
control_typet _one = 1.0;
struct intervalt
{
control_typet low;
control_typet high;
};
control_typet _dbl_... |
C | #include "rr_array.h"
#include "rr_malloc.h"
array_t *
array_create(unsigned long n, size_t s) {
array_t *a;
unsigned long initial_number; /* initial number of elements in array, 1 by default */
a = rr_malloc(sizeof(array_t));
if (a == NULL) {
return NULL;
}
initial_number = n==0 ? 1 ... |
C | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <unistd.h> /* getopt, ssize_t */
#define SIZE_OF_BUFFER 128
void generate_word(char *word)
{
memset(word, 0, sizeof(word));
int length = rand() % 10 + 1, ... |
C | #include <stdio.h>
#include <stdlib.h>
char main()
{
char i;
do{
printf("GIVE ME A FUCKING SYMBOL \n");
scanf("%c",&i);
}while(i<0 || i>127);
if(i>=48 && i<=57)
printf("it's a digit\n");
if(i>=97 && i<=122)
printf("it's a small letter\n");
if(i>=65 ... |
C | #ifndef P2P_CHAT_LOGGING_H
#define P2P_CHAT_LOGGING_H
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <time.h>
#include <sys/timeb.h>
#define LOGBUF 1024
#define log_debug(msg, args...) log_msg(DEBUG, msg, ##args)
#define log_info(msg, args...) log_msg(INFO, msg, ##args)
#define log_warn(msg, args... |
C | //using variable length argument list
#include <stdio.h>
#include <stdarg.h>
double average(int i, ...);
int main(void){
double w = 37.5;
double x = 22.5;
double y = 1.7;
double z = 10.2;
printf("%s%.1f\n%s%.1f\n%s%.1f\n%s%.1f\n", "w = " ,w,"x = ",x,"y = " ,y,"z = ",z);
printf("%s%.3f\n%s%.3f\n%s%.3f\n" ,"The... |
C | #include "holberton.h"
/**
* add - function will add two integers
* Return: function will return value of addition
* @a: holds value of first integer
* @b: holds value of second integer
*/
int add(int a, int b)
{
int v;
v = (a + b);
return (v);
}
|
C | void rotate(int** matrix, int matrixSize, int* matrixColSize){
int i,j;
int mat[matrixSize][matrixSize];
for(i=0;i<matrixSize;i++){
for(j=0;j<matrixSize;j++)
mat[j][i] = matrix[i][j];
}
int m=0,n=matrixSize-1;
for(i=0;i<matrixSize/2;i++){
for(j=0;j<matrixSize;j++){
... |
C | // gcc -I . test.cpp -lOpenCL
#include <CL/cl.h>
#include <stdio.h>
#include <stdlib.h>
#define MAX_SOURCE_SIZE (0x100000)
float util_integrate(float a, float b, float n, char* f) {
char* source_str;
size_t source_size;
int i = 0;
float dx = (b-a) / (n*1.0);
float *results = (float*) malloc(n * s... |
C | #include <stdio.h>
#include "one_duplicate.h"
int main() {
static const int ARRAY_SIZE = 5;
static const int array[] = {2, 1, 3, 4, 3};
int r = one_duplicate(array, ARRAY_SIZE);
printf("%d", r);
return 0;
}
|
C | #include "timer.h"
volatile unsigned char pauseTrame;
volatile unsigned char pauseCalcul;
void initTimer()
{
INTCON1bits.NSTDIS = 1;
//Activation du Timer trame US
T1CONbits.TON=1; //Demarrage du timer
T1CONbits.TCS = 0;
T1CONbits.TSIDL=1;
T1CONbits.TGATE=0;
T1CONbits.TCKPS=0b01;
IFS0bits.T1IF = 0;/... |
C | #include<stdio.h>
int main()
{
int time[48]={0},i,n,prime_time,p,m=0,a;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d %d",&p,&a);
time[p-1] += a;
}
for(i=0;i<48;i++)
{
if(m<time[i])
{
m = time[i];
prime_time = i;
}
}
prin... |
C | /**
* Exercice 1.4
*
* Write a program to print
* the corresponding Celsius to Fahrenheit
*
**/
#include <stdio.h>
void main()
{
float fahr, celsius;
int lower, upper, step;
lower = 0;
upper = 300;
step = 20;
printf("+------------+\n");
printf("| C | F |\n");
printf("|... |
C | #include "stdio.h"
#define N 25 // maximum of 25 elements in vector
extern int asm_sum_e(int n,int* v); // sum elements, returns result
extern void asm_mul_e(int n,int* v1,int* v2); // multiply element by element, returns results in v1
// struct for data values
struct data
{
int n;
int scale;
int x[N]... |
C | #include<stdio.h>
void main()
{
int a[10],i,j,d,temp;
printf("enter limit");
scanf("%d",&d);
printf(" enter the number");
for(i=0;i<d;i++)
{
scanf("%d",&a[i]);
}
printf("sorted array");
for(i=0;i<d;i++)
{
for(j=1;j<d;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}}
}
for(i=0;i<d;i++)
{
printf("%d\d",a[i]);
}
... |
C | #include <assert.h>
#include <stdlib.h>
#include "utf8.h"
Utf8_Chunk utf8_encode_rune(uint32_t rune)
{
const uint8_t b00000111 = (1 << 3) - 1;
const uint8_t b00001111 = (1 << 4) - 1;
const uint8_t b00011111 = (1 << 5) - 1;
const uint8_t b00111111 = (1 << 6) - 1;
const uint8_t b10000000 = ~((1 << 7)... |
C | /*
当选择了数组的一个数, 不能选择相邻的数, 能相加的最大值
*/
#include <stdio.h>
int max(int x, int y){
/*
* 条件运算符要求有3个操作对象,称三目(元)运算符
* 一般形式为:表达式1 ? 表达式2 : 表达式3;
*/
return (x>y)?x:y;
}
int rec_opt(int *arr, int i){
if (i == 0) return *arr;
else if (i == 1) return max(*arr, ++*arr);
else{
int a = rec_opt(arr, i-2) ... |
C | #include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "ipc.h"
#define MKFIFO_PATH "/tmp/mkfifo"
#define MKFIFO_PATH_LEN 32
struct mkfifo_posix_ctx
{
int fd;
void *private_data;
char path[MKFIFO_PATH_LEN];
ipc_recv_cb *cb;
};
static void *mkfifo_init_(struct ipc *ipc,uint16_t port,... |
C | #include <stdio.h>
#include <stdlib.h>
void imprimematriz(int** v, int m, int n);
int BuscaNaMatriz(int** v, int m, int n, int x);
int main () {
int m, n, i, j, x;
int** v;
scanf("%d %d", &m, &n);
if (m != 0 && n != 0) {
v = malloc(sizeof(int*) * m);
for (i = 0; i < m... |
C | void mx_printchar(char c);
void mx_print_alphabet(void) {
for (int i = 0; i <= 25; i++) {
if (i % 2 == 0)
mx_printchar(i + 65);
else
mx_printchar(i + 97);
}
mx_printchar('\n');
}
|
C | #include <stdlib.h>
#include <stdio.h>
#include "./abb.h"
#include "./listaDupla.h"
#include "./vetor.h"
#include "./config.h"
#include <time.h>
void percorrer_arvore(no *raiz, no *vetor[], int *posicao)
{
if (raiz == NULL)
{
// printf("RAIZ NULA!");
return;
}
if (raiz != NULL)
{
percorrer_arvo... |
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>
#include <dirent.h>
#include <unistd.h>
#include <sys/uio.h>
#include <sys/stat.h>
#include <fcntl.h>
#define BUFFER_SIZE 512
char* concat(char *s1,... |
C | #include <stdio.h>
#include <string.h>
#define min_to_max 0
#define max_to_min 1
void print_int_array(int *a, int len)
{
int i;
for (i = 0; i < len; i++)
{
printf("%d ",*(a + i));
}
printf("\n");
}
void bubbling_int(int *a, int len, int arrangement)
{
int i, j;
int temp;
for... |
C | //Even numbers in the interval
#include<stdio.h>
int main()
{
int int1,int2,itr;
scanf("%d %d",&int1,&int2);
for(itr=int1+1;itr<int2;itr++)
{
if(itr%2==0)
printf("%d ",itr);
}
return 0;
}
|
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
void merge(int *, int, int);
/**
* Merge sort algorithm.
*
* @param int input Array to sort
* @param int n Number of data in search array
*
* @return void
*/
void merge_sort(int *data, int start, int end)
{
if (start == end) {
return;
}... |
C | #include <stdio.h>
int main()
{
double a=-0.0123456789,b=12.3456789,c=1.23456789,d=123456789;
printf("%f\n%Lf\n%e\n%g\n\n",a,a,a,a);
printf("%f\n%Lf\n%e\n%g\n\n",b,b,b,b);
printf("%f\n%Lf\n%E\n%G\n\n",c,c,c,c);
printf("%f\n%Lf\n%e\n%g\n\n",d,d,d,d);
}
#if(0)
结果
-0.012346
-0.012346
-1.234568e-002
-0.0123457
12.... |
C | /* main.c - Foundation semaphore test - Public Domain - 2013 Mattias Jansson
*
* This library provides a cross-platform foundation library in C11 providing basic support
* data types and functions to write applications and games in a platform-independent fashion.
* The latest source code is always available a... |
C | int singleNumber(int* nums, int numsSize) {
int i, odd = 0;
for (i = 0; i < numsSize; i++) {
odd = odd ^ nums[i];
}
return odd;
}
|
C | /**********************************************************************************
* File: timers.h
*
* Author: Ahmed Eldakhly
*
* Comments: it contains prototypes and enums of all timers peripherals.
*
* Revision history: 25/2/2020
*
***************************... |
C | #include <stdio.h>
int main(void) {
int initial, extra, rate, total, drank = 0;
scanf("%d %d %d", &initial, &extra, &rate);
total = initial + extra;
while(total >= rate) {
total -= rate;
drank++, total++;
}
printf("%d\n", drank);
return 0;
} |
C | /*
MIT License
Copyright (c) 2017 Keith J. Cancel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish... |
C | //Implementing the Linked list
#include<stdio.h>
#include<malloc.h>
struct node
{
int info;
struct node *link;
}*start;
void create_list(int data);
void addatbeg(int data);
void addafter(int data,int pos);
void display();
void search(int data);
void del(int m);
void main()
{
int m,n,i,choice,position... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpyi.c :+: :+: :+: ... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hex.h"
//
// Return Value: NULL on success, error message on error
//
const char *parseHex(const char *hexString, unsigned char **outBuffer, size_t *outLength)
{
size_t searchLength = strlen(hexString);
if(searchLength % 2) return "the string di... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* definition2.c :+: :+: :+: ... |
C | #include<stdio.h>
#include<string.h>
int main(int argc, char *argv[]){
int i,n;
char a[] = "abcdefgh";
char b[11];
n = strlen(a);
for (i = n-1; i >= 0; i--){
b[n-1-i] = a[i];
}
b[n] = '\0';
printf("逆読み%s\n", b);
return 0;
} |
C | // Sentença dançante - ex14
#include <stdio.h>
#include <ctype.h>
void dancante(char *str)
{
int i, caixa = 1;
for(i = 0; str[i]; i++)
{
if( (str[i] >= 65 && str[i] <= 90)
|| (str[i] >= 97 && str[i] <= 122) )
{
if(caixa)
{
str[i] = toupper( str[i] );
caixa = 0;
}
else
... |
C | #include <stdio.h>
main() {
char str[] = "Hello";
int i;
printf("%s\n", str); // первое Hello
for (i = 0; str[i] != '\0'; i++) // второе Hello
putchar(str[i]);
printf("\n");
}
|
C | #include <stdlib.h>
#include <stdio.h>
#include "dominion.h"
int main(){
int i;
int handPos = 0;
int pass = 1;
int player = 0;
int test=0;
struct gameState state, tempState;
int k[10] = {smithy, great_hall, gardens, minion, mine, cutpurse,
sea_hag, tribute, adventurer, council_room};
initializeGame(2,... |
C | #include <stdio.h>
#include "barrier_counter.h"
void barrier_counter_init(barrier_counter_t *barrier, unsigned required, const char* id)
{
for(int i=0; i<8; i++)
barrier->id[i] = id[i];
barrier->arrived = 0;
barrier->required = required;
barrier->state = LOCKED;
barrier->cycle = 0;
pthread_mutex_init(&... |
C | #include "map.h"
/*
* split()
* splits @line along @delims
* returns a pointer to a string array with the results
* (remember to free!)
* supports an arbitrary number of splitees
*
*/
char **split(char *line, char *delims)
{
int i = 0;
// first pass to find necessary length
char oof[strlen(lin... |
C |
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
int a[10],l;
for(int i=0;i<10;i++)
a[i]=rand()%100;
for(int i=0;i<10;i++)
printf("%d ",a[i]);
l=a[0];
for(int i=0;i<10;i++)
if(a[i]>l)
l=a[i];
printf("Largest is %d",l);
return 0;
}
|
C | main()
{
float a[1000],b[1000];
int n,m,i,j,k;
float sum;
scanf("%d",&n);
a[0]=2;
a[1]=3;
b[0]=1;
b[1]=2;
for(i=0;i<n;i++)
{
sum=0;
//printf("%f",sum);
scanf("%d",&m);
// for(j=0;j<2;j++)
// sum=sum+(float)(a[j])/(float)(b[j]);
for(j=... |
C | #include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
int main(){
int pipefd1[2], pipefd2[2], lenSon, lenFather;
pid_t pid;
char messageSon[20] = "Hi father", messageFather[20] = "Hi son!", empty[20];
lenSon = strlen(messageSon);
lenFather = strlen(messageFather);
if (pipe(pipefd1) ||... |
C | /*
Author: Chen Liang
Description: Write a program to compute the number
of seconds passwd since the beginning
of the current month. Use the following:
- localtime()
- difftime()
- mktime()
Date: 25th Apr 202... |
C | /*
* mario.c
* creates half pyramid using hashes (#)
* prompt user for pyramid height, <= 23
* reprompt if not non-negative integer
* print pyramid, aligning bottom-left corner
*
* Author: wtamura
* Date: 2/10/16
*/
#include <stdio.h>
#include <cs50.h>
int main(){
int height, hash, sp... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.