language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
/** \file */ /* \amodel apop_mixture The mixture model transformation: a linear combination of multiple models. Generated via \ref apop_model_mixture. Note that a kernel density is a mixture of a large number of homogeneous models, where each is typically centered around a point in your data. For such situations,...
C
#include<stdio.h> #include<string.h> #include<stdlib.h> int main(void) { int num=0; int * prime; int flag=0; printf("양수 입력 : "); scanf("%d",&num); prime=(int*)malloc(sizeof(int)*num-1); prime[num-2]=0; for(int i=2;i<num;i++) { prime[i-2]=i; for(int j=2;j<i;j++) { if(i%j==0) { // printf(" i ...
C
/****************************************************************************** * Copyright (C) 2017 by Alex Fosdick - University of Colorado * * Redistribution, modification or use of this software in source or binary * forms is permitted as long as the files maintain this copyright. Users are * permitted to mod...
C
// // main.c // Minimum Spanning Tree // // Created by Swarup Ghosh on 07/11/19. // Copyright © 2019 Swarup Ghosh. All rights reserved. // #include <stdio.h> #include <stdlib.h> #include <limits.h> #include "charset.h" int prims(int **graph, int len_vertices, int start_vertex) { CHARSET v, s; init(&v); i...
C
#include <stdio.h> #include <ctype.h> #include <math.h> #include <string.h> #include <limits.h> /* Chapter 5.1 */ /* pointers cannot be applied to expressions constants or register variables */ /* Chapter 5.2 */ /* */ /* Chapter 5.3 */ /* There is one difference between an array name and a pointer that must be ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include "queue.h" struct Node{ NumericItemP item; struct Node* next; }; void initQueue (Queue **queue) { if (queue == NULL) return; *queue = (Queue *)malloc(sizeof(Queue)); (*queue)->first = NULL; (*queue)->last = ...
C
// // main.c // Pointers Training // // Created by Mironov Oleg on 05.01.16. // Copyright © 2016 Mironov Oleg. All rights reserved. // #include <stdio.h> #include <stdlib.h> void basicPointers(); void arrayPointers(); void stringPointers(); void heap(); int main(int argc, const char * argv[]) { basicPointers()...
C
typedef char *VA; typedef struct MemoryRegions { VA startAddr; VA endAddr; size_t size; int isReadable, isWritable, isExecutable, isPrivate; off_t offset; unsigned int long device_id_major, device_id_minor, inode_number; char name[1024]; } __attribute__((packed)) MemoryRegion; char mtcp_readchar(int fd) { ch...
C
#include "hyperbolic_geodesics.h" void companion_inverse(size_t nb_vectors, size_t nb_coordinates, double complex* v_all, double complex *p){ size_t i,j; double complex aux; for(i=0; i<nb_vectors; ++i){ aux = v_all[i]; for(j=0; j<nb_coordinates-1; ++j) v_all[i + nb_vectors*j] = v_all[i+nb_vectors*...
C
#include <stdio.h> main() { int *pnum; int *pnum2; int suma; int num; int num2; num=0; num2=0; suma=0; printf("Introduce un numero:"); scanf("%d",&num); printf("Introduce otro numero:"); scanf("%d",&num2); pnum=&num; pnum2=&num2; suma=*pnum+*pnum2; printf("La suma de %d y %d es: %d", num,num2,suma); }
C
#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { char *arg_directory = NULL; char *arg_prefix = NULL; if(argc != 3) { fprintf(stderr, "usage: %s <directory> <prefix>\n", argv[0]); exit(1); } //사용자로부터 임시파일을 생성할 디렉터리를 입력받음 //공백을 입력받는 경우 NULL을 저장하여 시스템이 설정 arg_directory = argv[1][0] ...
C
#include <unittest.h> #include SOURCE_C /* * rn2483_poll_gpio() marks all of the radio module GPIO pins that have been * explicitely configured as */ static struct rn2483_desc_t radio_descriptor; #include "rn2483_service_stubs.c" static void reset (void) { sercom_uart_has_line_call_count = 0; executed_...
C
#include <stdio.h> int main(){ int count,c = 0,n,temp,t,ans; scanf("%d",&count); while(c < count){ c++; ans = 1; scanf("%d",&n); int T[n][n]; for(temp = 0;temp < n ;temp++){ for(t = 0;t < n;t++){ scanf("%d",&T[temp][t]); } } for(temp = 0;temp < n;temp++){ for(t = temp;t < n;t++){ if((T[t][...
C
#include <sys/types.h> #include <dirent.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #define BUFFSIZE 32768 int main(int argc, char **argv) { char filename[80]; char buf[BUFFSIZE]; int n; int name_length; /* * * * given code * * * ...
C
/*5. Write a C program to read the data from hyper terminal and Print the same on LCD panel.*/ #include<avr/io.h> #include<avr/interrupt.h> #include<util/delay.h> #define PRT PORTA #define RS 0 #define RW 1 #define EN 2 void delay_ms(int d); void delay(int d); void LCD_init(void); void goto_LC...
C
// 2 05 #include <stdio.h> int main(void) { int a[] = { 65,25,45,35,55 }; int i, j, tmp, n; n = sizeof(a) / sizeof(int); puts("---------------------"); puts(" * * "); puts("---------------------"); // puts(" ** **"); for (i = 0; i < n; i++) printf("a[%d] = %d \n", i, a[i]); // (Selection sort) ...
C
/* mpu9250.c * Control routines for Invensense MPU-9250 9-axis IMU */ #include "mpu9250.h" // Read two sequential 8-bit registers and return the 16-bit value // Assumes that the high byte is in the lower register (first to be read out) s16 mpu_read_reg16(u8 addr) { // Send the address XIic_Send(I2C_BASEADDR, I2C_...
C
#include "led.h" #include <libopencm3/stm32/rcc.h> #include <libopencm3/stm32/gpio.h> void led_setup() { /* Enable GPIOC clock. */ rcc_periph_clock_enable(RCC_GPIOC); /* Set GPIO13 (in GPIOC) to 'output push-pull'. */ gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSH...
C
#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> void md5_to_str(uint8_t *md5, uint32_t len, uint8_t *str) { int i=0; for ( ; i<len; ++i) { snprintf(str, 3, "%02x", *(md5+i)); str += 2; } } void str_to_md5(uint8_t *str, uint32_t len, uint8_t *md5) { int i...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> void newp(const int el){ int mas[el]; int ch; for(ch=0; ch<el;ch++){ mas[ch] = rand() % 100; printf("%d ", mas[ch]); } } int main(int argc, char *argv[]){ srand(time(NULL)); int bl; scanf("%d", &bl); newp(bl); getch...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <conio.h> #define MAX_COL 80 #define MAX_ROW 25 #define BREAK_COL 62 #define BREAK_COL_C 12 int c_row, c_col; FILE *in, *out; char *data = NULL; void print_table(void); void in_store(void); void out_store(void); void disp_store(void); void clear_dis...
C
#include <stdio.h> #include <stdlib.h> typedef struct node { int data; struct node *next; } Node; void detect_removeLoop(Node *head) { Node *slow = head; Node *fast = head; while (slow && fast && fast->next) { slow = slow->next; fast = fast->next->next; if (slow == ...
C
#ifndef UTILS_H #define UTILS_H /* * Function returns least common denominator of two numbers. */ int LeastCommonDenominator(int a, int b); /* * Function returns greatest common divisor of two numbers. * Euclid's algorithm for integers is used. */ int GreatestCommonDivisor(int p, int q); #endif /* UTILS_H */
C
#ifndef LIST_H #define LIST_H struct node { char *name; char *surname; char *bdate; char *email; long int contact; char *address; struct node *next; struct node *prev; } ; struct list { struct node *head; struct node *tail; }; struct list *init(void); struct node *create_node(char *n, char *s, char *b, c...
C
/* ------------------------------------------------------------------------ phase4.c University of Arizona South Computer Science 452 @authors: Erik Ibarra Hurtado, Hassan Martinez, Victor Alvarez ------------------------------------------------------------------------ */ #include <stdlib.h> #include...
C
/* Student Name=Sunil Giri Subject=Programming Fundamentals Roll No.= Program=to calculate factorial using do while loop. Lab No.=09 BCS Sem.=1st Date=26 oct,2016 */ #include<stdio.h> //#include<conio.h> int main(){ int n,fact,a; g: printf("Enter Number to calculate factorial:\n"); scanf("%d",&n); a=1; fact=1...
C
#include "common.h" int print_table(hash_t array[]) { int i; hash_t *temp; dulist *temp1; for (i = 0; i < SIZE; i++) { temp = &array[i];//.word_link; if(strcmp(temp->word,"#") == 0) { continue; } printf("index: %d\t", i); // printf("num of files: %d\t",temp->no_of_files); //printf("The word : ")...
C
#include "BST.c" BST_Node * BST_New_Node(int item); BST_Node * BST_Insert(BST_Node * node, int key); BST_Node * BST_Search(BST_Node * root, int x); BST_Node * BST_Min_Value(BST_Node * node); BST_Node * BST_Remove(BST_Node * root, int x); void BST_In_Order(BST_Node * root); void BST_Preorder(BST_Node * node); ...
C
#include <stdio.h> #include <stdlib.h> #include <SDL/SDL.h> #include "menu.h" #include "config.h" #include "structs.h" #include "widget.h" #include "cursor.h" int main(int argc, char * argv[]){ initSDL(); // Starts the SDL menu(); // Load main menu SDL_Quit(); // After menu did its job, stops SDL ret...
C
#include "fifo.h" // Tamar Bacalu & Mark Koszykowski // ECE357 - Operating Systems Problem Set 6, 2C void fifo_init(struct fifo *f) { f->readInd = 0; f->writeInd = 0; sem_init(&f->mutex, 1); sem_init(&f->empty, 0); sem_init(&f->full, MYFIFO_BUFSIZ); } void fifo_wr(struct fifo *f, unsigned long d) { sem_wait(&f...
C
#include <stdio.h> #include <stdlib.h> /*Crie um aplicativo em C que pea um nmero inteiro ao usurio N e exiba o n-simo termo da srie de Fibonacci, sabendo que o primeiro termo 0, o segundo 1 e o prximo nmero sempre a soma dos dois anteriores. Ex.: 0 1 1 2 3 5 8... Se o usurio digitar 4 o elemento da 4 posio o 2.*/...
C
#include <stdio.h> #include <stdint.h> #include <stdlib.h> struct node { int value; struct node *next; }; typedef struct node node_t; void print_llist(node_t *head) { node_t *temp = head; while (temp != NULL) { printf("%d - ", temp->value); temp = temp->next; ...
C
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> #include <curl/curl.h> #include "services/info_service.h" #define MAX 255 int main(int argc, char *argv[]) { char *url = getenv("REST_URL"); CURL *curl; CURLcode res; printf("Connects to API URL: %s\n", url); curl_g...
C
#include "biblioteca.h" #include <stdio.h> int main() { int *vet1, *vet2, taman1, taman2, teste; taman2 = 30; taman1 = 30; vet1 = (int *)calloc(taman1, sizeof(int)); vet2 = (int *)calloc(taman2, sizeof(int)); teste = EIgual(vet1, vet2, taman1, taman2); if (teste == 1) { prin...
C
#include <stdio.h> int main(void) { int a=10; if(a==1) { printf("a等于10"); } else { printf("a不等于10"); } return 0; }
C
/* * @lc app=leetcode id=53 lang=c * * [53] Maximum Subarray */ // @lc code=start #define tsmax(a,b)\ ({ __typeof__ (a) a_ = (a);\ __typeof__ (b) b_ = (b);\ a_ > b_ ? a_:b_; }) int maxSubArray(int* nums, int numsSize){ if (numsSize == 0) return 0; // base case int dp_0 = nums[0]; ...
C
#include <stdio.h> int results[] = {1, 0, 0, 2, 10, 4, 40, 92, 352, 724}; int main(int argc, char * argv[]) { int n = atoi(argv[1]); printf("%d\n", results[n-1]); return 0; }
C
#include<stdio.h> int main() { int c=1,i,count=0; for(i=0;i<100;i++) { if(c<=100) count++; //else //break; printf("%d ",c); c=c*2; } printf("\ncount=%d ",count); return 0; }
C
//Homework 1.21 #include <stdio.h> #include <stdlib.h> #include "files.h" int tabcheck(int j, int n); int main(int argc, const char* argv[]) { FILE* fin; FILE* fout; int n; int ok = openfiles(argc, argv, &fin, &fout, &n); if(ok == 1) { printf("Error, Usage: ./detab input output n"); ...
C
#include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include "mytoc.h" #include "saferFork.h" #include <string.h> #include <sys/wait.h> #include <sys/stat.h> int tokenLen(const char *token); char *concat(char *str,char *cmd,int lenght, int cmdLenght); int exitShell(char *input); int number...
C
#include <stdio.h> #include <stdlib.h> typedef struct node{ int value; struct node *next; } ListNode; void printList(ListNode *head); int removeNode(ListNode **ptrHead, int index); ListNode * findNode(ListNode *head, int index); int main() { ListNode *head = NULL, *temp; int num; printf("Enter a...
C
// Implements a dictionary's functionality #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <stdbool.h> #include <ctype.h> #include "dictionary.h" // Represents a node in a hash table typedef struct node { char word[LENGTH + 1]; struct node *next; } node; // Number of ...
C
/* * bmp085_tests.cpp * * Created: 2013-12-29 10:14:08 * Author: mikael */ #if BMP085_ENABLE==1 #include <avr/io.h> #include <stdbool.h> #include <util/delay.h> #include <avr/pgmspace.h> #include <stdio.h> #include "../drivers/bmp085_driver.h" #include "../drivers/TSL2561_driver.h" #include "../device/i2c_bus....
C
/* ** EPITECH PROJECT, 2018 ** interaction ** File description: ** rpg */ #include "rpg.h" static void right_click(battle_t *battle) { if (!battle->fight[battle->id]->enemy_turn && battle->hero->select) { if (battle->hero->spell_id != -1) cast_spell_attack(battle); else { deplacement(battle); attack(bat...
C
#include <stdlib.h> #include <stdio.h> #include <malloc.h> #include <string.h> #define togglebit(v, bit) v = v ^ (1<<bit) #define checkbit(a, v, bit) a = v & (1<<bit) typedef struct { char desc[60]; unsigned char potencia; unsigned int estado; }datos_t; typedef struct{ datos_t inf; int id; }d_a...
C
/* * Copyright (c) 2011 ITE Tech. Inc. All Rights Reserved. */ /** @file * USB HID Boot Protocol Mouse driver. * * @author Irene Lin * @version 1.0 */ #include <string.h> #include "ite/itp.h" #include "ite/ite_usbmouse.h" #include "usb/ite_usb.h" struct usb_mouse { char name[128]; struct usb_device* usbde...
C
/* ǽ 2 : fibonacciArray.c ۼ : 2019. 04. 10 ~ 04. 12 ۼ : 2016153 缺 α׷ : 迭 10 Ǻġ ϰ ϴ α׷ */ #include <stdio.h> // ó #define SIZE 10 // define ũ SIZE 10 void printArray(int arr[]); // 迭 ϴ printArrayԼ void setFiboArray(int arr[]); // 迭 Ǻġ ϴ setFiboArrayԼ int main(int argc, char* argv[]) { // mainԼ int arra...
C
#include "heap.h" int get_parent_index(HEAP *queue, int i) { return i >> 1; } int get_left_index(HEAP *queue, int i) { return i << 1; } int get_right_index(HEAP *queue, int i) { return (i << 1) + 1; } HUFF_NODE *item_of(HEAP *queue, int i) { return queue->data[i]; } bool is_empty(HEAP *queue) { ...
C
/****************************************** * ////Gomulu Sistemlerde String Islem Yapmayi Saglayan Kutuphane//// * Proje: OSKAR * Derleme: Mustafa zelikrs * ****/ #include <stdlib.h> #define STRING_BUF_SIZE 50 // maximum Grsse vom String #define USE_STR_FKT 1 // 0=nicht be...
C
#include <stdio.h> int ft_str_is_printable(char *str); int main(void) { char str1[] = " fdhhAAA | /%f1235`"; char str2[] = "ABCDE!á"; char str3[] = "aasr342AA433¬¬¬"; int validate; validate = 0; if (ft_str_is_printable(str1)) { printf ("1ª string has printable chars only : %s\n", str1); validate++; } ...
C
#include <stdio.h> #include "hash.h" main() { int ch,ret; char key[20]; hashItem_t *p; while(1) { printf("\n1.add Element to hash list"); printf("\n2.search Element in hash list"); printf("\n3.Exit"); printf("\nEnter choice:"); scanf("%d",&ch); switch(ch) { case 1: ...
C
#include <stdio.h> /* strcmp: return <0 if s<t, 0 if s == t, >0 if s>t */ int strcmp1(char *s, char *t) { int i; for (i = 0; s[i] == t[i]; i++) if (s[i] == '\0') return 0; return s[i] - t[i]; } int strcmp2(char *s, char *t) { for ( ; *s == *t; s++, t++) if (*s == '\0'...
C
#include <unistd.h> int comp(char *s1, char c, int index) { int i; i = 0; while(i < index) { if(s1[i] == c) return (1); i++; } return (0); } void inter(char *s1,char *s2) { int i; int j; i = 0; while(s1[i]) { if(comp(s1,s1[i],i) == 0) { j = 0; while(s2[j]) { if (s1[i] == s2[j]) ...
C
#include<stdio.h> #include<stdlib.h> #include<sys/types.h> #include<sys/socket.h> #include<netinet/in.h> #include<unistd.h> int main() { int server_socket; int error_check; char server_message[256]; char ping[10]; struct sockaddr_in client_address; socklen_t client_len; client_len = si...
C
#include <stdio.h> int main( void ) { int num; do { printf( "Enter a even number: " ); scanf( "%d", &num ); } while ( num % 2 != 0 ); puts( "Input accepted!" ); return 0; }
C
#include <pthread.h> #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <time.h> // use 4 for a quad processor, but try also with 1 and 2 threads // to check the running time and the system load // matrix dimension #define dim 1024 int thread_count; struct param { int start_line, end_line; }; in...
C
#ifndef LINKED_LIST_H #define LINKED_LIST_H #ifdef __cplusplus extern "C" { #endif typedef void linked_list; typedef void linked_list_iterator; // linked list linked_list * linked_list_new(); void linked_list_add(linked_list * ll, void * value); void * linked_list_get(linked_list * ll, int i); void linked_li...
C
/* flex integer type definitions */ #ifndef FLEXINT_H #define FLEXINT_H /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, * if you want the limit (max/min) macros for...
C
// // zad_8.c // // // Created by Student on 18.10.2017. // // #include <stdio.h> int silnia(int); int main() { int a; scanf("%d", &a); printf("%d\n", silnia(a)); return 0; } int silnia(int a) { if(a == 0) return 1; else return silnia(a-1)*a; }
C
/* ================================================================== * Universidade Federal de Sao Carlos - UFSCar, Sorocaba Disciplina: Algoritmos e Programação 2 Lista 02 - Exercício 01 - Coeficiente Binomial Instrucoes ---------- Este arquivo contem o codigo que auxiliara no desenvolvimento do exercicio....
C
/************************************************************** 1231번 jongtae0509 C 정확한 풀이코드 길이:268 byte(s) 수행 시간:0 ms 메모리 :1120 kb ****************************************************************/ #include<stdio.h> int main() { int a,b; char c; scanf("%d %c %d",&a,&c,&b); if(c=='+'){ printf("%d",a+b); } else...
C
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #define TAPE_SIZE (30000) static char tape[TAPE_SIZE] = {0}; static size_t get_file_size(FILE *fp) { fseek(fp, 0L, SEEK_END); size_t size = ftell(fp); fseek(fp, 0L, SEEK_SET); return size; }...
C
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // File name: pyramide.c // Author: Jan K. Schiermer // Created on: 27 Sep 2018 // Description: //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #include <stdio.h> #define LIMIT 250 int main(void) { c...
C
/** Inspired by the examples in * https://www.kernel.org/doc/Documentation/networking/can.txt */ #include <sys/socket.h> #include <net/if.h> #include <linux/can.h> #include <unistd.h> #include <stdio.h> #include <string.h> int main(int argc, char* argv[]) { if (argc == 2) { int s; s = socket(PF_CAN, SOCK_RAW, ...
C
/* ** EPITECH PROJECT, 2021 ** mylib ** File description: ** mylib */ #include "../../includes/client.h" static int info_thread(connect_t *con) { if (con->status != THREAD_INFO) return 0; char *uuid = cjson_get_by_key(con->res, "uuid"); char *title = cjson_get_by_key(con->res, "title"); char *...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.c :+: :+: :+: ...
C
#include <stdlib.h> #include <stdio.h> #define BUF_SIZE 2048 long int get_tail_pos(FILE* f, int tail_size){ fseek(f, 0, SEEK_END); char buf[BUF_SIZE]; long int file_size = ftell(f); long int pos = file_size; int remaining_lines = tail_size - 1; while(remaining_lines > 0){ int read_from; if(pos < BUF...
C
/* ** EPITECH PROJECT, 2019 ** prompt ** File description: ** key */ #include <string.h> #include <unistd.h> #include "prompt/keys.h" #include "prompt/cursor.h" int key_match(char const k1[4], char const k2[4]) { for (int i = 0; i < 4; i++) { if (k1[i] != k2[i]) return 0; } return 1; }...
C
/* #################################################### Demo Array size #######################################################*/ #include <stdio.h> # define MONTHS 12 int int_array[100]; float float_array[100]; double double_array[100]; char * string_array[100]; int main() { printf("Size of int array : %lu ...
C
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <math.h> #include "bit_array.h" #include "eratosthenes.h" #include "error.h" int main(int argc, char *argv[]){ //printf("primes\n"); ba_create(pole, 202000000); eratosthenes(pole); unsigned long primes[11] = { 0, }; //printf("primes end"); //ge...
C
#include "c_threadpool.h" void* pull_from_queue(void* arg){ Args* args = (Args*)arg; int thread_id = args->thread_id; Pool* pool = args->pool; char *act = (pool->thread_active + thread_id); //pop node from queue xNode* queue_item; while (1){ pthread_mutex_lock(&(pool->queue_guard_mtx)); while (!pool->queu...
C
#include<stdlib.h> #include<stdio.h> #define MAX 10 struct stack { int items[MAX]; int top; }; void push(struct stack*, int); int pop(struct stack*); void list(struct stack*); void main() { struct stack s; int c=1, ch, n; s.top=-1; while(c) { printf("main menu"); printf("\n 1. Push the element"); printf("\n 2. Pop the ...
C
/* * uC1_car.c * * Created: 11/30/2019 2:43:07 PM * Author : aahun */ #define F_CPU 8000000UL #include <stdint.h> #include <stdlib.h> #include <stdio.h> #include <stdbool.h> #include <string.h> #include <math.h> #include <avr/io.h> #include <avr/interrupt.h> #include <util/delay.h> #include <avr/eeprom.h> #includ...
C
#include <stdio.h> #define INIT_VALUE -1 int findSubstring(char *str, char *substr); int main() { char str[40], substr[40]; int result = INIT_VALUE; printf("Enter the string: \n"); gets(str); printf("Enter the substring: \n"); gets(substr); result = findSubstring(str, substr); if (resu...
C
#include<sys/ipc.h> #include<sys/shm.h> #include<sys/types.h> #include<stdio.h> #include<errno.h> int main() { //int shmget(key_t key, size_t size, int shmflg) int segment_id; struct shmid_ds shmbuffer; //create a new share menory object segment_id = shmget(IPC_PRIVATE, 128, IPC_CREAT|IPC_EXCL|0600)...
C
#include <stdio.h> #include <unistd.h> #include <sys/time.h> #include <sys/resource.h> extern void random_length_task(); int main(int argc, char **argv) { struct timeval tv; int times = 10; long long int last; if (argc > 1) sscanf(argv[1], "%d", &times); srand(time(0)); // setpriority(PRIO_PROCESS, getpid(),...
C
/* This is a naive implementation of Snelling's algorithm, ICS 1973 */ #include <stdio.h> #include <stdlib.h> #include "global.h" #include "parser.h" #include "driver.h" #include "grammar.h" static int trace = 1; /* ACCESS ROUTINES */ static int in_N(char n) { int i; for (i = 0; i < n_N; i++) { if (N[i]...
C
/*! * \file LivingColors.h * \version 1.1 * \date 29-01-2009 * \author George Mathijssen, george.knutsel@gmail.com * * Copyright (c) 2008, 2009 George Mathijssen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as pu...
C
#include <stdbool.h> typedef struct Stack { int stack[20]; int size; } Stack; bool stack_empty(Stack* stack); void push(Stack* stack, const int value); void pop(Stack* stack); int top(Stack* stack); int size(Stack* stack); void print(Stack* stack);
C
//Runtime:Runtime: 16 ms //Beats 64.61% int myAtoi(char* str) { int value = 0, sign = 1; while(*str == ' ') str++; if(*str == '+' || *str == '-') { sign = *str == '-' ? -1 : 1; str++; } while(*str >= '0' && *str <= '9') { if(value > INT_MAX / 10 || (value == INT_MAX / 1...
C
#include <stdio.h> int main() { int n; printf("請輸入班級人數:"); scanf("%d", &n); int a = n / 12; int b = n % 12; printf("總共需要付%d元\n", a * 50 + b * 5); return 0; }
C
#include "livestock.h" //Initializes a livestock struct with a name struct Livestock * sub_809B454(struct Livestock *lstock, u8 *name, u32 *param, u32 age, u32 daysFed){ sub_809B12C(&lstock->animal, name, param, age); lstock->daysFed = daysFed; lstock->fed = FALSE; lstock->unhappy = FALSE; lst...
C
#include <stdio.h> struct { int a; int b; }paper,image; void main(){ int t,p1,p2; //printf("%c",'%'); scanf("%d %d %d %d",&image.a,&image.b,&paper.a,&paper.b); while(image.a||image.b||paper.a||paper.b){ if(image.a<image.b&&paper.a>paper.b||(image.a>image.b&&paper.a<paper.b)) { t=paper.a;paper.a=paper...
C
#include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <string.h> int main(int argc, char **argv) { char buf[256], alpha[34], beta[34]; int j, plen, fd; if (argc < 2) { printf("usage: %s <keyfile>\n", argv[0]); return 1; } if (strlen(argv[...
C
#include "utils.h" #define MAX 50 size_t strindex(char *s, char *t) { char *i, *j, *k; for (i = s; *i != '\0'; i++) { for (j = i, k = t; *k != '\0' && *j == *k; j++, k++); if ((size_t)(k - t) > 0 && *k == '\0') { return (size_t)(i - s); } } return -1; }...
C
#include "lcd.h" /* * @function:数据不经过任何处理直接写进lcd屏幕 * @params: */ void write_lcd( char *bmp_buffer, struct RGB *jpg_info, char *fb, struct fb_var_screeninfo *vinfo) { bzero(fb, vinfo->xres * vinfo->yres * 4); int x,y; for(y=0; y<vinfo->yres && y<jpg_info->height; y++) { for(x=0; x<vinfo->xres && x<jpg_info...
C
// This program gives the output without declaring function prototype before main(), // its possible only in case of int return type function. #include<stdio.h> char fun(); void main(){ int a = fun(); printf("a = %d", a); // o/p => 10 if int fun() was there, and gives error // w...
C
#include<stdio.h> void main() { int gender,age,m,f; printf("enter the age& gender of the person\n"); scanf("%d\n",&age); if (gender==m,age>21) { printf("eligible to the marriage\n"); } else { printf("not eligible to the marriage\n"); } printf(t) } ]
C
#include <stdio.h> #define ElementType int void swap(ElementType *x, ElementType *y) { ElementType temp; temp = *x; *x = *y; *y = temp; } // get the left child of node under index with startup zero int leftChildFromZero(int index) { return index * 2 + 1; } // percolating down the element whe...
C
#include <stdio.h> #include <unistd.h> #define PI 3.14 void foo(void) { printf("%s\n", __func__); } int bar(void) { return 100; } int main(void) { printf("Hello, world!\n"); printf("%f\n", PI); foo(); printf("bar:%d\n", bar()); sleep(30); return 0; }
C
#include <stdio.h> typedef struct rashika { int a; } as; int main(){ as a1; struct rashika as; as.a = 5; as.a = 10; a1.a = 5; printf("%d\t%d ",a1.a,as.a); }
C
#include <stdio.h> #include <string.h> #include <stdlib.h> int max(int,int); int *multiplicamatriz(int *,int **,int); // Funcin recursiva que multiplica matrices int *suma(int *,int **,int); // suma de matrices int *resta(int *,int **,int);// Resta de matrices void libera(int **,int); // Libera memoria int main() { ...
C
#include <stdio.h> // #include <stdlib.h> void towers(int num, char frompeg, char topeg, char auxpeg) { if (num == 0) return; if (num == 1) { printf("Move disk 1 from %c peg to %c peg \n", frompeg, topeg); return; } else { towers(num - 1, frompeg, auxpeg, topeg); ...
C
// Use a switch case to convert newline and tab characters to visible chars #include<stdio.h> #include<stdlib.h> #define MAX 100 void expand(char* s, char* t); int main(void) { char s[MAX]; char t[MAX]; //Get input string from stdin fgets(s, MAX, stdin); expand(s, t); puts(t); } void expand(char...
C
#ifndef __LSTACK1_H #define __LSTACK1_H typedef struct lstack_st { void *bottom; void *top; int size; int capacity; }lstack_t; // 初始化栈 int lstackInit(int size,int capacity, lstack_t **ls); // 入栈 int lstackPush(lstack_t *ls, void *data); // 出栈 int lstackPop(lstack_t *ls, void *data); // 判断栈是否为空 int lstackEmpty(...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> #include <time.h> #include "SDL.h" #include "SDL_ttf.h" #include "utilities.h" #if (defined _WIN32) || (defined _WIN64) #pragma warning(disable:4996) #endif int gGameover = 0; char gMediaPath[256] = ""; ...
C
#include"method.h" #include<stdio.h> #include<stdlib.h> #include<time.h> // . #define MAX_BUF 512 typedef enum Player { PLAYER_1, PLAYER_2 }; char TTT_BOARD[3][3] = { { ' ',' ',' ' },{ ' ',' ',' ' },{ ' ',' ', ' ' } }; void show_board() { printf(" 1 2 3\n"); printf(" +---+---+---+\n"); printf(" ...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <ctype.h> #include <assert.h> #include "readData.h" #include "invertedIndex.h" #include "searchPagerank.h" //Get Word List Graph void invertedIndex(){ int numberURL = 0, wordCount = 0, NEWWORD; char str[100]; WordList word...
C
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<unistd.h> #include<sys/types.h> int main(){ printf("execl() function execution\n"); //print message execl("/bin/ls", "ls", "-l", NULL); //do execl ls -l printf("Error"); //print error if execl not working correctly return 0; }
C
/**************************************************************************//** * \file infoflash.c * \author Ben Boudaoud (bb3jd@virginia.edu) * \date Dec 20, 2013 * * \brief This file contains the TEMPO 4000 info flash management code * * This library provides a simple interface for reading and writing the MS...