language large_stringclasses 1
value | text stringlengths 9 2.95M |
|---|---|
C | /*
A non-empty array A consisting of N integers is given. The array contains an odd number of elements, and each element of the array can be paired with another element that has the same value, except for one element that is left unpaired.
For example, in array A such that:
A[0] = 9 A[1] = 3 A[2] = 9
A[3] = 3 ... |
C | //10,ֵСֵ
#include <stdio.h>
#define LEN 10
int main()
{
int nCount = 0;
float nMin = 0;
float nMax = 0;
float nBox[LEN] = { 0 };
puts("Enter 10 numbers");
for (; nCount < 10; nCount++)
{
scanf_s("%f", &nBox[nCount]);
}
nMax = nMin = nBox[0];
for (nCount = 0; nCount < 10;... |
C | #include "holberton.h"
/**
* _pow - Returns the value of x raised to the y of power
* @x: Base number
* @y: Exponent
*
* Return: int
*/
unsigned int _pow(int x, unsigned int y)
{
unsigned int res = 1, i;
for (i = 0; i < y; i++)
{
res = res * x;
}
return (res);
}
/**
* binary_to_uint - converts a bina... |
C | #include <stdlib.h>
#include <stdio.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
static int num_signal=0;
void signal_handler(int sig){
if(sig==10){//SIGUSR1
printf("\n prints %d sigint \n",num_signal);
}
if(sig==2){//SIGINT
num_signal++;
}
}
int main(){
prin... |
C | #include<stdio.h>
#include<stdlib.h>
void main()
{
int *ptr,i;
ptr = calloc(5, sizeof(int));
for(i=0;i<5;i++)
*(ptr + i) = i;
for(i=0;i<5;i++)
printf("%d\t",*(ptr+i));
free(ptr);
}
|
C | // src/next_mday_days.c
#include <stdio.h> /* printf */
#include <time.h> /* struct tm */
#include "_private.h" /* mth_days */
int next_mday_days(int tgt_mday, const struct tm* lc)
// Days to end of current month
{
D && printf("next_mday_days()\n");
... |
C | //COPYRIGHT @KOLMOGROV
#include <stdio.h>
#include <mpi.h>
#include "err.h"
#define low (-100)
#define high 100
#define h 1
double func(double x)
{
return 4/(1+x*x);
}
int main(int argc, char *argv[])
{
int rank, size,errc;
double sum=0, inter,area;
errc=MPI_Init(&argc,&argv);
MPI_Errhandler_set(MPI_COMM_WORLD, ... |
C | #include <stdio.h>
#define TAM 100
float media_ponderada(float n1, float n2);
int main() {
int i, N;
float nota1[TAM], nota2[TAM], mediadoaluno[TAM];
float mediageral;
char ch1;
printf("\n***** Faz a média de N alunos *****");
printf("\n\nEntre com a quantidade de alunos na turma - no máximo 100: ");
scanf("%... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hashtable_country.h"
#include "hashtable_virus.h"
HashtableCountry* hash_country_create(int hashNodes) {
int i;
HashtableCountry* ht = malloc(sizeof (HashtableCountry));
ht->hash_nodes = hashNodes;
ht->nodes = (HashtableCountryNode**) malloc(... |
C | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
int array1[], array2[], array3[], array4[], size, choice;
void load_array(int array[], int size);
void print_array(int array[], int size);
float average_array(int array[], int size);
int main() {
printf("Average 4 arrays\n");
printf("Insert size of arr... |
C | #include "common_header.h"
#include "server_header.h"
char* server_ip,* server_port,* listen_port;
typedef struct tagWEB_CLIENT
{
int tag_id;
int ptt_socket;
int recv_data_socket;
int send_data_socket;
char ptt_to_recv_buf[8*1024+1];
size_t ptt_to_recv_buf_h;
size_t ptt_to_recv_... |
C | #include "common.h"
#include "memory.h"
#include <string.h>
#define VMEM_ADDR 0xa0000
#define SCR_SIZE (320 * 200)
#define NR_PT ((SCR_SIZE + PT_SIZE - 1) / PT_SIZE) // number of page tables to cover the vmem
PDE *get_updir();
//PTE ptable[1024] align_to_page;
extern PTE kptable[];
void create_video_mapping()
{
/*... |
C | /*
* menu.c
*
* Created on: Jun 12, 2020
* Author: catalina
*/
#include <stdio.h>
#include <stdlib.h>
#include "menu.h"
#include "utn.h"
//menu opciones principal
int menu()
{
int option;
system("clear");
printf(" ***** M E N U P A N D E M I A *****\n\n\n");
printf(" (1) Cargar archi... |
C | #ifndef control_funtion_h
#define control_funtion_h
#include <math.h>
/*please fill this controller function
* input:
* des_pos -> desired position
* des_vel -> desired velocity
* des_acc -> desired acceleration
* des_yaw -> desired yaw angle
* now_pos -> now psition
* now_vel -> body velocity
* Kp -> P ... |
C | #include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(int argc, char *argv[]) {
char cwd[256];
char fullname[1024];
if(argc < 2) {
fprintf(stderr, "usage: %s name\n", argv[0]);
return -1;
}
printf("cwd = %s\n", getcwd(cwd, sizeof(cwd)));
snprintf(fu... |
C | #ifndef __ARR_H__
#define __ARR_H__
typedef struct _arr_t {
int *arr;
int arr_len;
int num_entries;
} arr_t;
int alloc_arr(arr_t *a, int arr_len);
int free_arr(arr_t *a);
int arr_contains(arr_t *a, int e);
int arr_add(arr_t *a, int e);
#endif |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* hex_dump.c :+: :+: :+: ... |
C | #include <stdio.h>
#define XOPEN_SOURCE
#include <stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<sys/ioctl.h>
/* Chown the slave to the calling user. */
extern int grantpt (int __fd) __THROW;
/* Release an internal lock so the slave can be opened.
Call after gra... |
C | #include<stdio.h>
#include<math.h>
void main()
{
int a,b,c,d,e;
float y;
printf("enter the numbers:");
scanf("%d%d",&a,&b);
printf("enter the line no.:");
scanf("%d%d%d",&c,&d,&e);
y=((a*c+b*d+e)/sqrt(c*c+d*d));
printf("\n%f",y);
}
|
C | /* maxTweeter.c
*
* input:
* One program arguement, filepath to a CSV file.
*
*
* restrictions:
* Max line length will not exceed 1024 characters.
* Length of file will not exceed 20,000 lines.
* Header for Name may be surrounded by quotes, but then all names must also be surrounded ... |
C | #include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include "graphics.h"
#include "genlib.h"
#include "conio.h"
#include <windows.h>
#include <olectl.h>
#include <stdio.h>
#include <mmsystem.h>
#include <wingdi.h>
#include <ole2.h>
#include <ocidl.h>
#include <winuser.h>
#include "unsize_array.h"
typedef stru... |
C | #ifndef CHELL_LINEEDIT_H
#define CHELL_LINEEDIT_H
#include <stdio.h>
/**
* Resets the terminal formatting entirely.
*/
#define RSTT "\x1B[0m"
/**
* Color choices.
* The codes sets the foreground color to the indicated color.
*/
#define BLKT "\x1B[30m"
#define REDT "\x1B[31m"
#define GRNT "\x1B[32m"
#define YELT... |
C | //Function call and pointer
void swap(int *a, int *b)
{
int temp = *a;
*a = *b;
*b = temp;
}
void main()
{
int a=3, b=5;
swap(&a, &b);
}
|
C | #include <stdio.h>
#include <cs50.h>
#include <string.h>
int main(int argc, string key[])
{
if (argc != 2)
{
printf("Usage: ./substitution key\n");
return 1;
}
else for (int k = 0; k < 26; k += 1)//go through each letter of key
{
if (64 < (int) key[1][k] && (int) key [1][k] ... |
C | #include <stdio.h>
int main()
{
int x= 10;
printf("Value of x is %d\n", x);
printf("Adress of x is %p\n", &x);
return 0;
}
|
C | #include<stdio.h>
#include<string.h>
void search(char txt[], char pat[])
{
int l1, l2, i, j;
l1 = strlen(txt);
l2 = strlen(pat);
for (i = 0; i <= l1 - l2; i++) {
for (j = 0; j < l2; j++) {
if (txt[i + j] != pat[j]) {
break;
}
}
if (j == l2) {
... |
C | #include <cs50.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct
{
int n;
char name[10];
}
node;
int main(void)
{
node test[5];
for (int i = 0; i < 5; i++)
{
test[i].n = i*3;
fprintf(stdout, "enter string.\n");
char *user = get_strin... |
C | #pragma comment(copyright, " © Copyright Rocket Software, Inc. 2017, 2020 ")
#include <stdlib.h>
/* TODO: figure out how to wrap new, new[], delete, and delete[],
* if necessary.
*/
/* To somewhat convince ourselves that, this isn't introducing
* memory leaks, maybe wrap free as well, then keep track of
* the 0... |
C | #include <stdio.h>
#include <stdlib.h>
typedef struct lianbiao
{
int a;
struct lianbiao *next;
}lb;
lb* myinput()
{
lb *head,*p,*pp;
printf("请输入int型数据,以0结束.\n");
head=p=(lb *)calloc(sizeof(lb),1);
while(1)
{
pp=(lb *)calloc(sizeof(lb),1);
scanf("%d",&pp->a);
if(pp->a==0)
{
p->next=NULL;
return head... |
C | #include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#if defined (__GNU__)
#define PACKED __attribute__((packed))
#else
#define PACKED
#endif
typedef struct PACKED {
int barrelID;
int battery;
int temperature;
int humidity;
int pressure;
int roll;
int pitch;
... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_split_whitespaces.c :+: :+: :+: ... |
C | /*
* funcServer.c
*
* Created on: Dec 5, 2012
* Author: rosyid
*/
#include "funcServer.h"
static void init_fs() {
memset(&(fs.hints), 0, sizeof(fs.hints));
fs.hints.ai_family = AF_INET;
fs.hints.ai_socktype = SOCK_STREAM;
fs.hints.ai_flags = AI_PASSIVE;
}
static void ftps_listen() {
ch... |
C | /**
* @file
* @brief A driver for the solenoid.
*/
/**
* @brief Initializes the solenoid.
*/
void solenoid_init();
/**
* @brief Sets the solenoid.
*/
void solenoid_set();
/**
* @brief Clears the solenoid.
*/
void solenoid_clear();
/**
* @brief Checks if the solenoid is set.
*
* @return A boolean corr... |
C | /**
* Nombre: ejercicio8.c
* Autores: Jose Ignacio Gomez, Óscar Gómez
* Fecha: 10-03-2017
* Grupo: 2202
* Pareja: 5
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <signal.h>
#include <time.h>
#define NUM_PROC 4 /*!< Ńumero de iter... |
C | #include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "member.h"
#define MIN_ID 0
// Struct Decleration
struct Member_t{
int member_id;
char* member_name;
};
// Function Implementations
Member memberCreate(const int member_id, const char* member_name)... |
C | #include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define K 1024
#define WRITELEN (128 * K)
int main(void)
{
int result = -1; /*创建管道结果*/
int fd[2], nbytes; /*文件描述符,字符个数*/
pid_t pid; /*PID*/
char string[WRITELEN] = "Hello Miclefeng pipe";
char rea... |
C | #ifndef __GRADER_H
#define __GRADER_H
#include <stdio.h>
#include <string.h>
#include <printf.h>
#include <stdlib.h>
#include <setjmp.h>
////////////////////////////////////////////////////////////////
// Color macros
#define TEST_COLOR "35;1"
#define RESET_COLOR "0"
#define PASSED_COLOR "32"
#define FAILED_COLOR "31... |
C | #ifndef _SINGLE_LIST_H
#define _SINGLE_LIST_H
struct node;
typedef struct node * pNode;
typedef pNode sList;
struct node
{
int value;
pNode next;
};
pNode sListSearch(sList l, int v);
void sListDelete(sList l);
void sListAppend(sList l, int v, pNode p);
void sListRemove(sList l, int v);
void sListPrint(sList l);
... |
C | #include<stdio.h>
int main()
{
double h;
scanf("%lf", &h);
if(h >= 4)
{
printf("He can be a excellent programmer.");
}
else if(h >= 3)
{
printf("He can be a good programmer.");
}
else if(h > 2)
{
printf("He can be a normal programmer.");
}
else
... |
C | #include <stdlib.h>
#include <string.h>
void * destroy(char** args) {
int i = 0;
while(args[i]) free(args[i++]);
free(args);
return NULL;
}
void * recallocarray(void * ptr, size_t nmemb, size_t size, size_t oldLen) {
void * temp = calloc(nmemb, size);
memcpy(temp, ptr, oldLen * size);
free(ptr);... |
C | #include "monty.h"
/**
* exe_operation - function that executes opcodes
* @op_command: opcode commamd
* @head: pointer to head
* @line_number: line number
*
* Return: void
*/
void exe_operation(char *op_command, stack_t **head, unsigned int line_number)
{
int i;
instruction_t all_ops[] = {
{"push", do_push}... |
C | //
// Created by Chao Yang on 2019-04-22.
//
#include "util.h"
#include <stddef.h>
uint32_t
bytes_to_u32(uintptr_t addr) {
uint32_t u32 = 0;
for(int i = 0; i < 4; i++) {
uint8_t* ptr = (void*)(addr + i);
u32 |= ((*ptr) << (i * 8));
}
return u32;
}
uint64_t
bytes_to_u64(uintptr_t add... |
C | #include "common.h"
void convert_to_data(uint64_t value, int size, unsigned char * data) {
for (int i = 0; i < size; i++) {
data[i] = 0;
data[i] = value >> ((size - i - 1) * 8) & 255;
}
}
uint64_t convert_from_data(int size, unsigned char * data) {
uint64_t value = 0;
for (int i = 0; i < size; i++) {
value ... |
C | #include <stdlib.h>
#include <sys/resource.h>
#include "png.h"
int main(int argc, char** argv) {
void writeImage(FILE *file, png_bytepp data, int width, int height) {
png_structp p = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
png_infop info = png_create_info_struct(p);
setjmp... |
C | #include <stdio.h>
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
struct s {
int one;
char two;
};
/*
... |
C | /*
gcc -std=c17 -lc -lm -pthread -o ../_build/c/string_wide_iswblank.exe ./c/string_wide_iswblank.c && (cd ../_build/c/;./string_wide_iswblank.exe)
https://en.cppreference.com/w/c/string/wide/iswblank
*/
#include <stdio.h>
#include <wchar.h>
#include <wctype.h>
#include <locale.h>
int main(void)
{
wchar_t c = L'\u3... |
C | #include <stdio.h>
#include <unistd.h>
int main()
{
// Iteratively double i
for (int i = 1;; i *= 2)
{
printf("%i\n", i);
sleep(1);
}
return 0;
} |
C | #include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "unistd.h"
#include "arpa/inet.h"
#include "sys/socket.h"
//定义监听端口
#define PORT 8080
/**
* 处理浏览器请求
* 参数 *sock 客户端套接字地址
*/
void requestHandling(void *sock);
//发送数据
void sendData(void *sock, char *filename);
//显示html
void catHTML(void *sock, char *fi... |
C | #include <stdio.h>
#include <stdlib.h>
#define SIZE 8
typedef int data_t;
typedef struct list{
data_t data[SIZE]; //保存数据的空间
int last; //保存最后一个有效元素的下标
}list_t;
/*返回创建好的 空顺序表 的地址*/
list_t *creat_list()
{
list_t *p;
p = malloc(sizeof(list_t));//申请空间
p->last = -1; //初始化 结构内部相应内容
return p;
}
/*
* p: 顺序表的地址
* in... |
C | #include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "utone.h"
typedef struct {
ut_fof *fof;
ut_ftbl *sine;
ut_ftbl *win;
} UserData;
void process(ut_data *ut, void *udata) {
UserData *ud = udata;
UTFLOAT osc = 0, fof = 0;
ut_fof_compute(ut, ud->fof, &osc, &fof);
ut->out[0] = ... |
C | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <regex.h>
void SolveMaze(char *maze, int width, int height) {
int dir, count;
int x, y;
int dx, dy;
int forward;
/* Remove the entry and exit. */
maze[0 * width + 1] = 1;
maze[(height - 1) * width + (width - 2)] = 1;
forw... |
C | #include<stdio.h>
//declaration of structure
struct node
{
int info;
struct node *next;
};
//create function
struct node *create()
{
struct node *root,*newnode,*temp,*prev;
root=NULL;
int n;
printf("enter no(-999 to stop) = ");
scanf("%d",&n);
while(n!=-999)
{
newnode=(struct... |
C | #include <stdio.h>
#include "sfs.h"
struct workspace {
unsigned int task_no;
};
void common_task(void)
{
struct workspace *ws;
ws = SFS_work();
printf("task%d!\n",ws->task_no);
}
void regist_task1(void)
{
struct workspace *ws;
ws = SFS_work();
ws->task_no = 1;
SFS_change("TASK1", 0, common_task);
}
void r... |
C | #include <stdio.h>
int med3(int a, int b, int c)
{
if (a >= b)
{
if(b >= c) return b;
else if (a <= c) return a;
else return c;
}
else if (a > c) return a;
else if (b > c) return c;
else return b;
}
int main(void)
{
int a, b, c;
printf("Get a median among three integers.\n");
printf("a ... |
C | #include <stdio.h>
#include <Windows.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
//öͣλ
enum role { manager = 1, technician, saler, salemanager };//ö: Ա Ա ۾
//Աṹ
struct employee
{
int number;
char name[15];
int age;
char sex[5];
char department[10];//
enum role role;//λ
double salary;//
int ... |
C | #pragma once
//Basic set of indexeds for bool Keys array
// this enum spans from 0 to 73, so make sure to use KEYS_SIZE for the size of the array
#define KEYS_SIZE 74
enum KEYS{
KEY_A,
KEY_B,
KEY_C,
KEY_D,
KEY_E,
KEY_F,
KEY_G,
KEY_H,
KEY_I,
KEY_J,
KEY_K,
KEY_L,
KEY_M,
KEY_N,
KEY_O,
KEY_P,
KEY_Q,
... |
C | #include <stdio.h>
#include <stdlib.h>
struct passenger {
int floor;
int time;
};
struct passenger passengers[101];
int cmp_passenger(const void *left, const void *right)
{
struct passenger *l = (struct passenger *)left;
struct passenger *r = (struct passenger *)right;
return l->floor - r->floor;... |
C | #include <stdio.h>
int main() {
float result;
int addidition = 3 + 1;
//The result of our calculation*
result = (float)(addidition) / 5;
printf("The value of 4/5 is %f\n", result);
return 0;
}
|
C | //#include "list.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
typedef struct cache_entry_t {
char* filename;
struct cache_entry_t* next;
} cache_entry;
typedef struct cache_t {
cache_entry* file_cache;
signed short int cache_size;
} cache;
void cach... |
C | #ifndef TOKEN_H_
#define TOKEN_H_
#include "common.h"
#define TOKEN_KINDS \
TOKEN_KIND(Error, "error") \
TOKEN_KIND(None, "none") \
TOKEN_KIND(Comment, "Comment") \
TOKEN_KIND(Eof, "EOF") \
TOKEN_KIND(IntLiteral, "integer literal") \
TOKEN_KIND(FloatLiteral, "float literal") \
TOKEN_KIND(StrLiteral, "st... |
C | //Lăbău Cristea Andrei Liviu 314 CB
#include "utils.h"
Resource* get_page_resources(const char *URL_Name, int *n) {
int i, j, name_len, url_name_len = strlen(URL_Name);
unsigned int resource_nr = 0;
uint32_t size = 0;
if(URL_Name == NULL) {
return NULL;
}
for(i = 0; i < url_name_len; i+... |
C | #include<stdio.h>
int s(int *[]);
int main()
{
int a[5]={4,3,7,1,2};
int *b[5];
for (int i=0;i<5;i++)
{
b[i]=&a[i];
}
printf("before: \n");
for (int j=0;j<5;j++)
{
printf("A[%d] : %d\n",j,a[j]);
}
s(b);
printf("after:\n");
for (int j=0;j<5;j++)
{
printf("A[%d] : %d\n",j,a[j]);
... |
C | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
int calculo_potencia(int base, int potencia);
int main(){
int base, potencia;
printf("Digite um valor para base (k) e o valor da potencia(n):\n");
scanf("%d %d", &base, &potencia);
calculo_potencia(base,potencia);
pr... |
C | #include<stdio.h>
#include<stdlib.h>
#include<assert.h>
typedef int SListDateType;
typedef struct SListNode
{
struct SListNode* _pNext;
SListDateType _data;
}SListNode;
SListNode* BuySListNode(SListDateType data)
{
SListNode* pNewNode = (SListNode*)malloc(sizeof(SListNode));
if (pNewNode == NULL)
{
perror("ma... |
C | #include <stdio.h>
int main() {
/* Izlaz */
if (padavine=='d' || padavine=='D') {
printf("Ne odgovara niti jedan grad.");
} else if (padavine=='n' || padavine=='N') {
if (temperatura>-5 && temperatura<30) {
printf("Elma i Anja mogu u Sarajevo.");
}
else if (temperatura<5) {
printf("Anja i Una ... |
C | /*
* test_crypto.c
*
* Performs a simple encryption-decryption
* of random data from /dev/urandom with the
* use of the cryptodev device.
*
* Stefanos Gerangelos <sgerag@cslab.ece.ntua.gr>
* Vangelis Koukis <vkoukis@cslab.ece.ntua.gr>
*/
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_type.c :+: :+: :+: ... |
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 "stdlib.h"
#define ATEXIT_MAX (8)
typedef void (*AtexitFunc)(void);
static AtexitFunc __atexit_funcs[ATEXIT_MAX];
static int __atexit_count;
int atexit(void (*func)(void)) {
int count = __atexit_count;
if (count >= ATEXIT_MAX)
return 1;
__atexit_funcs[count] = func;
++__atexit_count;
return ... |
C | /* Program name: prime3.c
Author : Atish Jain
IDE: C-Free 5.0
Task : Program to check whether the given no is prime or not - Logic 3 */
# include <stdio.h>
main()
{
int no,d=2,count=0;
char isprime='y';
printf("Enter a no....:");
scanf("%d",&no);
while(d<(no/2))
{
count++;
... |
C | #include <stdio.h>
int main () {
printf("%d\n",exame(5));
}
int exame (int n) {
int a;
int b = 1;
int current = 2;
for (int i = 2; i < n; i++) {
a = b;
b = current;
current = (1 + b) / a;
}
return current;
} |
C | //
// main.c
// 计算位数
//
// Created by edz on 2020/8/3.
// Copyright © 2020 edz. All rights reserved.
//
#include <stdio.h>
int main(int argc, const char * argv[]) {
int num, count=0;
printf("Enter a number: ");
scanf("%d", &num);
do {
num = num / 10 ;
count++;
} while (num !=0)... |
C | # include <string.h>
# include <stdio.h>
# include "openAddressingOperations.h"
/* Returns the number of probes as a metric of efficiency. */
long openAddressTable_Insert (OpenAddressTable *oaTable, void *elem) {
long h, i, k, slotKey;
char *slot;
/* Put the elem key into a long variable. */
k = keyCopy((c... |
C | #include <stdio.h>
void swap_max(int a[], int x, int y)
{
int d = a[y], e = 0;
for (int i = y; i < x; i++)
{
if (a[i] > d)
{
d = a[i];
e = i;
}
}
if (d != a[y])
{
a[e] = a[y];
a[y] = d;
}
}
void ssort(int p[], int z)
{
... |
C | /*
深度优先遍历,dfs与bfs结合
*/
vector<int> lexicalOrder(int n) {
vector<int> res;
set<string> zdx;
while (n>0) zdx.insert(to_string(n--));
set<string>::iterator iter = zdx.begin();
while (iter!=zdx.end())
{
stringstream out(*iter++);
out >> n;
res.push_back(n);
}
return res;
} |
C |
#include<stdio.h>
#include<stdlib.h>
#include"stack.h"
int main()
{
int i, n, ch, data, pos;
do
{
printf("\n\n\n-----------Stack using Linked List------------:\n");
printf("\n\n1. Push the element.\n");
printf("\n2. Pop the element.\n");
printf("\n3. Display\n");
printf("\n0. Exit\n");
printf("\n... |
C | #include "stdlib.h"
#include <string.h>
#include "stdio.h"
void yap(int *argc, char *argv[])
{
FILE *dosya;
char *satir = NULL;
char mod[2];
int satir_sayac = 1;
char c;
mod[0] = argv[1][0];
mod[1] = argv[1][1];
char *dosyaAdi = malloc(sizeof(char) * 100);
dosyaAdi = argv[2];
size_t buff = 0;
si... |
C | #include <unistd.h>
#include <limits.h>
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <assert.h>
void test_symlink(char *salt) {
char filename[100];
char linkpath[100];
pid_t pid = getpid();
sprintf(filename, "./%sfile_%d", salt, pid);
printf("creat... |
C | /*
** client.c -- a stream socket client demo
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include "commons/config.h"
#include "commons/string.h"
#inc... |
C | #include <stdio.h>
int main()
{
int ar1[4]={0},ar2[4]={0},ar3[4]={0};
float ar4[4],apodotikotita,temp;
int i=0,n,k=-1,j;
FILE *fp;
if(fp=fopen("in.txt", "r")){
fscanf(fp, "%d",&n);
printf("Reading file for %d lines of data...\n",n);
while(i<n){
fscanf(fp, "%d",&ar1[i]);
fscanf(fp, "%d",&ar2[i]);
... |
C |
#include "Pali.h"
int IsPalindrome (const char *str)
{
int flag = 0; /* check equal */
int counter = 0 ;
int len = strlen(str);
/* eaual the first char + counter in the string to the last char - counter in the string*/
for (; counter < (len/2) ; counter++)
if (*(str+counter) == *(str +len-counter -1)) /* ... |
C | #ifndef _HEXADECIMAL_H_
#define _HEXADECIMAL_H_
#include <stdlib.h>
/**
* @file Hexadecimal Representation
*/
/**
* @brief Print the hexadecimal representation of a variable.
*
* @param address the address of the variable in memory
* @param size the size, in bytes, of the variable
*/
void PrintHex(void *address... |
C | //name-naveen roll-1601CS28
// Date-31/07/2017
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//stucture define
struct node
{
char serialno[10];
char title[10];
char author[10];
int boolnumber;
struct node* next;
};
//print linked list and book details
void print(struct node *head)
{
struct node *ne... |
C | #include <stdio.h>
#include "ft_str_is_alpha.c"
int main()
{
char chaine_alpha[] = "aaaabbbsbdfjkkkcjdhejeejhfnfjQQQQDHKSJhhhkdjAASJJFK";
char chaine_non_alpha[] = "aaagggfffsdsddsQQQ[]_avdbn";
char chaine_vide[] = "";
printf("La premiere chaine est alphabetique : %s\n", chaine_alpha);
printf("La deuxieme chaine... |
C | #include<stdio.h>
void table(int n);
int main(void)
{
int no;
printf("\n Enter No :: ");
scanf("%d", &no);
table(no); // function call
return 0;
}
void table(int n)
{
int counter;
printf("\n print table of %d in function :: \n", n);
for(counter=1; counter<=10; counter++)
{
printf("\n %d * %d = %d ", n, cou... |
C | #include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <err.h>
#include <dynamic.h>
#include <ts.h>
void usage()
{
extern char *__progname;
(void) fprintf(stderr, "Usage: %s [INPUT FILE] [OUTPUT FILE]\n", __progname);
exit(1);
}
int main(int argc, char **argv)
{
ts_stream st... |
C | /*
** EPITECH PROJECT, 2018
** PSU
** File description:
** Created by MP,
*/
#include <common.h>
int nbr_str (char *line, char c)
{
int nbr = 0;
int len = strlen(line);
for (int i = 0; line[i] != '\0' && i != len; i++) {
if (line[i] == c || line[i] == ' ' || line[i] == '\t') {
while (i < len && (line[i] ... |
C | #include<stdio.h>
int main()
{
int num;
scanf("%d",&num);
int no_of_bits=sizeof(int)*8;
for(int k=0;k<no_of_bits;k++)
{
if(num<<k|num>>(no_of_bits-k))
printf("%d",num);
}
}
|
C | /**
* alilib-ali2.c
* Converts an arbitrarily large integer to something else
* (double, int, string, long) for alilib.
*
* <insert appropriate open source license>
*/
// +---------+-------------------------------------------------------
// | Headers |
// +---------+
#include <stdio.h>
#include <stdlib.h>... |
C | #include <stdio.h>
int main () {
char a[256];
printf("Enter a message: ");
scanf("%[^\n]s", a);
printf("%s\n", a);
return 0;
} |
C | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include"second.h"
int check (int argc, char** argv){
int fin=1;
if(argc-1!=8){ //checking that 5 inputs have been fed
return 0;
}
int cachesize=atoi(argv[1]);
int cache2size=atoi(argv[5]);
if(floor(log2(cachesize))!=log2(cachesize... |
C | /*
C The Hard Way
more function pointers
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
// just some error checking
void die(const char *message)
{
if(errno) perror(message);
else printf("Error: %s\n", message);
exit(1);
}
// typedef for function pointer
typedef... |
C | // NEVER ACTUALLY USED IN KERNEL CODE
// THIS FILE HASN'T BEEN REVIEWED AND IS DIRTY
#include "../common/stdlib.h"
#include "mem.h"
#include "uart.h"
#include "mailbox.h"
int mailbox_send(mailbox_message_t msg){
uart_puts(" Sending a message\n"); // Debugging
mailbox_status_t stat;
// Make sure we can send ... |
C | #include <stdio.h>
main()
{
char sel;
do
{
scanf("\n%c",&sel);
if (sel >= 'a' && sel <= 'z')
printf("Minuscula\n");
else if (sel >= 'A' && sel <= 'Z')
printf("Maiuscula\n");
else if (sel >= '0' && sel <= '9')
printf("Digito\n");
else
printf("Sem classificacao\n");
}
whi... |
C | #include<stdio.h>
int main()
{
int lr,ur;
int lc,uc;
int i,j,n,arr[20][20];
printf("\nEnter a number:");
scanf("%d",&n);
lr=lc=0;
ur=uc=n-1;
int count=1;
while(lr<=ur&&lc<=uc)
{
for(i=lc;i<=uc;i++)
arr[lr][i]=count++... |
C | #include<stdio.h>
#include<string.h>
#define MAX 1000000
int factorCount[MAX]={};
void distinct_factor_count()
{
int i, j;
for(i=2;i<=MAX;i++)
if(!factorCount[i])
for(j=i;j<=MAX;j+=i)
factorCount[j]++;
}
int main()
{
distinct_factor_count();
int n;
while(scanf("%... |
C | /*
* 线程池的实现
*/
#include "threadPoll.h"
extern void threadCall(struct TaskNote *arg);
char initThreadPoll(int threadNum, struct ThPoll **thPoll)
{
pthread_t tid; //线程号
pthread_attr_t tattr;//线程属性
int i = 0;//循环变量
//初始化线程池结构体
*thPoll = (struct ThPoll *)malloc(sizeof(struct ThPoll));
(*thPol... |
C |
/*
*
* dig
*
* created with FontCreator
* written by F. Maximilian Thiele
*
* http://www.apetech.de/fontCreator
* me@apetech.de
*
* File Name : dig
* Date : 06.03.2016
* Font size in bytes : 892
* Font width : 7
* Font height : 11
* Font first char : 42
*... |
C | #include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<sys/socket.h>
#include<sys/stat.h>
#include<arpa/inet.h>
#include <string.h>
#include "log.h"
#include "Locker.h"
#include "locker_pthread.h"
#define MAXBUF 1024
//whole system log
Logger* log = NULL;
int main(int argc ,char** argv) {
Locker* locke... |
C | #include<stdio.h>
int main()
{
int array[10], sum = 0,i;
for (i = 0; i < 10; ++i) {
scanf("%d", &array[i]);
sum += array[i];
if (sum >= 100) {
if (sum - 100 <= 100 - (sum-array[i]))
printf("%d\n", sum);
else
printf("%d\n", sum-array[i]);
return 0;
}
}
printf("%d\n", sum);
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.