language large_stringclasses 1
value | text stringlengths 9 2.95M |
|---|---|
C | #include "threads.h"
int factorial(int n) {
return n == 0 ? 1 : n * factorial(n-1);
}
void fun_with_threads(void * arg) {
printf("** In fun_with_threads() function **\n");
int i = 0;
int n = *(int *) arg;
for(;i < 10; ++i) {
printf("** Loop %d **\n", i);
printf("** %d! = %d **\n", n+i, factorial(n+i... |
C | /*
虚拟内存实验
*/
/*
实验思路:
1.先把物理页数量减少至1,便于观察实验
2.剩余1个页,我们要在1个页的基础上再给进程分配10个页(即10*4096的进程空间)
3.循环访问分配的10个页:每次访问都先要换出一个页,再把之前写到磁盘的页换入
实验效果:
1.物理页从剩余数量为690,减少至1
2.除第一次分配不用换出外,后面的9次分配都要换出,一共换出9次
3.每次访问,先换出一个页(腾出一个物理页),再换入之前在磁盘的物理页数据
*/
#include "types.h"
#include "stat.h"
#include "user.h"
void
me... |
C | #pragma once
#include "defs.h"
#include "str.h"
typedef enum {
TStyle_bold, // : sfn('1', '1', '22'),
TStyle_italic, // : sfn('3', '3', '23'),
TStyle_underline, // : sfn('4', '4', '24'),
TStyle_inverse, // : sfn('7', '7', '27'),
TStyle_white, // : sfn('37', '38;2;255;255;255', '3... |
C | #include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <ctype.h>
#include <stdlib.h>
#include "myhead.h"
int main(int argc, char *argv[]){
int server_sock = -1; //服务器socket
u_short port = 4000; //port
int client_sock = -1; //客户端socket
struct sockaddr_in client_na... |
C | #include <stdio.h>
#include <stdlib.h>
#include "limits.h"
/**
* \brief Recibe el valor de dos numeros y calcula la suma
* \param numeroUno corresponde al primer numero ingresado por el usuario
* \param numeroDos corresponde al segundo numero ingresado por el usuario
* \param resultadoSuma corresponde a la suma de los... |
C | #include "functions.h"
#include "mathematicalOperations.h"
void menu()
{
float x=0,y=0,suma=0,resta,multiplicacion,divicion;
int factorialA,factorialB,flag=0,flag1=0,flag2=0,option;
do
{
printf("1.Ingresar 1er operando (A=%.2f)\n",x);
printf("2.Ingresar 2do operando (B=%.2f)\n",y);
... |
C | #include<stdio.h>
#include<conio.h>
int main()
{
int num;
printf("enter the number");
scanf("%d%",&num);
if(num%2==0)
{
printf("given number is even number");
}
else
{
printf("given number is odd number");
}
return 0;
}
|
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../header/tree_map.h"
int cstring_compare(void *o1, void *o2){
return strcmp((char*)o1, (char*)o2);
}
int int_compare(void *o1, void *o2){
return *((int*)o1) - *((int*)o2);
}
int* toPointer(int value){
int* temp = malloc(sizeof(int));
*temp = val... |
C | #ifndef LIST_H_
#define LIST_H_
typedef void (*list_element_free)(void *v);
// This function shall return 0 if v1 and v2 are equal, -1 otherwise
typedef int (*list_element_cmp)(void *v1, void *v2);
typedef struct _list_element {
void *v;
struct _list_element *next;
} list_element;
typedef struct _list {
... |
C | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
int main(int argc, char **argv)
{
int fd, fd1;
int flag;
fd = open(argv[1], O_WRONLY | O_CREAT);
if (fd == -1)
{
return -1;
}
printf("O_CREAT = %#o\n", O_CREAT);
fl... |
C | #include "Mean.h"
#include "stdio.h"
#include "stdlib.h"
#include "time.h"
void messageOfTheDay()
{
char * msgs[] = { "Scott is not great...", "Mario is much better than Kast.", "Wade is much better than Kast.", "BIG (Brandon is great)",
"Generic mean message; be upset." , "KING (Kast is not good)" , "Happy... |
C | #include<stdio.h>
void main()
{
int num;
do
{
printf("Enter a positive number: ");
scanf("%d",&num);
}while(num<0);
int factorial,i;
for(i=1;i<=num;factorial*=i,i++);
printf("%d! = %d\n",num,factorial);
} |
C | #include "uart_485.h"
#include "delay.h"
#include "usart.h"
#include "config.h"
#ifdef USART_485_RX_EN //ʹ˽
//ջ
u8 RS485_RX_BUF[100]; //ջ,64ֽ.
//յݳ
u8 RS485_RX_CNT=0;
void USART3_IRQHandler(void)
{
u8 res;
if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET) //յ
{
res =USART_Receive... |
C | #include "numerik_bespin_deutsch_linalg.h"
#include <stdlib.h>
#include <math.h>
MATRIX *matrix_alloc(int n) {
int i;
MATRIX *ret;
/* Allokiert ein Matrix-Struct */
if ( NULL == (ret = malloc(sizeof(MATRIX))) ) {
return NULL;
}
/* Speicher fuer die Matrixelemente */
if ( NULL == (ret->data = m... |
C | #include "../include/core.h"
#include "../include/graph.h"
void init_graph() {
if (initscr() == NULL) {
perror("initscr");
return;
}
noecho();
curs_set(0);
keypad(stdscr, true);
cbreak();
start_color();
refresh();
... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strtrim.c :+: :+: :+: ... |
C | /*
* uart2.c
*
* Created on: Jun 3, 2014
* Author: reuben
*/
#include "mb90540.h"
/* globals */
unsigned char receive_data;
unsigned char ERROR = 0xC2; /* clears all data leds */
//unsigned char data[] = {0x00,0x02,0x40,0x42,0x80,0x82,0xC0};
unsigned char data[] = {'R','E','U','B','E','N','\n'};
unsigned... |
C | #include "asm80.h"
/* packToken - packs the token pointed by tokStart, with length toksiz into 4 bytes
packed version replaces original and toksize set to 4 bytes
*/
static byte Pack1(byte i)
{
return i >= tokenSize[0] ? 0 : tokStart[0][i] < 0x3f ? tokStart[0][i] - 0x2f : tokStart[0][i] - 0x34;
}
void PackToken()
... |
C | #include <stdio.h>
int main(int argc, char **argv)
{
int myNum = 7;
int *myPtr;
myPtr = &myNum; //myPtr = address of myNum
printf("myNum = %i\n",myNum); //myNum = 7
printf("myPtr = %i\n",myPtr); //address of myPtr
printf("*myPtr = %i\n",*myPtr); //contents of what myPtr is pointing to (myNum) "... |
C | #include <string.h>
#include <minunit.h>
#include <titan-secure-volume/titan-secure-volume.h>
#include <titan-secure-volume/app.h>
void new_ramdisk (size_t len);
START_TEST (test_write0)
{
int err;
uint8_t mac_key[TSV_MAC_KEY_SIZE];
uint8_t encryption_key[TSV_ENCRYPTION_KEY_SIZE];
uint8_t buf[1024] = {0};
tsv... |
C | //
// Lab work #7, Count pi
//
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define ITERATIONS 2000000000
#define BILLION 1000000000.
typedef struct pi_state {
size_t pos;
size_t amount;
pthread_t thread;
double result;
} pi_state_t;
void* count_pi(void* ... |
C | #include "test.h"
static mat4 rnd = {{
{ 1, 2, 3, 4 },
{ 5, 6, 7, 8 },
{ 1, 2, 3, 4 },
{ 5, 6, 7, 8 },
}};
static mat4 cns = {{
{ 1, 2, 3, 4 },
{ 1, 2, 3, 4 },
{ 1, 2, 3, 4 },
{ 1, 2, 3, 4 },
}};
static void test_mmmul() {
printf("test mmmul:\n");
mat4 a = midentity();
ma... |
C | #include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <syslog.h>
#include <errno.h>
#include <stdlib.h>
#define MAX_LISTEN_NUM 5
#define SEND_BUF_SIZE 100
#define RECV_BUF_SIZE 100
#define SERVER_PORT 11010
int main()
{
int sock_fd = 0;
char recvbuf[RECV_BUF_SIZE] = {0... |
C | // String util
// Unsigned int to BCD (range 0 to 9999)
uint16_t uint2bcd(uint16_t binary) {
if (binary >= 9999)
return 0x9999;
uint8_t i3 = binary / 1000;
uint8_t i2 = binary / 100 % 10;
uint8_t i1 = binary / 10 % 10;
uint8_t i0 = binary % 10;
return (i3<<12) | (i2<<8) | (i1<<4) | i0;
}
// BCD to unsigne... |
C | #include <stdio.h>
int main(){
int k = 1048576;
int exec = 0;
while(k){
k /= 2;
exec++;
}
printf("%d\n", exec);
return 0;
}
|
C | /*
*
* File Name: Menu.c
* Name: Kensal J. Ramos
* Course: COP 2220C at Valencia College
* Instructor: David Stendel
* Description: This file will handle the processing of menus.
* Team Members: Kensal J. Ramos
* Date: November 21st - Menu file created
*
*
*/
#include <stdio.h>
#include <stdlib.h>
... |
C | #include <uapi/machine/cpufunc.h>
#include <uapi/machine/io.h>
#include <uapi/console.h>
#include <string.h>
#define BACKSPACE 0x100
static void cga_putc(void *arg, int c)
{
uint16_t *crt = arg;
int pos;
/* cursor position: col + 80*row */
outb(PORT_CRT, 14);
pos = inb(PORT_CRT + 1) << 8;
out... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_len.c :+: :+: :+: ... |
C | typedef struct{
int posX;
int posY;
int ** movimientos;
int cantmovs;
}tipoF;
/*Guarda la posición de la ficha encontrada al azar y las direcciones en las que puede moverse.
**Sirve únicamente para el juego contra la computadora*/
struct infoTablero{
char **Mapa;
int Fil;
int Col;
};
/*Guarda la inf... |
C | #include <stdio.h>
//#include<conio.h>
#include <stdlib.h>
struct hash *ht = NULL;
int eCount = 0,ccount=0;
char l[100];
struct node {
int key;
struct node *next;
};
struct hash {
struct node *head;
int count;
};
struct node * createNode(int key)
{
struct node *newnode;
newnode = (struct node *)mal... |
C | #include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <ctype.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <unistd.h>
int add(int a, int b);
int sub(int a, int b);
int mul(int a, int b);
int divi(int a, int b);
// TCP server
int main(){
// Cr... |
C | #include <stdio.h>
#include <unistd.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/types.h>
#include <errno.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#define SHMKEY 0x40
#define SHMSIZE 100
main()
{
int shmid;
int* array;
int i;
if( (shmid = shmget( (key_t)SHMKEY , SHMSIZE , ... |
C | /*
* Copyright (c) 2006 Dustin Sallings <dustin@spy.net>
*/
#include <math.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include "tl_hashtable.h"
/* Table of 32 primes by their distance from the nearest power of two */
static size_t prime_size_table[] = {
3, 7, 13, 23, 47, 97, 193, 383, 769, ... |
C | /*
============================================================================
Name : voiwel.c
Author : abubakr
Version :
Copyright : Your copyright notice
Description : Hello World in C, Ansi-style
============================================================================
*/
#include <std... |
C | #include <stdio.h>
typedef struct student {
char name[20];
int Kor, eng, mat;
double ave;
} STUDENT;
void main() {
STUDENT s1 = { "", 100,100,100,0.0 };
STUDENT s2 = { "ڳ", 90,80,88,0.0 };
STUDENT s3 = { "̸", 45,32,44,0.0 };
STUDENT* std[] = { &s1, &s2, &s3 };
for (int i = 0; i < 3; i++) {
std[i]->ave = (... |
C | #include<stdio.h>
int binarySearch(int arr[], int n, int key) {
int l=0,h=n-1,mid;
int bool = 0;
while(l<=h) {
mid = (l+h)/2;
if(key == arr[mid]) {
bool =1;
return mid;
}
else if(key > arr[mid]) {
l = mid +1;
}
else {
h = mid -1;
}
}
if(bool == 1) {
return mid;
... |
C | //WAP to Bubble Sort.
#include <stdio.h>
int main(void)
{
int n;
printf("Enter the Number of elements in the array: ");
scanf("%d", &n);
int data[n], temp;
printf("Enter the elements of the array to be sorted: \n");
for(int i=0; i<n; i++)
{
scanf("%d", &data[i]);
}
for(int i=0; i<=n-2; i++)
{
for(int j=... |
C | /**************************************************************************/
/* INCLUDES */
/**************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
/*******************************************************... |
C | #include <elf/elf.h>
#include <string.h>
#include <inttypes.h>
int
elf32_checkFile(Elf32_Ehdr *file)
{
if (file->e_ident[EI_MAG0] != ELFMAG0
|| file->e_ident[EI_MAG1] != ELFMAG1
|| file->e_ident[EI_MAG2] != ELFMAG2
|| file->e_ident[EI_MAG3] != ELFMAG3)
return -1; /* not an elf file */
if (file->e_id... |
C | #include "apue.h"
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
//#define SHM_MODE 0600 /* user read/write */
int main(int argc, char *argv[]) {
int row = atoi(argv[1]);
int columns = atoi(argv[2]);
int column = atoi(argv[3]);
char* charma... |
C | #include <rest/curl_output.h>
size_t curl_output_write_data_overwrite(char* restrict buffer, size_t size, size_t nmemb, void* restrict userp) {
size_t input_size = size * nmemb;
curl_output* output = (curl_output*)userp;
if(input_size + 1 > output->allocation_length){
output->memory = (char*)realloc(output->... |
C | #include <stdio.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <pthread.h>
#include <dirent.h>
#include <errno.h>
#include <semaphore.h>
#define SOD "SOD"
#define EOD "EOD"
#define SOC "SOC"
#define EOC... |
C | #include <stdio.h>
int main() {
char * p = " are going to the park.\n";
FILE * fp;
fp = fopen("output.txt", "w+");
fputs("Mary and Paul", fp);
fseek(fp, 5, SEEK_SET);
fputs("is", fp);
p += 4;
fputs(p, fp);
fclose(fp);
return(0);
}
|
C | #include"factory.h"
void send_file(int sfd)
{
data d;
int fd;
fd=open(DOWNLOAD,O_RDONLY);
if(-1==fd)
{
perror("open");
exit(-1);
}
memset(&d,0,sizeof(d));
d.len=strlen(DOWNLOAD);
strcpy(d.buf,DOWNLOAD);
send_n(sfd,(char*)&d,d.len+4);
while(1)
{
memset(&d,0,sizeof(d));
d.len=read(fd,d.buf,sizeof(d.b... |
C | #include <stdio.h>
#include <math.h>//因为sqrt属于math.h的工具,而stdio.h不含这个,所以要添加
int main(void)
{
//计算一元二次方程
int a = 1; //赋值
int b = -678;
int c = 5;
double delta; //deltac存放b^2—4*a*c
double x1;
double x2; //存放x1 x2的值
delta = b * b - 4 * a * c;
if (delta > 0)
{
x1 = ((-b) + sq... |
C | //Linked-List
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <time.h>
int tot_blocks, n_files, empty_blocks;
int initialize(bool blocks[], int next[], int SB[], int EB[])
{
for (int i = 0; i < tot_blocks; i++)
{
blocks[i] = false; // 0 - block free
next[i] = -1; ... |
C | /**
* グラフィック液晶モジュールAQM1248のテンプレートライブラリ
*/
#if defined(__AVR__)
# include <avr/pgmspace.h>
# include <util/delay.h>
#elif defined(__linux__)
# include <unistd.h>
# define pgm_read_byte(a) (*(a))
# define _delay_ms(x) usleep((x) * 1000)
#else
# error ""
#endif
#include "libglcd.h"
/*================================... |
C | #include "hash.h"
#include <stdio.h>
#define ERRO_NUMERO_DE_ARGUMENTOS 1
#define MAX_TAM_LINHA 1000000
#define MAX_TAM 2500
int comparPalavras(const void *p1, const void *p2)
{
const char **ip1 = (const char **)p1;
const char **ip2 = (const char **)p2;
return strcmp(*ip1, *ip2);
}
int main(int ar... |
C | #include <stdio.h>
int main()
{
int andar[3], a1, a2, a3;
scanf("%d %d %d", &a1, &a2, &a3);
andar[0] = 2 * a2 + 4 * a3;
andar[1] = 2 * a1 + 2 * a3;
andar[2] = 2 * a2 + 4 * a1;
if (andar[0] <= andar[1] && andar[0] <= andar[2])
{
printf("%d\n", andar[0]);
}
... |
C | /*
* serveur.c
*
* Created on: 8 mars 2016
* Author: Quincy
*/
#include <stdio.h> /* printf */
#include <stdlib.h> /* system, NULL, EXIT_FAILURE */
#include <unistd.h>
#include <fcntl.h>
#include <sys/file.h>
#include <sys/socket.h> /* socket, bind*/
#include <sys/select.h> /* select */
#include <sy... |
C | #include <stdio.h>
int main(void)
{
int arr[][3] = {1,2,3,4,5};
int (*p)[3] = arr;
printf("%d\n", *(*(p+1)+3));
long long int pop = 100000000000000023;
float f1 = 3.4E39,f2 = 1.2323212327812;
printf("%lld,%e,%f\n",pop,f1,f2);
getchar();
return 0;
}
|
C | /* mqtt4modbus
* modbus tcp/rtu via mqtt
* author: daixijiang@gmail.com
*/
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <modbus.h>
#include "common.h"
typedef struct
{
const char *address; /* ttySN*/
int baudrate;
modbus_t *ctx;
int slaveid;
} mbslave_t;
mbslave... |
C | /* GROUP No. 29
2017A7PS0004P -- SUBHAM KUMAR DASH
2017A7PS0036P -- RAHUL JHA
2017A7PS0084P -- ANIRUDDHA JAYANT KARAJGI
2017A7PS0128P -- MEET KANANI
2017A7PS0193P -- AYUSH GARG
*/
#include "parser.h"
#include "lexer.h"
#include "ast.h"
#include "semanticAnalyzer.h"
#include "symbolTable.h"
#incl... |
C | #include <stdio.h>
#include "user.h"
/*
ԴļʹõԶ庯
*/
extern int tot, N, vote_end;
extern struct user user[100];
extern int choice_main, choice_admin, choice_logon_regist, choice_user;
extern char name[20], phone[12], passwd[20];
extern char search_name[20];
/*
βΣuserûݵĽṹ飻totܳ
ֵ
ܣʾÿһͨûϢ
*/
void information_user... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* free.c :+: :+: :+: ... |
C | #include <ctype.h>
#include <errno.h>
#include <signal.h> // This is new!
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#define BUFFER_SIZE 80
// Because of space delimiters, the max number of arguments can be estimated.
#define ARG_NUM (BUF... |
C | #include <stdio.h>
int main(void)
{
int arr[5] = {1,2,3,4,0};
int len = sizeof(arr) / sizeof(arr[0]);
int i = 0;
int index = 0; //插入到数组的头部的情况
//从倒数第二个元素开始向右移动
for (i = len - 2; i >= index; i --)
{
//后一个元素的内容等于前一个元素的内容
//第一次循环: 1,2,3,4,4 4向右移动
//第二次循环: 1,2,3,3,4 3向右移动
//第三次循环: 1,2,2,3,4 2向右移动
//第四次循... |
C | #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
/* create a barrier */
pthread_barrier_t barrier;
/* normal thread */
void* robot_worker(void *arg)
{
for(;;)
{
char* msg = (char *)arg;
puts(msg);
pthread_barrier_wait(&barrier);
/* advancing... |
C | #include <stdio.h>
#include "../memory.h"
#include "../processor.h"
#include "../alu.h"
#include "jump_00_modeless.h"
#include "jump_00_default.h"
/* Jump based on aaa for an assorted group of mostly 'modeless' instructions */
static void jmpMod(unsigned char aaa, unsigned char bbb, unsigned char cc)
{
jump_00_mode... |
C | #include <stdio.h>
#include <stdlib.h>
struct lista{
int valor;
struct lista *proximo;
};
//Funo que retorna endereo de um ponteiro que aponta para uma struct lista.
struct lista *procurarValor(struct lista *pLista, int valor){
//recebe membro da lista concatenada pLista.
while(pLista != 0){
//se o ponteiro pLis... |
C | #include<stdio.h>
int main()
{
int n;
scanf("%d", &n);
getchar();
char a[100][100];
for(int i=0;i<n;++i)
{
for(int j=0;j<n;++j)
{
scanf("%c", &a[i][j]);
}
getchar();
}
int ocounter=0;
for(int i=1;i<n-1;++i)
{
ocounter=0;
for(int j=1;j<n-1;++j)
{
if(a[i-1][j]==... |
C | /*
* Pseudo Character Driver.
* Works on memory area.
*/
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/kdev_t.h> /* MAJOR(), MINOR() macros*/
#include <linux/cdev.h> /* struct cdev */
#include <linux/export.h> /* THIS_MODULE */
#include <linux/device.h> /* class_create(), device_create() */
#inclu... |
C | /**
* Name: Sal Penza
* Lab: Lab 3
* Date: 2/19/2020
**/
#include "person.h"
LIST *head = NULL, *tail = NULL;
void inputPersonalData(PERSON *person)
{
// TODO implement the function
// or check out part 9 of the c tutorial ;)
scanf("%s", person->name);
scanf("%d", &person->age);
scanf("%f", &pe... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* run_bin.c :+: :+: :+: ... |
C | #include "threadpool.h"
#ifndef REF
#define REF(x) &(x)
#endif
void *threadpool_worker(void *tp)
{
//Get the thread pool pointer
threadpool_t *threadpool = (threadpool_t*) tp;
//The task to be executed
task_t *task;
for( ; ; ) {
//Aquire lock
pthread_mutex_lock(REF(threadpool->mutex));
//Wait for an ava... |
C | #include <stdio.h>
#include <malloc.h>
int main()
{
int s;
int i = 0, j = 1;
int *a;
printf("enter array's size: ");
scanf_s("%i", &s);
a = (int*)malloc(s * sizeof(int));
while (i<s)
{
a[i] = j;
j += 2;
i++;
}
printf("array A { ");
for (i = 0; i < s; i++)
{
printf("%i "... |
C | #ifndef MAP_H
#define MAP_H
#include "../color/color.h"
#include "../point/point.h"
#include "../boolean/boolean.h"
#include "../building/building.h"
#include "../unit/unit.h"
/* Ukuran minimum dan maksimum baris dan kolom */
#define MapBrsMin 1
#define MapBrsMax 15
#define MapKolMin 1
#define MapKolMax 45
typedef s... |
C | #include <func.h>
typedef struct{
pthread_mutex_t mutex;
long tickets;
}thData;
void* threadfunc1(void *p) {
thData *p1=(thData*)p;
while(1){
pthread_mutex_lock(&p1->mutex);
if(p1->tickets>0){
printf("I am windows1,I will sale tickets %ld\n",p1->tickets);
... |
C | #include <iostream>
using namespace std;
int main() {
int age;
cout << "How old are you? ";
cin >> age;
cout << "Thank you. You are ";
cout << age * 365 * 24 * 60 * 60;
cout << " seconds old." << endl;
return 0;
}
|
C | //NMEC: ...
//NOME: ...
//
// Joaquim Madeira, AlgC, May 2020
// João Manuel Rodrigues, AlgC, May 2020
//
// Adapted from an old example (ca. 2003)
//
// Binary Search Tree storing pointers to items --- Simple Version
//
//// PROCURE ... E COMPLETE ////
#include "BSTree.h"
#include <assert.h>
#include <stdio.h>
#inc... |
C | #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
/*
* node structure.
*/
struct node {
struct node *next;
int data;
};
extern struct node *node_create(int data);
extern void node_free(struct node *n);
extern int list_lenght_get(struct node *list);
extern struct node *link_list_intersect(struct node *li... |
C | /* Напишите программу, которая запрашивает у пользователя ввод количества
дней и затем преобразует это значение в количество недемь и дней. Например,
18 дней программа должна преобразовать в 2 недели и 4 дня. Отображайте результаты
в следующем формате:
18 дней составляют 2 недели и 4 дня.
Чтобы пользователь мог многокр... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_intlarg.c :+: :+: :+: ... |
C | #include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <string.h>
#include "ksmall.h"
static void swap(int *, int *);
static int comparator(const void *, const void *);
static size_t smallest_index(int *, size_t);
static size_t largest_index(int *, size_t);
static size_t partition(int ... |
C | #include <string.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <stdio.h>
/*返回str2第一次出现在str1中的位置(下表索引),不存在返回-1*/
int indexOf(char *str1,char *str2)
{
char *p=str1;
int i=0;
p=strstr(str1,str2);
if(p==NULL){
return -1;
... |
C | /* compile with gcc -o msHOT msGCHOT.c streecGCHOT.c rand1.c -lm */
/*same as ms.c but with mutliple crossover and geneconv hotspots addition */
/***** ms.c ************************************************
*
* Generates samples of gametes ( theta given or fixed number
* of segregating sites.)
* Usage i... |
C | //
// Created by csatl on 5/5/2020.
//
#include "hashTable.h"
#include "io.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
void initHashTable(int N)
{
//! initialize hash table with length "INITIAL_HT_SIZE_FACTOR" of N (1/4 of N)
size = (INITIAL_HT_SIZE_FACTOR * N);
hashTable = (char**)mallo... |
C | #include <stdio.h>
int main()
{
int c;
for(c=1;c<=5;++c){
for(int j=1;j<=c;j++){
printf("*");
}
printf("\n");
}
return 0;
} |
C | #include <stdio.h>
int main ()
{
int i = 171;
float f = 3567.654;
printf ("Principais caracteres de formatao em C:\n\n");
printf ("%%c\t\tCaracter\n");
printf ("%%d ou %%i\tInteiro\n");
printf ("%%e ou %%E\tNotao cientfica\n");
printf ("%%f\t\tFloat\n");
printf ("%%o\t\tOctal\n");
printf ("%%s\... |
C | // RUN: %tool "%s" > "%t"
// RUN: %diff %CORRECT "%t"
int main() {
int x;
x = ((1 + 1) <= (0 + 2));
assert x == 1;
x = 5 != 7;
assert x == 1;
x = x + (x == x) == !(x != x) + x - 1 + 1;
assert x == 1;
x = 1 << 2;
assert x == 4;
x = 1 << 3;
assert x == 7 + 1;
x = 1 << 31;
assert x == 2147483648;
x =... |
C | /*
* Copyright (c) 2012 Roland Philippsen <roland DOT philippsen AT gmx DOT net>
*
* BSD license:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyrigh... |
C | /*
* cutmorph.c
*
* Created on: 2013/11/01
* Author: IwabuchiK
*/
#ifndef STDIO_H
#define STDIO_H
#include <stdio.h>
#endif
#ifndef STRING_H
#define STRING_H
#include <string.h>
#endif
#ifndef D_1_H
#define D_1_H
#include "d_1.h"
#endif
#define MAX 65535 * 3
int getsource(char *s);
int main()
{
char... |
C |
void adjListInit(int N){
for(i=1;i<=N;i++){
for(j=1;j<=N;j++){
graph[i][j] = 0;
}
}
}
void printInitAdj(int N){
for(i=1;i<=N;i++){
for(j=1;j<=N;j++){
printf("%d ",graph[i][j]);
}
printf("\n");
}
}
void graphEdges(){
for(i=1;i<=edge;i++){
for(j=1;j<=edge;j++){
scanf("%d%d"... |
C | #include<stdio.h>
int main()
{
int n,a[50],b[50],count=0;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
int large;
large=a[0];
for(int i=0;i<n;i++)
{
if(large<a[i])
large=a[i];
}
for(int i=0;i<n;i++)
{
if(large==a[i])
count++;
}
for(int i=0;i<count;i++)
{
b[i]=large;
}
for(int i=0;i<n;i++)
{
if(a[i]!=lar... |
C | #ifndef __COMMANDS_H
#define __COMMANDS_H
#include "ws2801.h"
// GRAPHIC + COMMAND TYPES
// mode / command enum
enum mode_t {
MODE_FADE = 0,
MODE_STROBE = 1,
MODE_CHASE = 2,
MODE_RAINBOW = 3
};
// primitives
// used by FADE mode
struct fade_info_t {
color_t start, finish; // colours to fade between
ui... |
C | #include "./tests.h"
static void child_main(libforks_ServerConn conn, int socket_fd) {
(void)socket_fd;
(void)conn;
exit(23);
}
int main() {
libforks_ServerConn conn;
check(libforks_start(&conn) == libforks_OK);
int exit_fd;
pid_t child_pid;
libforks_Result r = libforks_fork(
conn,
&child... |
C | /*
* Modellierung dynamischer Systeme
* Praktikum 1
* Teil 1
*
* Lösung steifer Differentialgleichungen
*
* y' = 10 - 500 * y + 5000 * x y(0)=1
*/
#include <chplot.h>
#include <math.h>
#define h 0.001
#define x_End 0.2
double Ableitung(double x, double y){
return 10 - (500*y) + (5000*x);
}
double Ableit... |
C | #include<stdio.h>
#include<conio.h>
void main()
{
char g1[100],g2[100];
int res;
clrscr();
printf("Enter g1 and g2:");
gets(g1);
gets(g2);
res=strcmp(g1,g2);
if(res==0)
printf("Strings are equal");
else
printf("Strings are not equal");
getch();
}
int strcmp(char *g1,char *g2)
{
int i=0;
while(g1[i]!='\0'||g2[i]!='\0')
... |
C | #include "date.h"
#include "tldlist.h"
#include <stdio.h>
#include <string.h>
#define USAGE "usage: %s begin_datestamp end_datestamp [file] ...\n"
static void process(FILE *fd, TLDList *tld) {
char bf[1024], sbf[1024];
Date *d;
while (fgets(bf, sizeof(bf), fd) != NULL) {
char *q, *p = s... |
C | //CPE-400
//SECTION: 1001
//Luis Ruiz
//Client code
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#define TRUE 1
#define FALSE 0
//display error messages
void error(char *msg)
{
perror(msg)... |
C | //if else ladder - with no return type and no argument
#include<stdio.h>
#include<conio.h>
void fun();
void main()
{
clrscr();
fun();
getch();
}
void fun()
{
int a,b,c;
printf("enter the numbers ");
scanf("%d%d%d",&a,&b,&c);
if(a>b && a>c)
{
printf("a is greater : %d",a);
}
else if(b>c && b>a)... |
C | #include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
void greeting(char name [150]){
printf("hello %s",name);
}
int main(){
hello();
char myname[150];
gets(myname);
greeting(myname);
return ... |
C | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int i, numero, par = 0, impar = 0;
printf("Insira 200 números:\n");
for(i = 0; i < 200; ++i)
{
scanf("%d", &numero);
if (numero % 2 == 0)
{
++ par;
}
else
{
++ impar;
}
}
printf("A quantidade de nú... |
C | #include <stdio.h>
void main()
{
int m;
for (m = 5; m < 8; m++) { /* m 5 ~ 7 3ȸ ݺ */
if (m == 6) continue; /* m 6 continue Ѵ */
printf("m(%d)\n", m);
}
} |
C | #include<stdio.h>
int main() {
int k,d;
scanf("%d%d",&k,&d);
int i;
if(d==0){
if(k==1){
printf("0\n");
}else{
printf("No solution\n");
}
}else{
//d大于等于k就够分了!
//以平均值的办法去分!
while(1){
if(d>=k)break;
d=d*10;
}
int average=d/k;
int more=d-average*k;
printf("%d",average+more);
for(i=0;i... |
C | #define _CRT_SECURE_NO_WARNINGS
//#include<stdio.h>
//#include<string.h>
//#include<stdlib.h>
//#include "slist.h"
////linecode* Listsort(linecode* head, lineconttype x)
////{
//// linecode *newhead = NULL, *cur = head, *fron = NULL, *cur1;
//// //newhead
//// if (head->cont < x)
//// {
//// newhead = head;
//// whil... |
C | //Program to understand synchronization among the processes using the unnamed semaphores
#include<stdio.h>
#define MAX_VAL 10000000
#include<pthread.h>
#include<stdlib.h>
#include<sys/ipc.h>//for ftok()
#include<sys/shm.h>//for shmget(),shmat(),shmctl(),shmdt()
#include<sys/wait.h>//for waitpid()
#include<unistd.h>//fo... |
C | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <omp.h>
#include <time.h>
void Read_file(char* File_name, int Count ,int *stars);
void calculate_gravitational_force(int Count ,int *stars,double gravitational_force_list[],int treat_count);
double calculate_distance(int *stars,int main_star_index,int o... |
C | #include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <locale.h>
#include <math.h>
void bubble_sort();
void comb_sort();
void merge();
void mergeSort();
void ed_cnts(double* sv, long* cnts, long N)
{
unsigned short i;
unsigned char* bp = (unsigned char*)sv;
unsigned char* svEnd = (unsigned char... |
C | #include <stdio.h>
#include <stddef.h>
//structure of the employee table
typedef struct
{
/* data */
long number; //four bytes
char *name; //four bytes
char *phone; //four bytes
double salary; //eight bytes
} Employee, *PtrToEmployee; // two variable names
// once initialized, cant be change... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.