language large_stringclasses 1
value | text stringlengths 9 2.95M |
|---|---|
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <conio.h>
#include "propietarios.h"
int prop_menu ()
{
int opc;
printf("::::::::::::::::::: MENU DE OPERACIONES :::::::::::::::::::");
printf("\n\n");
printf(" 1- AGREGAR PROPIETARIO\n");
printf(" 2-... |
C | /*
* Multistage graph algorithm implementation in C
* by Shaik Sameer, jan 28 2021
*/
#include <stdio.h>
void solve(int N, int graph[][N+1], int stages)
{
int cost[N+1]; // cost array to store the optimal cost of every vertex to the sink
int d[N+1]; // destination array to store the optimal destination of... |
C | #include<stdio.h>
#include<stdlib.h>
void enqueue();
void display();
void dequeue();
void isEmpty();
void isFull();
int a[10],i=0,e,n,t,front=-1,rear=-1;
main()
{
printf(" 17BCE0042\n");
char option='T';
while(option=='T')
{
printf("\n");
printf("Enter command (17BCE00... |
C | #include <stdio.h>
#include <stdlib.h>
#include "timers_lib.h"
// node of a list (bucket)
struct node_t{
int value;
int hash_code;
struct node_t * next;
};
int MAX_LOCKS=64;
struct HashSet{
//int length;
struct node_t ** table;
int capacity;
int setSize;
__int128 atomic_locks;
int ... |
C | #include <fcntl.h>
#include <unistd.h>
int main(int argc, char** argv) {
int fd1 = open("out.txt", O_RDWR);
char str[] = "xyz";
char c;
write(fd1, str, 1);
read(fd1, &c, 1);
write(fd1, &c, 1);
return 0;
}
|
C | #include "os.h"
#include "reg.h"
#include "string.h"
#include "buffer.h"
void *stdin;
void putchar(char c)
{
while (!(*(USART2_SR) & USART_FLAG_TXE));
*(USART2_DR) = (c & 0xFF);
}
void puts(const char *str)
{
while (*str) {
while (!(*(USART2_SR) & USART_FLAG_TXE));
*(USART2_DR) = (*str & 0xFF);
str++;
}
}
... |
C | /*************************************************************************
> File Name: readdir.c
> Author: jianghechao
> Mail: 591378033@qq.com
> Created Time: Wed 23 Apr 2014 11:39:37 PM CST
************************************************************************/
#include<stdio.h>
#include<dirent.h>
#include<... |
C | #include <stdio.h>
//niz sa ispita
int main() {
int i, niz[100],n,br=1;
printf("Unesite niz: ");
for(i=0;i<100;i++) {
scanf("%d", &niz[i]);
if(niz[i]==-1) break;
}
n=i;
for(i=1;i<n;i++) {
if(niz[i]>niz[i-1]) br++;
}
printf("Ima %d opadajucih podnizova", br);
return 0;
}
|
C | /**
* @chinese
* @file stringchar.c
* @author 胡俊远
* @date Thu Oct 13 10:00:00 2011
*
* @brief 字符串和char处理模块
* @endchinese
*
* @english
* @file stringchar.c
* @author Hu Junyuan
* @date Thu Oct 13 10:00:00 2011
*
* @brief string and char handling module
* @endenglish
*/
#include <sys/times.h>
#in... |
C | /* POJ 1200
* 特别简单的一道Hash
* 认真看题即可
*/
#include <stdio.h>
#include <string.h>
char str[16000001];
char hash[16000000];
int main()
{
int x[26],total;
int n,nc,i,j,key,pow,result;
memset(hash,0,sizeof(hash));
memset(x,-1,sizeof(x));
scanf("%d%d",&n,&nc);
scanf("%s",str);
result=0;
total=0;
fo... |
C | /*
习题3-5 三角形判断 (15 分)
给定平面上任意三个点的坐标(x1,y1),(x2,y2),(x3,y3)检验它们能否构成三角形。
输入格式:
输入在一行中顺序给出六个[?100,100]范围内的数字,即三个点的坐标x
x1,y1,x2,y2,x3,y3
输出格式:
若这3个点不能构成三角形,则在一行中输出“Impossible”;若可以,则在一行中输出该三角形的周长和面积,格式为“L = 周长, A = 面积”,输出到小数点后2位。
输入样例1:
4 5 6 9 7 8
输出样例1:
L = 10.13, A = 3.00
输入样例2:
4 6 8 12 12 18
输出样例2:
Impossible
*/
#in... |
C | #include "holberton.h"
/**
* append_text_to_file - function that appends text to a file
* @filename: file name
* @text_content: text content
* Return: 1 on success, -1 otherwise
*/
int append_text_to_file(const char *filename, char *text_content)
{
int fd, x, i;
if (filename == NULL)
return (-1);
if (text_content == NU... |
C | #include <stdio.h>
#define __USE_XOPEN_EXTENDED
#include <string.h>
#include <faup/hash/hash.h>
#include <faup/hash/htable.h>
struct _foobar_t {
char *name;
int blah;
};
typedef struct _foobar_t foobar_t;
static size_t rehash(const void *e, void *unused)
{
return hash_string(((foobar_t *)e)->name);
}
static b... |
C | #include <unistd.h>
void ft_putchar(char c);
int main(void)
{
char c;
c = 'c';
ft_putchar(c);
}
void ft_putchar(char c)
{
write(1, &c, 1);
}
|
C | /*
Alunos:
Igor Ferreira Murras / DRE: 118156052
Jonathan Suhett Barbêdo / DRE: 120021182
Versão GCC: 10.2.0
*/
#define ANSI_COLOR_RED "\x1b[31m"
#define ANSI_COLOR_GREEN "\x1b[32m"
#define ANSI_COLOR_BLUE "\x1b[34m"
#define ANSI_COLOR_RESET "\x1b[0m"
#include<stdio.h>
#include<stdint.h>
/*... |
C | #ifndef types_h
#define types_h
#include <allegro5/allegro5.h>
#include <string.h>
#include <math.h>
#include "utils.h"
/** Tipo delle funzioni che si occupano di copiare un valore */
typedef void * (* duplicate_function)(void *);
/** Tipo delle funzioni che si occupano di deallocare un valore */
typedef void (* ... |
C | #include "md.h"
#define FILE_PATH_MAX 256
const char *testMdFileName = "test.md";
char fp[FILE_PATH_MAX] = {0};
md_t *md = NULL;
int get_test_md_path(){
int ret = 0;
char *currFilePath = __FILE__;
size_t currFilePathSize = strlen(currFilePath);
int i = currFilePathSize - 1;
size_t dirPathSize = ... |
C | #include <stdio.h>
#include <stdlib.h>
/* Create main funciton */
int main()
{
char CharacterName[] = "John";
int CharacterAge = 35;
/* %s used for characters */
printf("There once was a man named %s\n", CharacterName);
printf("he was %d years old\n", CharacterAge);
/* %d used for integers */
printf("H... |
C | #include <stdio.h>
#include <stdlib.h>
int main(){
int a,b,c;
int tmp;
scanf("%d%d%d", &a,&b,&c);
if( a > b ){ // Worst Case: swapping a with b
tmp = a;
a = b;
b = tmp;
}
if( b > c ){// Worst Case: swapping b(old a) with c
tmp = b;
b = c;
c = tmp;
if(a > b){// Worst Case: swapping old C(now b... |
C | #include <stdio.h>
/* This is a comment. */
int main(int argc, char *argv[])
{
int distance = 100;
// \n is important because otherwise the line will end with a % sign
printf("You are %d miles away.\n", distance);
printf("HELLO HOW ARE YOU\n");
return 0; // The program still works if you delete ... |
C | /* radare - LGPL - Copyright 2007-2015 - pancake */
// TODO: RRef - reference counting
#include <stdio.h>
#define _R_LIST_C_
#include "r_util.h"
inline RListIter *r_list_iter_new () {
return malloc (sizeof (RListIter));
}
void r_list_iter_free (RListIter *list) {
/* do nothing? */
}
RListIter *r_list_iter_get_ne... |
C | #include <stdio.h>
#include <stdlib.h>
#include "holberton.h"
/**
* create_array - create char array and init it with a specific char
* @size: the size of the memory to print
* @c: char to init values to
*
* Return: pointer to array
*/
char *create_array(unsigned int size, char c)
{
char *ptr = NULL;
unsigned i... |
C | /**
* usual head files
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sqlite.h>
/*********************************************************
************** Function Declaration ***************
*********************************************************/
static int cb(... |
C | // ADS 2020 - LINGUAGEM DE PROGRAMAO
// CAPTULO 07 - EXERCCIO 05
/* Solicitar um nome e mostrar a primeira, ultima, a quarta, da primeiro
terceira, da primeira ultima. Mostrar a posio de cada letra no vetor.*/
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<time.h>
#include<locale.h>
#include<string.... |
C | #include<stdio.h>
#include<stdlib.h>
struct Node
{
int value;
struct Node *leftChild,*rightChild;
};
struct Node* root = NULL;
struct Node* temp = NULL;
int leafcount =0;
int height=0,max=0,internalNode = 0,level=0,currentlevel=0;
void insert(struct Node* rootnode, struct Node* newnode)
{
if(rootnode->v... |
C | /*Programa que permita o mantemento dun arquivo de libros (altas, baixas, modificacins e consultas)
Os datos de cada libro estan grabados nun arquivo
binario (libros.dat)no que os datos de cada rexistro
estn nunha estructura cos seguintes campos:
cdigo de libro 5 caracteres
Ttulo ... |
C | /*
*/
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
void print_my_port_num(int sock);
int main(){
int sock0;
struct sockaddr_in client;
socklen_t len;
int sock;
struct addrinfo hints, *res;
... |
C | #include <stdio.h>
#include <stdlib.h>
struct process //Structure of a process
{
int pt; //Process Number
int at; //Arrival Time
int bt; //Burst Time
int wt; //Waiting Time
int tt; //Turn Around Time
int rt; //Remaining Time
int ct; //Com... |
C | #include <stdio.h>
#include <malloc.h>
#include <stdbool.h>// bool,
struct Tree
{
struct Tree *Right;
struct Tree *Left;
double Data;
};
void init(struct Tree **t)// ,
{
*t = (struct Tree *)malloc(sizeof(struct Tree));
(*t)->Right = NULL;
(*t)->Left = NULL;
(*t)->Data = 2147483648;// 1 ,
}
void clean(stru... |
C | #include<stdio.h>
int main()
{
int n,i,j,k;
printf("Enter no. of rows:- ");
scanf("%d", &n);
printf("\nPattern is :- \n");
for(i=1;i<=n;i++) //for rows
{
for(j=1; j<=(n-i);j++) //for space
{
printf(" ");
}
for(k=1;k<=i;k++)
{
printf("*");
}
... |
C | #include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char ss[20],su[5];
char *s,*sub;
int l=0;
printf("enter the value of string\n");
gets(ss);
//scanf("%s",ss);
printf("enter the value of substring character\n");
gets(su);
//scanf("%s",su);
s=ss;
sub=su;
l=strl... |
C | #include "hash_tables.h"
/**
* hash_table_set - function that adds an element to the hash table.
* @ht: is the hash table to add or update the key/value
* @key: is the key. key can not be an empty string.
* @value: is the value associated with the key. value must be duplicated.
* value can be an empty string
* R... |
C | /*
* type.h
* Date : 11-14-2014
* Author : HouBiao,WangHanCheng
*/
#ifndef TYPE_H_
#define TYPE_H_
typedef double FLOAT; //
// ṹ
typedef struct
{
FLOAT real; // ʵ
FLOAT imag; // 鲿
}complex;
// ٽλ
typedef struct
{
FLOAT phsE; // E֧·λ
FLOAT phsP; // P֧·λ
FLOAT ... |
C | #include <stdio.h>
int num = 5;
int static num2 = 0;
void incrPtint(void);
void incrPrint(void) {
int num = 1;
num++;
printf("incrPrint(): num --> %d \n", num); //Լ .
}
int main(void) {
num = 10;
printf("num: %d \n", num);
incrPrint();
incrPrint();
incrPrint();
printf("num: %d \n"... |
C | #include "camera.h"
#include "ray.h"
#include "hit.h"
#include "material.h"
#include "vectors.h"
OrthographicCamera::OrthographicCamera(Vec3f cp,Vec3f dir, Vec3f u, float size)
{
center_point = cp;
direction = dir;
direction.Normalize();
Vec3f temp = u;
up = u-temp*u.Dot3(direction);
Vec3f::Cro... |
C | #include "bar.h"
Bar newBar(Point center, Texture texture, int id){
Bar b;
b.id = id;
b.center = center;
b.width = WINDOW_WIDTH/10;
b.height = 12;
b.speed = 0;
b.texture = texture;
return b;
}
void barDraw(Bar *bar){
float w = bar->width/2;
float h = bar->height/2;
float x = bar->center.x;
f... |
C | #include "header.h"
int main(){
int n, i, j;
printf("masukkan jumlah angka: ");
scanf("%d", &n);
char str[n][100];
for(i=0; i<n; i++){
scanf(" %s", &str[i]);
}
int hitungan = 0;
for(i=0; i<jumVo(n, str); i++){
hitungan++;
for(j=0; j<n; j++){
if(j==0){
printf("%d", hitungan);
}
printf("%s "... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: ... |
C | /*
* Slist.c
*
* Created on: Sep 18, 2014
* Author: nvthanh
*/
#include <stdio.h>
#include <stdbool.h>
#include "Slist.h"
slist * slist_append(slist * list, void * data)
{
slist * walk=list;
slist * add_item= (slist*)malloc(sizeof(slist));
if(!add_item)
{
perror("Out of memory !!!\n");
return list... |
C | #include <stdio.h>
int main(void){
long l;
long double d;
int i,k,n;
scanf("%d",&n);
for (k=1;k<=n;k++){
d=1;
l=1;
for (i=1;i<=k;i++){
d*=i;
l*=i;
}
printf("long :%d!=%ld\n",k,l);
printf("double:%d!=%Lf\n\n",k,d);
}
return 0;
}
|
C | #include<stdio.h>
int main(void)
{
int a, b, v;
char s;
printf("Number 1: ");
scanf("%d", &a);
printf("Number 2: ");
scanf("%d", &b);
s = '+';
v = a+b;
printf("\n%d%c%d = %d\n", a, s, b, v);
s = '-';
v = a-b;
printf("\n%d%c%d = %d\n", a, s, b, v);
... |
C | #include <stdio.h>
#define func(...) myfunc((struct mystru){__VA_ARGS__})
struct mystru { const char* name;int number; };
void myfunc(struct mystru ms){
printf("%s:%d\n",ms.name?:"untitled",ms.number);
}
int main(int argc,char **argv){
func("three",3);
func(.number=100);
func(.name="zero");
return 0;
}
|
C | #define NDEBUG
#include<iostream>
#include<cstdlib>
#include"./Containers.H"
#include"bits/ExplSumTreeTable.H"
#include"bits/WeightSumTable.H"
#include<cassert>
#include<ctime>
#define NUM_PASSES 1
#define DEF_LOG_HASH_SIZE 24 /* 16M */
using namespace std;
struct MyPolicy:public SetContainerPolicy<size_t> {
stati... |
C | #include <stdio.h>
int main()
{
float length;
printf("Enter length in cm --> ");
scanf("%f", &length);
if (1)
{printf("\nLength in feet is %f feet", length/30.48);
printf("\nLength in inches is %f inches\n", length/12);}
}
|
C | /*
* arboles.C: Script de ROOT para mostrar el uso de árboles.
*
* Ejemplo para el curso introductorio de ROOT.
* Laboratorio Avanzado
*
* Héctor Pérez, mayo 2020.
*
*/
#include <iostream>
#include <string>
#include <vector>
#include "TTree.h"
#include "TFile.h"
#include "TCanvas.h"
#include "TH1D.h"
#incl... |
C | #include <stdio.h>
int main(void){
int n; // N Է ϴ
int i,j; // ݺ
int result=0; // Ҽ
int cnt = 0; //
scanf("%d", &n); // Է
for(i=2; i<n; i++){
cnt = 0; //
for(j=1; j<=i; j++){ // i j++
if ( i % j == 0){ // Ҽ (cnt) Ѱ
cnt ++;
... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mff.h>
int main(int argc,char **argv)
{
FILE *def,*tag;
char *temp = malloc(512);
smud_file *myfile;
char *buffer = malloc(1024);
char *work = malloc(16384);
short vnum;
int i;
if(argc<2)
{
printf(" Usage: %s <filename>\n",argv[0]);
exi... |
C | #ifndef FECHA_H_INCLUDED
#define FECHA_H_INCLUDED
typedef struct
{
int dia;
int mes;
int anio;
} eFecha;
#endif // FECHA_H_INCLUDED
int obtenerFecha(int* diaAux, int * mesAux, int* anioAux);
/** \brief recibe las referencias a memoria de dia mes y ao y le pide al usuario valores validos para las mismas
... |
C | #ifndef DEVICES_DISK_H
#define DEVICES_DISK_H
#include <inttypes.h>
#include <stdint.h>
/* Size of a disk sector in bytes. */
#define DISK_SECTOR_SIZE 512
/* Index of a disk sector within a disk.
Good enough for disks up to 2 TB. */
typedef uint32_t disk_sector_t;
/* Format specifier for printf(), e.g.:
print... |
C | #include <stdio.h>
#include <stdlib.h>
#include "points.h"
#include "triangle.h"
int main()
{
printf("Hello world!\n");
Point *p1=createPoint(0,0);
Point *p2=createPoint(8,0);
Point *p3=createPoint(0,6);
Triangle *tr=createTriangleByPoints(p1,p2,p3);
printTriangle(tr);
printf("sguare of tr... |
C | #include<stdio.h>
void main()
{
int a[20];
int k,mid,i,first,last,n,f=0;
printf("Enter the no of elements -" );
scanf("%d",&n);
printf("Enter the elements\n");
for(i=0;i<n;i++)
{
printf("->");
scanf("%d",&a[i]);
}
printf("Array is ");
for(i=0;i<n;i++)
{
printf("%d,",a[i]);
}
printf("\nEnter t... |
C | #include <stdio.h>
#include <stdlib.h>
struct point {
int x;
int y;
};
int main()
{
struct point first = {100, 100};
struct point second = first;
struct point third = {.x=20, .y=30};
second.y = 200;
printf("(%d, %d)\n",first.x, first.y);
printf("(%d, %d)\n",second.x, sec... |
C | #include "Header.h"
//////////////////////////////////////////////////////////////
//
// Name: DigitsSum
// Description: Accept N numbers from user and
// display summation of digits of each number
// in it
//
// Input: N: 6
// 8225 665 3 76 953 858
// Output: 17 17 3 13 17 21
//
// Author: Vivek Shrihari Do... |
C | #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <semaphore.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
int counter=0;
int thread_count=4;
pthread_mutex_t barrier_mutex;
void* threadFn(void* rank){
long my_rank = (long) rank;
srand(my_rank);
pthrea... |
C | /*
* function for uart comms
*/
#include "mcu_defs.h"
#include <avr/io.h>
// Set up MCU
#define F_CPU CLOCK
#include <util/setbaud.h>
#include <util/delay.h>
#include "uart.h"
void uart_init(void)
{
UBRR0H = UBRRH_VALUE; // Set baud values correctly
UBRR0L = UBRRL_VALUE;
UCSR0B = (1 << RXEN0 ) | (1 <<... |
C | #include "hack.h"
int read_from_file_stream(
FILE *stream, unsigned char *data, size_t buf_capacity, size_t *dlen)
{
if (dlen) {
*dlen = 0;
}
if (!stream || !data || !dlen) {
return -1; // some argument is invalid
}
for (;;) {
int thisbyte = getc(stream);
if ... |
C | #include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
/*
param msg(const, str: pointer)
*/
static void die(const char* msg){
/*
perror()
エラー番号に対応するエラーメッセージを標準エラー出力。
msgを標準エラー出力
*/
perror(msg);
/*
exit()
プログラムの終了
EXIT_FAILURE : 失敗終了状態
*/
... |
C | #include<stdio.h>
#include<stdlib.h>
int main(int argc, char *argv[])
{
int cards[5];
char suits[5];
char lastSuit = '\0';
int suitchange = 0;
int i,j;
int jokers = 0;
int neighbors[2];
int bounds[2];
int ind;
int breaker_a = -1;
int breaker_b = -1;
int in_a_row = 0;
int row_value = -1;
... |
C | /*
* Author: lngost
* See https://github.com/lngost/algorithm-practice
*/
#include <stdlib.h>
#include <math.h>
#ifndef _ORDER_DEFINED_
#define _ORDER_DEFINED_
typedef const int ORDER;
#define ORDER_ND 1 // non-descending
#define ORDER_NA 2 // non-ascending
#endif
static void merge(int a[], int p, int q, int ... |
C | #include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main(int argc, char* argv[]){
// I suppose that I know the filenames and the number of rows
int n = 40;
//double tmp;
FILE* input_1;
FILE* input_2;
input_1 = fopen("matrix_from_matlab.txt", "r");
input_2 = fopen("vector_from_matlab.txt", "r");... |
C | #include<stdio.h>
int main(void){
int n;
scanf("%d",&n);
int sa;
int ans;
if(n>=9){
sa=n-9;
ans=sa%7;
if(ans==0){
printf("sat\n");
}
if(ans==1){
printf("sun\n");
}
if(ans==2){
printf("mon\n");
}
if(ans==3){
printf("... |
C | #include <stdio.h>
#include <stdlib.h>
// Funo contagem
void naturais(n){
if(n==49){ // Caso base
printf("%d", n);
return; // Imprime ltimo valor e retorna vazio
}
printf("%d ", n);
naturais(n+1); // Imprime o nmero e chama a funo para o prximo
}
// Funo Principal
int m... |
C | /*
* Expresses Regulares
* Biblioteca POSIX
* Ver: https://www.educative.io/edpresso/how-to-write-regular-expressions-in-c
* lufer
**/
#include <stdio.h>
#include "regex.h"
#pragma warning (disable: 4996);
void printResult(int return_value) {
if (return_value == 0) {
printf("Pattern found.\n");
}
... |
C | /**
*_strstr - find occurence of a substring in a string
*@haystack: string to search in
*@needle: string searched
*Return: pointer to the begining of the located substring or a null
*/
char *_strstr(char *haystack, char *needle)
{
int i, j;
for (i = 0; haystack[i] != 0; i++)
{
for (j = 0; (needle[j] != '\0') && ... |
C | #include <stdio.h>
#include <fcntl.h>
#include <time.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <memory.h>
#include <zconf.h>
#include <sys/types.h>
#include <sys/time.h>
int main(int argc, char * argv[]) {
if(argc<2){
printf("Błędne argumenty\n");
return -1;
}
... |
C | /*
* Copyright (c) 2018, 2021-2022 Paul Mattes.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this l... |
C | #ifndef UTIL_H_INCLUDED
#define UTIL_H_INCLUDED
float powi(float base, int exp)
{
if (exp == 0)
return 0;
else if (exp > 0)
{
while (exp - 1)
{
base*= base;
--exp;
}
return base;
}
else
{
exp = -exp;
while (exp - 1)... |
C | #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include "niuparser_sdk.h"
#include <assert.h>
#include <stdbool.h>
typedef void sigfunc(int);
void func_wait(int signo) {
p... |
C | #include <stdio.h>
#include <string.h>
int main () {
int length, n;
printf("Please enter the starting number of the Collatz sequence:\n");
scanf("%d",&n);
while(n != 1){
printf("%d, ",n);
if((n % 2) == 0) n /= 2;
else n = 3*n + 1;
}
printf("%d\n",n);
}
|
C | #define PLUS 1
#define MINUS -1
typedef struct node {
int num;
struct node *next, *prev;
}node;
typedef struct number {
int sign, dec;
node *head, *tail;
}number;
void initNumber(number *a);
void addDigit(number *a, char ch);
void printNumber(number a);
void destroyNumber(number *a);
void appendleft(number *a, in... |
C | #include "piece.h"
#include <string.h>
#include <stdlib.h>
#include "AI/movesGen.h"
#include "board.h"
#include <stdio.h>
#include "validMoves.h"
#define MAX_COLUMN 8
#define MAX_RANK 8
int rookMoves(int start, int end)
{
if (start < MAX_RANK)
{
if (end % MAX_RANK == start)
return 1;
... |
C | #include<stdio.h>
typedef struct student
{
char name[40];
int age;
}STUDENT;
int main()
{
int i;
STUDENT s;
FILE *fp;
fp=fopen("120_para_5.dat","r");
for(i=0;i<=12;i++)
{
printf("i=%-2d,%d\n",i,ftell(fp));
fread(&s,sizeof(STUDENT),1,fp);
printf("%s,%d\n\n",s.name,s.age);
}
... |
C | #include "vtsaddrtable_test.h"
#include "vtsaddrtable.h"
#include "vblock.h"
#include <unistd.h>
#include <stddef.h>
#define SMALL_POWER 4
#define SMALL_SIZE (1 << SMALL_POWER)
#define LARGE_POWER 16
#define LARGE_SIZE (1 << LARGE_POWER)
const char *test_vtsaddrtable_init()
{
struct vtsaddrtab... |
C | /*复制并显示数组*/
#include <stdio.h>
int main (void){
int i;
int dgt[9] = {1,2,3,4,5,6,7,8,9};
int a[9] = {0};
for (i = 0;i < 9;i++) /*复制所有元素*/
a[i] = dgt[i];
for (i = 0;i < 9;i++) /*显示所有元素*/
printf("%d ",a[i]);
putchar('\n');
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 | // This code is created by Ahmed A. Eltahan
/*
----------------------------- Program Description -----------------------------------------
*/
// Libraries
#include<stdio.h> // Library to include c functions for the compiler.
// Function prototype
// Declared Structures
struct students{
// elements
int ID;
fl... |
C | //#include "types.h"
//#include "interpreter.h"
//
//#include <uthash.h>
//
//#include <stdio.h>
//#include <stdlib.h>
//#include <stdbool.h>
//
//
//// [print x "a" 421]
//Box * print_fn(Node *args, Scope *local) {
// Node *cursor;
// with_resolved_args(args, local, cursor, {
// while (cursor != NULL) {
/... |
C | /* array.c -- runtime support of arrays */
#include "rts.h"
#include <stdarg.h>
static void slices ();
/*
* sr_init_array (locn, addr, elemsize, initvalue, ndim, lb1, ub1, ...)
* -- initialize an array.
*
* If addr is 0, first allocate it. If addr is -1, obtain from sr_new().
*
* If elemsize is zero o... |
C | /*
* Revision Control Information
*
* $Source: /users/pchong/CVS/sis/sis/pld/act_remove.c,v $
* $Author: pchong $
* $Revision: 1.1.1.1 $
* $Date: 2004/02/07 10:14:55 $
*
*/
#include "sis.h"
#include "pld_int.h"
/* free up ACTs
*/
int
p_actRemove(network, argc, argv)
network_t **network;
int argc;
char **argv... |
C | #ifndef HKL_STRING_H
#define HKL_STRING_H
#include <stdint.h>
#include <stdio.h>
#include <stddef.h>
#include <stdbool.h>
/**
@struct HklString A utf8-based string implementation.
Since utf-8 internally can use anywhere between 1 and 4 bytes per character
HklString acts as a wrapper for utf-8 data.
@authors Scott L... |
C | /*************************************************************************
> File Name: queue_test.c
> Created Time: 2014年05月06日 星期二 13时21分12秒
************************************************************************/
#include <stdio.h>
#include "queue.h"
#include <assert.h>
int main(void)
{
int s[] = {
1, 2, 3,... |
C | #include <stdio.h>
void arraySort(int array[], int size) {
for ( int sorted = 0; sorted == 0; ) {
sorted = 1;
for ( int i = 0, j = 1; j < size; i++, j++ ) {
int current = array[i];
int next = array[j];
if ( current > next ) {
array[j]... |
C | #include <stdio.h>
#include <stdlib.h>
inline void fastRead(int *a)
{
register char c=0;
while (c<33) c=getchar_unlocked();
*a=0;
while (c>33)
{
*a=*a*10+c-'0';
c=getchar_unlocked();
}
}
inline void fastWrite(int a)
{
char snum[20];
int i=0;
do
{
snum[i++]=a%10+48;
a=a/10;
}while(a!=0);
i=i-1;
whi... |
C | #include <stdio.h>
/* My solution to exercise 2, chapter 2 from "Vägen till C".
* Write a program to calculate how many km a car has been driven during a year
* a much fuel it consumes on avererage
*/
int main()
{
float km_today, km_lastyear, fuel;
printf("Odometer last year: ");
scanf("%f", &km_l... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* set.h :+: :+: :+: ... |
C |
/**
* deadlock_demolition
* CS 241 - Fall 2020
*/
#include "graph.h"
#include "libdrm.h"
#include "set.h"
#include <pthread.h>
struct drm_t {
pthread_mutex_t mutex;
};
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
graph* graph_ = NULL;
set* visited_nodes_ = NULL;
// bool has_cycle(void* node) {
// i... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* libft.h :+: :+: :+: ... |
C | #include <stdlib.h>
#include "util.h"
#include "wayland.h"
#include "window.h"
struct wl_connection *
wayland_init()
{
debug("Connecting to Wayland");
struct wl_connection *conn = malloc(sizeof(struct wl_connection));
if (!conn)
die("Failed to allocate connection struct");
debug("Creating display");
conn->dis... |
C | /*
* https://www.spoj.com/problems/NSTEPS/
*/
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int x,y,r,t;
scanf("%d", &t);
while(t--)
{
scanf("%d %d",... |
C | #include "request.h"
#include <fcgi_stdio.h>
#include <string.h>
#include <stdlib.h>
#include "scythe/response.h"
#include "scythe/routes.h"
struct param {
char name[32];
char value[256];
struct param* next;
};
static struct param* head_cookie;
static struct param* head_param;
void process_request() {
set_... |
C | #pragma once
typedef struct darray{
int len;
int elem_size;
int allocsize;
void *elements;
}darray_t;
#define darray_len(darray) (darray)->len
#define darray_create(element_type) \
__darray_create(sizeof(element_type))
darray_t *__darray_create(int elem_size);
#define darray_append(darray, type,... |
C | #include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <mqueue.h>
int main ()
{
pid_t pid;
pid = fork ();
struct mq_attr attr;
attr.mq_msgsize = 100;
attr.mq_maxmsg = 5;
char buff[attr.mq_msgsize];
mqd_t mq_fd = mq_open ("/CREAT", O_CREAT | O_RDWR, 0666, &attr ... |
C | #include <stdio.h>
#define LOWER 0 /* lower limit */
#define UPPER 300 /* upper limit */
#define STEP 20 /* step size */
float f_to_c(int fahr);
/* Rewrite the temperature conversion program to use a function for conversion */
int main(void)
{
int fahr;
float celsius;
printf("Fahr Celsius\n");
for... |
C | #include <stdio.h>
#define SIZE 100
/*Main function starts*/
int main() {
/*Variable declarations*/
int i, j, n, index = 0, array[SIZE];
static int freq[SIZE][2];
printf("Please enter the number of elements: ");
scanf("%d", &n);
/*Read array*/
for (i = 0; i < n; i++) {
printf("\nPlease en... |
C | #include "stdio.h"
#include "stdlib.h"
#include "conio.h"
typedef char datatype;
typedef struct node
{
int weight;
datatype data;
int lchild,rchild,parent;
}hufmtree;
#define EPS 1e-5
int Counter(hufmtree tree[],hufmtree single,int deep){
static int num;
if(single.lchild == -1 && single.rchild == -1){
num +... |
C | /**
* @file udp.h This file contains function definitions related to the UDP
* protocol.
*/
#ifndef UDPIPStack_udp_h
#define UDPIPStack_udp_h
#include "common.h"
#include "ip.h"
#include <stddef.h>
#include <stdint.h>
#define UDP_HEADER_LEN 8
#define UDP_DATAGRAM_MAX_LEN 65507
#define UDP_DATA_MAX_LEN ... |
C | #include "score.h"
#include "util.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <math.h>
typedef struct buffer
{
int node_count; // p
int sample_count; // n
double *data; // X
int max_parents; // m
int prior;
int multinomial; // # categories TODO variable for eac... |
C | #include<stdio.h>
#include<stdlib.h>
int main(void){
int x , y , z , w , n , m , c , i , carrot;
int ptr , ssn;
char day[100];
scanf("%d" , &c);
for(i = 0 ; i < c ; i++){
scanf("%d %d %d %d %d %d" , &x , &y , &z , &w , &n , &m);
printf("x %d y %d z %d w %d n %d m %d \n" , x , y , z , w , n , m);
fgets(day , ... |
C | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
typedef struct body
{
int x;
int y;
struct body *pnext;
} BODY, *PBODY;
int begin(void);
int nxstep(PBODY phead);
void food(void);
void get_dir(void);
PBODY build_body(void);
void move(PBODY phead, int n);
int if_die(int x, int ... |
C | #include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
void* runner( void* params);
int main()
{
int choice;
printf("Select a sched policy: 1) RR 2) FIFO 3)OTHER: ");
scanf("%d", &choice);
pthread_t tid[3];
pthread_attr_t attr;
pthread_attr_init(&attr);
// set schedule policy
swi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.