language large_stringclasses 1
value | text stringlengths 9 2.95M |
|---|---|
C | #include <stdio.h>
#include <stdlib.h>
void digitCount(int num, int * digitNum){
int counter =0;
while(num >0){
counter++;
num /= 10;
}
*digitNum = counter;
}
int main()
{
int n, digitno=0;
scanf("%d", &n);
digitCount(n, &digitno);
printf("%d", digitno);
}
|
C | /* ref.c */
/* OCaml の 参照を C で表現する */
int p = 5;
int q = 2;
int *refp = &p;
int *refq = &q;
*refq = *refp;
printf("%d %d", p, q);
|
C | #include "philosophers.h"
void print_message(t_philo *philo, char *msg)
{
sem_wait(philo->print);
printf("%lld %d %s\n", time_now() - philo->data->start_time,philo->pos, msg);
sem_post(philo->print);
}
void philo_cycle(t_philo *philo)
{
sem_wait(philo->forks);
print_message(philo, "has taken a fork");
sem_wait(... |
C | #include "analysis.h"
void cal_kron_flops(
int nrowA, int nrowB,
int ncolA, int ncolB,
double *pflops_total,
double *pflops_method1,
double *pflops_method2 )
{
int nrowX = ncolB;
int ncolX = ncolA;
int nrowY = nrowB;
int ncolY = nrowA;
/*
% ----------------------... |
C | #include<stdio.h>
#include<string.h>
struct employee{
int code;
float salary;
char name[30];
};
void main(){
struct employee bhanu = {100, 34.23, "Bhanu"};
struct employee rohan = {101, 30.23, "Rohan"};
struct employee vikas = {102, 31.23, "Vikas"};
printf("-------------------------------... |
C | /*Задача 9.
Напишете по 2 тройни цикъла (един и същи код) за масивите.
Хайде да го изнесем във функция.*/
#include <stdio.h>
int arr[10][10][10];
void fillArray( int a[][10][10]){
int b=0;
for(int i=0; i<10; i++){
for(int j=0;j<10;j++){
for(int k=0;k<10;k++){
a[... |
C | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
void mergeSort(int *vetor, int posicaoInicio, int posicaoFim) {
int i, j, k, metadeTamanho, *vetorTemp;
if(posicaoInicio == posicaoFim) return;
metadeTamanho = (posicaoInicio + posicaoFim ) / 2;
mergeSort(vetor, posicaoInicio, metadeTamanho);
... |
C | # include <stdio.h>
# include <stdlib.h>
struct Stack{
int top;
int size;
int *arr;
};
struct Stack *createStack(int size){
struct Stack *stack;
stack = (struct Stack*)malloc(sizeof(struct Stack));
stack->top = -1;
stack->size = size;
stack->arr = (int *)malloc(stack->size * sizeof(str... |
C |
#include<stdio.h>
#include<stdbool.h>
int stringLength(char s[]){
int c=0;
while(s[c]!='\0'){c++;}
return c;
}
bool checkPalindrome(char s1[]){
int i,j;
for(i=0, j=stringLength(s1)-1;i<j;i++,j--){
if(s1[i]!=s1[j]){
return false;
}
}
return true;
}
void main(){... |
C | /*
** EPITECH PROJECT, 2020
** event.c
** File description:
** main of event structures
*/
#include "runner.h"
void window_event(head_t *head, sfEvent event)
{
if (event.type == sfEvtClosed)
sfRenderWindow_close(head->window);
}
void game_event(head_t *head, event_t *event, sfEvent sf_evt)
{
if (sf_e... |
C | #include <stdio.h>
#include <stdlib.h>
int main()
{
int i,n,t,k;
scanf("%d",&n);
int v[n];
for(i=0;i<n;i++)
scanf("%d",v+i);
for(i=0;i<n;i++)
printf("%d ",v[i]);
printf("\n");
scanf("%d",&t);
int w[n+t];
scanf("%d",&k);
//
for(i=0;i<k;i++)
w[i]... |
C | /***************************************************************************/
/* */
/* STRSHL.C */
/* */
/* Copyright (c) 1991 - Microsoft Corp. */
/* All rights reserved. */
/* Microsoft Confidential */
/* ... |
C | #include<stdio.h>
long long int gcd(long long int,long long int);
long long int a[10000000];
long long int gcd(long long int x,long long int y)
{
if(x==0)
return y;
else if(x>y)
return gcd(y,x);
else return gcd(x,y%x);
}
int main()
{
long long int t,i;
scanf("%lld",&t);
while(t>0)
{
long long int n,real=0;
scanf("%lld"... |
C | #include<stdio.h>
void dfs(int n,int cost[10][10],int u,int s[])
{
int v;
s[u]=1;
for(v=1;v<=n;v++)
if(cost[u][v]==1 && s[v]==0)
dfs(n,cost,v,s);
}
void main()
{
int n,cost[10][10],s[10],i,j,connected, flag;
printf("enter the number of vertices:");
scanf("%d",&n);
printf("enter the adjacency matrix\n");
for(i=1;i<=n;i+... |
C | /********************************************
* file name: writer.c
* author: kari.zhang
* date:
*
* modifications:
* 1. Review code @ 2015-11-25 by kari.zhang
*
********************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#inclu... |
C | //
// fdef_int.c INT functions for default number format
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT license.
//
#include "precomp.h"
//
// Default big-number format:
// INT objects are stored in two parts:
// a SYMCRYPT_FDEF_INT structure
// an array of UINT32; the # elements in... |
C | #include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
unsigned int samplerate = 44100;
#define channel 1
#define bitdepth 16
struct Wave{
int type;
double frequency, velocity[2];
} sound[100];
double length = 3;
void read_wave(F... |
C | #include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/wait.h>
#include<readline/history.h>
int main() {
printf("command line - max size of your command is 50 characters\n");
while (1){
char in[50];
printf("->");
scanf("%[^\n]%*c", in);
char* ne... |
C | Escreva um programa que desenhe uma cruz nas diagonais utilizando a função void cruz(int N);
O asterisco (carácter '*') deve ser usado para desenhar a cruz
Hífen (carácter '-') deve ser usado como o separador.
Input: Insira um numero > 2 para fazer uma cruz
4
Output: *--*
-**-
-**-
... |
C | #include <stdio.h>
#include <stdlib.h>
#include "Alumno.h"
int main()
{
//IMPORTANTE: ABRIR ARCHIVO - MODIFICAR ARCHIVO - BORRAR ARCHIVO
FILE* archivo; //para trabajar con archivos hay que crear la estructura FILES. Nos da acceso al archivo
// char mensaje[50];
int i = 0;
eAlumno* lista[10]... |
C | #include<stdio.h>
int main(int argc, char **argv){
if(argc != 2){return 1;}
int wys = atoi(argv[1]);
int i, j, k;
for(i=1, k=1;k<= wys;i+=2,k++){
for(j=(wys*2)-i;j>0;j-=2){
printf(" ");
}
for(j=0;j<i;j++){
printf("*");
}
printf("\n");
}
return 0;
}
|
C | #include <stdio.h>
#include <inttypes.h>
#include "TAP_LookUpTable.h"
#include "TAP.h"
#include "global.h"
#include "TAP_StateTable.h"
#include "jtagLowLevel.h"
extern TapState currentTapState;
/* @desc return the name of TAP state in string instead of number(enum)
@retval TAP state in string
*/
char *getTa... |
C | #include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
int table[35][35];
int N,i,j,col,row;
int MAX;
char ele[35][35][3005];
while(scanf("%d",&N),N){
memset(ele,0,sizeof(ele));
for(i=0;i<N;i++)
for(row=i,col=0;row>=0;col++,row--)
scanf("%d",&table[row][col]);
for(i=1;i<N;i++)
for(row=... |
C | /*
** EPITECH PROJECT, 2020
** my_compute_square_root
** File description:
** Calculate power root
*/
int my_compute_power_rec(int nb, int p);
int my_compute_square_root(int nb)
{
if (nb == 1)
return (1);
if (nb < 1)
return (0);
for (int i = 1; i <= nb/2; i++) {
if (i * i == nb)
... |
C | // lesson nine on the c language
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct product {
float price;
char productName[30];
struct product *next;
};
struct product *pFirstNode = NULL;
struct product *pLastNode = NULL;
void createNewList(){
struct product *pNewStruct = (struct product *) ma... |
C | #ifndef CACHEGRAND_DOUBLE_LINKED_LIST_H
#define CACHEGRAND_DOUBLE_LINKED_LIST_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct double_linked_list double_linked_list_t;
typedef struct double_linked_list_item double_linked_list_item_t;
struct double_linked_list_item {
double_linked_list_item_t *prev;
do... |
C | /*
* @lc app=leetcode.cn id=378 lang=c
*
* [378] 有序矩阵中第 K 小的元素
*
* https://leetcode-cn.com/problems/kth-smallest-element-in-a-sorted-matrix/description/
*
* algorithms
* Medium (63.17%)
* Likes: 657
* Dislikes: 0
* Total Accepted: 78.2K
* Total Submissions: 122.4K
* Testcase Example: '[[1,5,9],[10,1... |
C | /*5. Accept two numbers and print arithmetic and harmonic mean of the two numbers
(Hint: AM= (a+b)/2 , HM = ab/(a+b) ) */
#include <stdio.h>
int main()
{
int n1, n2;
float arithmetic_mean, harmonic_mean;
printf("Enter two numbers : ");
scanf("%d%d", &n1, &n2);
arithmetic_mean = (n1 + ... |
C | /* Name:
* ID:
*/
#include <stdio.h>
#include <stdlib.h>
// #include <string.h>
#include "mergesort.h"
void merge(Entry *output, Entry *L, int nL, Entry *R, int nR) {
int i = 0, j = 0, k = 0;
while(k < nL+nR){
//Get the slot of the those entry
Entry *cL = L+i;
Entry *cR = R+j;
Entry *cO ... |
C | #include <stdio.h>
#include <mpi.h>
int my_id,nproc,result;
char name[50];
int main(int argc, char** argv){
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD,&my_id);
MPI_Comm_size(MPI_COMM_WORLD,&nproc);
MPI_Get_processor_name(name,&result);
name[result]='\0';
printf(" Hola mundo yo soy %d de %d corrie... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* search_dict.c :+: :+: :+: ... |
C | // write a program to detect a loop in a linkedlist.
// once loop is detected we need to find the joint node
// After finding the joint node remove the loop withe joint node
#include<stdio.h>
#include<stdlib.h>
struct node {
int data;
struct node *next;
};
void push(struct node **headRef,int data);
void pri... |
C | #include <stdio.h>
int main(void)
{
double pi = 3.14159;
printf("%6.0\n",pi);
printf("123456\n");
return 0;
}
|
C | #include<stdio.h>
int main()
{
int ch;
printf("Enter your choice:");
scanf("%d", &ch);
switch(ch)
{
case 1:
printf("Pizza,Rs-239");
break;
case 2:
printf("Burger, Rs 129");
break;
case 3:
printf("Pasta, Rs 179");
break;
case 4:
printf("French Fries, Rs 99");
break;
case 5:
pri... |
C | /* Stubs imitating the external functions to test handling of the calls to
* such functions.
*
* gcc -c -o stubs.o stubs.c */
#include <stdio.h>
#include <stdlib.h>
void *
vmalloc(unsigned long size)
{
printf("[STUB] vmalloc(%lu)\n", size);
return malloc(size);
}
void
vfree(void *addr)
{
printf("[STUB] vfree(... |
C | #include "key.h"
// KeyValue ڷ 뿡 ̴.
Key* Key_new(void) {
Key* _this = NewObject(Key);
_this->_value = NULL;
return _this;
}// ⺻
Key* Key_newWith(KeyValue aValue) {
Key* _this = NewObject(Key);
_this->_value = aValue;
return _this;
}
// Ű ־
void Key_delete(Key* _this) {
free(_this);
}
void Key_setValue(... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_f2.c :+: :+: :+: ... |
C | /*
* Pthread Joinig
* page 30
*
*/
#include <pthread.h>
#include <stdio.h>
#define NUM_THREADS 3
void *BusyWork(void *null){
int i;
double result= 0.0;
for(i=0; i< 1000000; i++)
result = result + (double)random();
printf("result = %e\n", result);
pthread_exit((void*) 0);
}
int main(int argc, char* a... |
C | #include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{
int isstack = 222;
switch(vfork())
{
case -1:
exit(-1);
case 0:
sleep(3);
write(STDOUT_FILENO, "child executing\n", 16);
isstack *= 3;
_exit(EXIT_SUCCESS);
default:
write(STDOUT_FILENO, "parent exec... |
C | #include "queue.h"
#include <stdlib.h>
void main(int argc, char const *argv[])
{
Queue q ;
QueueEntry e ;
CreatQueue(&q);
Append(e,&q);
}
void CreatQueue(Queue *pq)
{
pq->front = 0 ;
pq->rear = -1 ;
pq->size = 0 ;
}
void Append(QueueEntry e , Queue *pq)
{
if (pq->rear == MAXQUEUE)
{
pq->rear = 0
}
els... |
C | //
// AOJ0027.c
//
//
// Created by n_knuu on 2014/02/22.
//
//
#include <stdio.h>
int main(void){
int i=0,j,k,sum,n,month[100],date[100],md[12]={31,29,31,30,31,30,31,31,30,31,30,31};
while(1){
scanf("%d %d",&month[i],&date[i]);
if(month[i]==0) break;
i++;
}
for(j=0;j<i;j++)... |
C | /* tell.c */
inherit M_COMMAND;
string *usage(void) {
string *lines;
lines = ({ "Использование: сказать [-h] КОМУ ЧТО" });
lines += ({ "" });
lines += ({ "Отправить сообщение указанному игроку. Если вы хотите сказать что-то "
});
lines += ({ "игроку из другого мада, используйте user@MUD. Если в... |
C | /* program for calculating the price of
product after adding the sales tax to
it original price
*/
#include<stdio.h>
void main()
{
float p, tax, tp;
printf("Enter the price: ");
scanf("%f", &p);
printf("Enter the rate of price: ");
scanf("%f", &tax);
tp = p*tax/100;
printf("Price of product = %f", tp);
... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utilsi.c :+: :+: :+: ... |
C | #include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <pthread/pthread.h>
#include <sys/types.h>
#include <sys/select.h>
#include <assert.h>
#include "util.h"
static const int kListenPort = 9527;
struct Child {
pi... |
C | #include "server.h"
#include "utils.h"
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#define USAGE "usage: %s ADDRESS PORT FILE\n"
int main (int argc, char **argv)
{
int fd;
in_addr_t addr;
in_port_t port;
if (argc != 4) {
printf(USAGE, argv[0]);
exit(EXIT_FAILURE);
}
addr = inet_ad... |
C | /*
1.3.Basándose en la pregunta anterior,
¿Cómo podría llegar a la referencia del Nodo a
desde el Nodo b en una sola instrucción?
*/
#include <stdio.h>
#include <stdlib.h>
struct nodo
{
int valor;
struct nodo *next;
} typedef *NODO;
int main()
{
NODO a = (NODO *)malloc(sizeof(NODO));
NODO b = (NODO *)malloc(... |
C | #include "transbank.h"
#include "common.c"
int main()
{
char *portName = select_port();
int retval = open_port(portName, bRate);
if (retval == TBK_OK)
{
printf("Serial port successfully opened.\n");
BaseResponse response = close();
if (response.function == 510)
{
printf("Function: %i\n... |
C | #pragma once
#include <stdint.h>
// All times are in milliseconds.
// The current time is measured from initialization.
typedef struct Timer {
// The time at which the handler will be called.
// timer_start adds the current time to this when the timer is first added.
// You may change this after the time... |
C | #include <errno.h>
#include <signal.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <unistd.h>
#include <sys/time.h>
#include "bmp.c"
#define uchar unsigned char
#define ushort unsigned short
#define ulong unsigned long
//---------------------------------... |
C | /*
有一个分数序列
2/1,3/2,5/3,8/5,13/8
从键盘输入一个数n,输出该序列前n项之和,保留两位小数。
*/
#include <stdio.h>
int main()
{
int num, den, i, n, t;
double sum=0;
scanf("%d", &n);
num = 1;
den = 1;
for (i = 0; i < n;i++)
{
t = num;
num += den;
den = t;
sum += (float)num / den;
}
... |
C | #include<stdio.h>
int main(){
int n,sum=0,temp=4,taxis=0;
scanf("%d",&n);
int arr[5]={0},taxi[n];
for(int itr=0;itr<n;itr++){
scanf("%d",&taxi[itr]);
arr[taxi[itr]]++;
}
for(int itr=0;itr<arr[3];itr++){
taxis = taxis+1;
if(arr[1]>0)
arr[1] = arr[1]-1;
}
for(int itr=0;itr<arr[2];itr... |
C | #include <stdio.h>
#define li long int
int main() {
li m;
int i,a, b, c, num[10] = { 0 };
char mult[10];
scanf("%d %d %d", &a, &b, &c);
m = (li)(a*b*c);
sprintf(mult, "%d", m);
for (i = 0; i < strlen(mult); i++) num[mult[i]-48]++;
for (i = 0; i < 10; i++) printf("%d\n",num[i]);
} |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define KEY 123456
int read_int(FILE *, int);
void encode_image(unsigned char *B, unsigned char *G, unsigned char *R,
int height, int width, char *message);
void convert2pixel(int, unsigned char *);
int read_image(FILE *fpin, unsigned char... |
C | //
// Created by Nylan on 08-05-2021.
//
#ifndef YUKON_GAMEVIEWINTERNALFUNCTIONS_H
#define YUKON_GAMEVIEWINTERNALFUNCTIONS_H
/**
* Writes the column headers for a specified number of
* columns to the specified string
* @param numColumns the number of columns
* @param str the string to which the column headers sh... |
C | #include <stdio.h>
#include <stdlib.h>
int calcstatus = 1;
int poldegree[2][6];
int orderarray[6];
char firstnchar[20];
void copystring(char * source, char * destination);
void shiftbuffer(char * sbuffer, int count);
int isequal(char * stringone, char * stringtwo);
void clearstring(char * clearbuffer);
char * firstn... |
C | /*
Laura Benito Martin 100284695
Rafael León Miranda 100275593
*/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
//Proof and error to know the offsetChosen of the "jump"
#define CHOSEN_OFFSET 300
unsigned char code[] = /* TO DO-- binary code of the exploit previously created ---*/
"\x31\xc... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* all_obj.c :+: :+: :+: ... |
C | /*
* author: Thomas Yao
*/
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "term_enum.h"
#include "term_infos_writer.h"
#include "../utils/utils.h"
struct _term_enum*
term_enum_initial(struct _file_stream* _in, struct _field_infos* _fieldinfos,
int _is_index)
{
struct _t... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* player.c :+: :+: :+: ... |
C | /*
* HighScoress.h
*
* Created on: 21/11/2017
* Author: Daniel Barragán
*/
#ifndef HIGHSCORES_H_
#define HIGHSCORES_H_
#include "DataTypeDefinitions.h"
//indicates the end index of the array
#define ARRAY_END 0
//this indicates the 10 value in ASCII
#define TEN_ASCII 58
//the next variables represents th... |
C | #include<stdio.h>
#include<stdlib.h>
struct node
{
int data;
struct node *link;
};
struct node * root=NULL;
int len=0;
void append();
int find_len();
void display();
void insert_atstart();
void insert_inmiddle();
int main()
{
int choice =0;
while(1)
{
printf("enter your choice\n");
printf("1.append\n2.find_l... |
C | /*
* The instlineMem files (.h,c) are responsible for saving instruction lines to memory.
*/
#include <string.h>
#include "../config.h"
#include "instlineMem.h"
extern int IC;
extern instLine instlineArray[MAX_ARRAY_LENGTH];
extern int LIC;
// Restart global variables
void RestartInstlines()
{
IC = 0;
LIC = 0;
}
... |
C | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "solver.h"
#include "game.h"
#include "parser.h"
#include "main_aux.h"
#include "SPBufferset.h"
/**
* parser summary
*
* A container that takes care of the user input.
* flow:
* 1. The user input reaches the function readComma... |
C | #include <stdio.h>
int main() {
int x;scanf("%d", &x);
int i, j, n;
while(x==1 || x==2 || x==3 || x==4){
switch(x){
case 1:
scanf("%d", &n);
for(i=1 ; i<=n-1 ; i++){
for(j=1 ; j<=n-i ; j++)printf(" ");
for(j=1 ; j<=i ; j++){
printf("%d ", i);
}
printf("\n");
... |
C | #include<stdio.h>
int main(void){
int num;
scanf("%d", &num);
switch(num){
case 1: printf("is 1\n");break;
case 2: printf("is 2\n");break;
case 3: printf("is 3\n");break;
default : printf("defaut\n");break;
}
return 0;
}
|
C | #include<stdio.h>
#define size 20
int stack[size];
int tos=-1;
int g[size][size];
int vis[size];
void push(int item)
{
if(tos==(size-1))
{
printf("The Stack is full.");
}
else
{
stack[++tos]=item;
}
}
int pop()
{
if(tos==-1)
{
return 0;
}
else
{
... |
C | #pragma once
#include "intersections.h"
// CHECKITOUT
/**
* Computes a cosine-weighted random direction in a hemisphere.
* Used for diffuse lighting.
*/
__host__ __device__
glm::vec3 calculateRandomDirectionInHemisphere(
glm::vec3 normal, thrust::default_random_engine &rng) {
thrust::uniform_real_dis... |
C | #pragma once
#pragma warning (disable:4996)
#include <windows.h>
// ȭ ʱȭ, 2
void screenInit();
// ȭ Ŭ
void screenClear();
// Ȱȭ ۿ Ȱȭ ¸ ȯ
void screenFlipping();
// 2 ۸
void screenRelease();
// x, yǥ string
void screenPrint(int x, int y, char* string);
// ȭ鿡
void setColor(unsigned short color); |
C | #include <stdio.h>
int main()
{
int a=10,b=12;
printf("%d\n",a&b);
printf("%d\n",a|b);
printf("%d",a^b);
return 0;
}
|
C | /*/////////////////////////////////////////////////////////////*/
/* 图的深度优先遍历 */
/*/////////////////////////////////////////////////////////////*/
/*
整理优化by:千百度QAIU
QQ:736226400
编译环境:gcc/tcc
2017/10/22
*/
#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
struct node ... |
C | #include "holberton.h"
/**
* string_toupper - changes all lowercase characters of a string to uppercase
* @s: string to change
* Return: changed string
*/
char *string_toupper(char *s)
{
char *x;
for (x = s; *x; x++)
{
if (*x >= 'a' && *x <= 'z')
*x -= 32;
}
return (s);
}
|
C | #include "util.h"
#define MAX 501
// 栈
int stack[501]; // 记录位置
int top = -1; // stack大小
// 返回值
int **ret = NULL;
int *sizes = NULL;
int sz = 0;
void output() {
int *t = (int*)malloc(sizeof(int) * (top+1));
for (int i = 0; i <= top; i++) {
t[i] = stack[i];
}
sizes[sz] = top + 1;
ret[sz++] ... |
C | #include "hyperion.h"
#include <stdio.h>
#include <stdlib.h>
BOOL fileToMem(const char* file_name, struct OpenFile* open_file){
//open input file
verbose("Opening %s\n", file_name);
FILE* f1 = fopen(file_name,"rb");
if(f1 == NULL) {
fprintf(stderr, "Could not open %s\n... |
C | /*****************************************************
* NAME: assignment_5.c *
* *
* AUTHOR: Devarsh Ruparelia *
* *
* EMAIL: devarsh.ruparelia@gmail.com ... |
C | #include <hash_internals.h>
int hashtable_print(t_hash *hash, int (*print_fun)(), int fd, size_t size)
{
const int wfd = fd + 2 * (fd == -1);
const t_node *it;
unsigned int i;
int tmp;
int ret;
i = -1;
ret = 0;
tmp = 0;
while (++i < hash->max_size)
{
it = hash->data[i].head;
if (!it)
tmp = wri... |
C | /**
* Lua binding for Jerasure's Vandermonde Reed-Solomon.
* w must be 8,16,32
* k + m must be <= 2^w
*/
#define LUA_LIB
#include "lua5.2/lua.h"
#include "lua5.2/lauxlib.h"
#include "lua5.2/lualib.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <gf_rand.h>
#include "jerasure... |
C | #include <pthread.h>
#include <inttypes.h>
#include <stdio.h>
int input = 0;
int result1 = 0;
int result2 = 0;
void *
fact_worker1(void * arg)
{
result1 = 0;
for (uint64_t i = 1; i < input / 2; i++)
if (input % i == 0)
result1++;
return NULL;
}
void *
fact_worker2(void * arg)
{
re... |
C | #include <stdio.h>
int main(){
int m1;
scanf("%d", &m1);
int i;
int array1[m1];
for(i = 0; i < m1; i++){
scanf("%d", &array1[i]);
}
int min= array1[0] , max= array1[m1 / 2];
for(i = 0; i < (m1 / 2); i++){
if(min > array1[i]){
printf("%c", ;
}
}
for(i = m1 /2; i < ... |
C | #include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Calificacion de un alumno \n");
int calificacion;
printf("Ingresa la calificacion del alumno sobre 100: \n");
scanf ("%i", &calificacion);
if (calificacion < 60)
printf("Esta reprobado");
else
printf("Esta aprobado"... |
C |
// 4.16 Does the UNIX System have a fundamental limitation on the depth of a directory tree? To find out, write a program that creates a directory and then changes to that directory, in a loop. Make certain that the length of the absolute pathname of the leaf of this directory is greater than your system’s PATH_MAX li... |
C |
/* readfile.c */
/* Read a csv file. */
/* This code is released to the public domain. */
/* "Share and enjoy..." ;) */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
struct col {
char heading[10];
int data[4];
};... |
C | #include <stdio.h>
#define NUM 3
//***************************************************
/**
* 中央
*/
//***************************************************
int main(void)
{
int array[NUM];
int i;
int max, min, median;
printf("整数を3つ入力してください。\n");
for (i = 0; i < NUM; i++)
{
printf("%dつ目... |
C | #include <assert.h>
#include <stdio.h>
#include <stdlib.h>
enum {
NFST = 10
};
char
pi_number() {
// TODO: your code here
}
int
main() {
int i;
char firstdigs[NFST] = {1,1,0,0,1,0,0,1,0,0};
for (i = 0; i < NFST; ++i) {
char nextdig = pi_number();
if (nextdig != firstdigs[i]) {
printf("Error ... |
C | #include<stdio.h>
#include<stdlib.h>
#define OK 1
#define ERROR 0
#define MAX_VERTAX_SIZE 20
typedef char VerElemType;
typedef char ElemType;
typedef struct Graph
{
VerElemType VertaxMatrix[MAX_VERTAX_SIZE];
int AdjacentMatrix[MAX_VERTAX_SIZE][MAX_VERTAX_SIZE];
int VertaxNum;
int EageNum;
}Gra... |
C | #include <stdio.h>
#include <sys/time.h>
#include <signal.h>
#include <unistd.h>
void manejador(int s){
signal(SIGALRM, manejador);
write(1, "ha llegado la señal\n",21);
}
int main(){
struct itimerval timer;
struct timeval valor;
struct timeval temporizador;
valor.tv_sec = 02;
valor.t... |
C | #include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#define RESPONSE_SIZE 1048576
#define REQUEST_SIZE 4096
#define SERV_PORT 9000 /*port*/
int main(int argc, char **argv) {
//basic check of the a... |
C | struct TreeNode
{
// member vars
int val;
TreeNode* left;
TreeNode* right;
// constructor
TreeNode(int val): val(val), left(nullptr), right(nullptr) {}
}; |
C | #include <stdio.h>
enum year {leap, nonleap};
void l(void) {
puts("闰年");
}
void n(void) {
puts("平年");
}
enum year judge(int year) {
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
return leap;
} else {
return nonleap;
}
}
int arr[12] = {31, 28, 31, 30, 31, 30, 31, 31, ... |
C | #ifndef JSONLIB_H
#define JSONLIB_H
typedef enum {
T_STRING = 1,
T_NUMBER,
T_OBJECT,
T_ARRAY,
T_TRUE,
T_FALSE,
T_NULL,
} json_value_t;
typedef struct json_object {
json_value_t object_type;
struct json_object** keys;
struct json_object** values;
size_t kle... |
C | //
// 6502 memory addressing
// Copyright (c) 2019 Kacper Rączy
//
#include "6502/addr.h"
static int full_value(struct mem_addr *maddr, struct memory6502 *memory, uint16_t pos) {
// little endian
uint8_t lsb = memory6502_load(memory, pos);
uint8_t msb = memory6502_load(memory, pos + 1);
uint16_t value = (uint... |
C | #include <stdio.h>
struct packed_struct {
unsigned int:3; //unused bits
unsigned int f1:1;//size of field
unsigned int f2:1;//size of field
unsigned int f3:1;//size of field
unsigned int type:8;
unsigned int index:18;
};
int main(){
struct packed_struct packed_data={.f1=1,.index=200};
packed_data.type=248;
... |
C | //
// Created by Guy Moyal on 20/03/2018.
//
#include "utils.h"
int findLength(int n){
int nLength=0;
while (n > 0){
n=n/10;
nLength++;
}
return nLength;
} |
C | /* copyright rschuitema 2018 */
/*
* Messages can be exchanged between a client and hilt.
* There are 3 types of messages:
* - actions
* - responses
* - events
*
* The actions requested from hilt are always acknowledged with the same id as in the action.
* When an actions requires a response then the response ... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "utilities.h"
void
list_init(
struct listnode **head)
{
*head = NULL;
}
void
list_prepend(
struct listnode **head,
void *data)
{
struct listnode *t = malloc(sizeof(struct listnode));
t->data = data;
t->next = *head;
... |
C | #include <stdio.h>
#include <math.h>
#include "laserdefs.h"
#include <stdlib.h>
int main(void){
scantype sc;
posetype startline,optline,tmpline;
double wmin,wmint;
int i;
sc.x=malloc(10*sizeof(double));
sc.y=malloc(10*sizeof(double));
sc.x[0]=4;
sc.x[1]=4;
sc.y[0]=2;
sc.y[1]=4;
sc.x[2]=8;
sc.x[3]=8;
sc.y[2]=2;
sc.y[3... |
C | #include "doubly.h"
#include <stdio.h>
#include <stdlib.h>
NODE_T* create(const unsigned noOfNodes)
{
NODE_T* head = NULL;
for(int i = 0 ; i < noOfNodes ; i++)
{
int data;
printf("\nEnter data to insert:");
scanf("%d",&data);
head = insert(head, data, i+1);
}
return ... |
C | #ifndef LIBFT_H
# define LIBFT_H
# include <stdio.h>
# include <string.h>
#include <ctype.h>
# include <fcntl.h>
void *ft_memset(void *s, int c, size_t n);
void ft_bzero(void *s, size_t n);
int ft_isalpha(int c);
int ft_isdigit(int c);
int ft_isalnum(int c);
int ft_isascii(... |
C | // TODO, it's very fun to represent the target string
// very smart way to represent DP
// try to solve it in exclusive search way and also the DP.
// DP way, bitmap way
// smart way to represent the original target here
// just be careful~ !!!!
// careful !!
// DP or exclusive search
// not that easy !
// big bitmap ... |
C | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <unistd.h>
char *func[4] = { "Hex","Dec","Oct","Bin" };
int Hex(int num)
{
int position = 0;
char hexadecimal[20] = { 0, };
while (1)
{
int mod = num % 16;
if (mod < 10) //
{
hexadecimal[position] = 48 + mod;
}
else
{ ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.