language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> void main() { int minute,hour,minu; scanf("%d",&minute); hour=minute/60; minu=minute%60; printf("%d %d",hour,minu); }
C
#include <stdlib.h> #include <stdio.h> #include "linkList.h" /* * @brief This function is to initialize * the structure of linkList. * * @return *plinkList */ linkList *createdLinkList(){ linkList *plinkList = malloc(sizeof(linkList)); plinkList->head = NULL; plinkList->tail = NULL; plinkList->...
C
#define _GNU_SOURCE #include <sched.h> #include <stdio.h> #include <stdlib.h> #include <stddef.h> #include <stdint.h> #include <string.h> #include <stdbool.h> #include <unistd.h> #include <sys/mman.h> #include <time.h> #include <assert.h> #include "../include/custom_timing.h" void time_handler1(size_t timer_id, void*...
C
#include "ADC.h" static volatile uint16_t ADC_val = 0; static volatile uint8_t ADC_cnt = 0; static volatile uint16_t ADC_result = 0; void ADC_init() { /*Vref = AVCC*/ ADMUX |= _BV(REFS0); /*MUX3..0 = ADC6*/ ADMUX |= _BV(MUX2) | _BV(MUX1); /*ADC interrupt enable*/ ADCSRA |= _BV(ADIE); /*ADC enabled*/ ADCSRA |=...
C
#include <stdio.h> #define SERIAL_BUFFER_SIZE 16 #define SERIAL_BUFFER_SIZE_MASK (SERIAL_BUFFER_SIZE -1) struct serial_buffer { unsigned char head; unsigned char tail; unsigned char data[SERIAL_BUFFER_SIZE]; }; void debug_print_fifo( struct serial_buffer *fifo) { unsigned char i; printf("\nh...
C
#include <stdio.h> #include <math.h> #include <float.h> #define N 10000 int main(void) { int k, i = 0, ind; double t, s, h, x, err; h = 10*M_PI/N; for(i = 0; i <=N; i++) { x = i*h; s = 0.; t = 1.; k = 0; while(fabs(t) >= fabs(s)*FLT_EPSILON) { s += t; ...
C
#include <stdio.h> #include <stdlib.h> int main() { FILE* f; char msj[10]="hola a todos"; f=fopen("mihtml.html","w"); /**Estatico*/ if(f!=NULL) { // fprintf(f,"<html><head> Hola </head></html>"); // mensaje hardcodeado fprintf(f,"<head><html>"); fprintf(f,msj);// parte variable d...
C
/* * life.c - Conway's Game of Life * * Read about the game at https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life * * compile with * mygcc life.c -lcurses -o life * run with * ./life [startboard.txt] * where the optional file has lines of text containing only the letter 'O' * and spaces, and no line lo...
C
#include "header.h" /* MAKE TREE */ void makeTree(char c, tree *T){ simpul *node; node = (simpul *) malloc(sizeof (simpul)); node->info = c; node->right = NULL; node->left = NULL; (*T).root = node; } /* ADD */ //=== right ===// void addRight(char c, simpul *root){ count_root++; if(root->right == NULL){ ...
C
#include "utils.h" /** * Implementing a 0-indexed heap * Needed for efficient implementation of event priority queue * to simulate when events like a process arriving or the CPU finishing * computing a process happens */ struct EventHeap *createPriorityQueue(int capacity) { struct EventHeap *priority_queue = ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/file.h> #include <fcntl.h> #define MEMSZ 200 * 1024 * 1024 int main( int argc, char **argv ) { int fd; char *p, *path = getenv("PATH_INFO"); if( path && strncmp( path, "/lock", 5 ) == 0 ){ if( ( ...
C
#include <stdio.h> int main (){ int arr[2][3][5]={2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60}; int l,m,n; for(l=0; l<2;l++){ for(m=0;m<3;m++){ for(n=0;n<5;n++){ printf("Arreglos [%d][%d][%d]: %d\n", l,m,n,arr[l][m][n]); } } } return 0; }
C
#include <stdio.h> #include "sorts.h" int main(int argc, char *argv[]){ int a[6] = {2,6,3,4,5,1}; int b[6]; int c[6]; for(int q = 0; q < 6;q++){ b[q] = a[q]; c[q] = a[q]; } List nList = create_list(a,6); merge_sort_list(&nList); ListNode *trav = nList.head; while(trav != NULL){ printf("%d", trav -> valu...
C
#include "../include/table_operations.h" #include "../include/jhash.h" #include <sys/time.h> /******************************五元组精确匹配********************************/ unsigned int get_tuple_hash(five_tuple_info tuple,unsigned int length) { unsigned int a[3]; a[0] = tuple.dst_ip; a[1] = tuple.s...
C
/*---------------------------------------------------------------------------------------------------------------------------------------------------------- DaysConvert.c Program to convert days into years, months and days DIVYA RAJ K 09-09-2018 --------------------------------------------------------------------------...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_find_min_elem_to_put_in_b.c :+: :+: :+: ...
C
Escreva um programa que pede ao utilizador um valor N correspondente a um certo período de tempo em segundos. O programa deverá apresentar no output esse período de tempo no formato HH:MM:SS. Sugestão: utilize o operador que calcula o resto da divisão (%). Input: 96 Output: Horas: 0 Minutos:1 Segundos: 36 #includ...
C
/* * ===================================================================================== * * Filename: console.c * * Description: Command console with interpreter * * Version: 1.0 * Created: 西元2020年06月05日 14時04分41秒 * Revision: none * Compiler: gcc * * Autho...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_cconv.c :+: :+: :+: ...
C
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <time.h> #include <stdlib.h> void selection_Sort(int* arr, int size) { int min = 0; for (int i = 0; i < size; i++) { min =i; for (int j = i; j < size; j++) { if (arr[min] > arr[j]) min = j; } int temp = arr[i]; arr[i] = arr[m...
C
/* Firmware for Serial-CV converter board. * http://www.fetchmodus.org/projects/serialcv/ * Written in 2013 by Nick Ames <nick@fetchmodus.org>. * Placed in the Public Domain. */ #include <avr/interrupt.h> #include <stdbool.h> #define F_CPU 8000000UL #include <util/delay.h> #include <stdint.h> /* This program receiv...
C
//includes #include <stdio.h> #define FILAS 6 #define COLUMNAS 1 //---------MAIN------------ int main() { int filas = FILAS; int coef = COLUMNAS; for(int a=0; a<filas; a++) { for(int b=0; b <= a; b++) { if (b==0 || a==0) { coef = 1; } else { ...
C
/********************************************************/ /*************** AUTHOR :ELabbas salah ****************/ /*************** DATE : 10 NOV 2020 ****************/ /*************** SWC : ARM STDTYPE ****************/ /*************** VERSION : V1.1 ****************/ /************************...
C
/* Horner's rule, 霍纳法则, 求多项式值的一个快速算法,算法复杂度O(n)。 原理:F(x) = a0+a1*x^1+...+an*x^n = ((an*x+a{n-1})*x+a{n-2}...)x+a0 */ #include<stdio.h> int horner(const int A[], int N, int x) { int fx = 0; int i; for(i=N-1;i>=0;--i) fx = A[i] + fx * x; return fx; } int main() { int A[4]={1,2,3,4},N=4,x=2; printf("w...
C
/* ███████████ ██████ █████ ████████ ░░███░░░░░███ ░░██████ ░░███ ███░░░░███ ░███ ░███ ████████ ██████ █████ ████ ░███░███ ░███ ░░░ ░███ ░██████████ ░░███░░███ ███░░███░░███ ░███ ░███...
C
/* ============================================================================ Name : Clase_Array.c Author : Version : Copyright : Your copyright notice Description : Hello World in C, Ansi-style ============================================================================ */ #include <stdio...
C
#include <std.h> #include "../yntala.h" inherit CROOM; void create(){ ::create(); set_property("indoors",1); set_property("light",-1); set_property("no_teleport",1); set_travel(RUBBLE); set_terrain(ROCKY); set_name("%^RESET%^%^ORANGE%^The edge of an underground spring"); set_short("%^RESET%^%^ORANGE%^The...
C
#include "stdio.h" /* Partial low? high? sum = 55 */ int main() { int low, high, result = 0; scanf("%d\n", &low); scanf("%d", &high); for (int i = low; i <= high; i++) { result += i; } printf("low? high? sum = %d", result); return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <math.h> int main() { int raio; float raioquadr; printf("Insira o valor do raio do circulo: "); scanf("%d", &raio); raioquadr = raio*raio; printf("Raio do circulo: %d", raio); printf("Area do circulo correspondente: %.2f", 3....
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strlcat.c :+: :+: :+: ...
C
#include <stdio.h> int main(int argc, char const *argv[]) { int input, enter; scanf("%d\n", enter); scanf("%d\n", input); printf("输出的值是%d\n", input + enter); return 0; }
C
/* K&R Exercise 3-1 p. 58 */ /* Our binary search makes two tests inside the loop, when one * would suffice (at the price of more tests outside). Write a * version with only one test inside the loop and measure the * difference in run-time. */ #include <stdio.h> #define LENGTH 100000 int binsearch(int x, int v...
C
#include <stdio.h> #include <string.h> #include <rsl.h> void dump_radar_header(FILE *output, const Radar *const r) { char radar_type[sizeof(r->h.radar_type)]; strncpy(radar_type, r->h.radar_type, sizeof(radar_type)); fprintf(output, "Radar [%p]:\nType: %s\nTimestamp: %02d/%02d/%d [M/D/Y] %d:%d:%f\n\n", r, radar_...
C
#include <stdio.h> int lower_one_mask(int n) { unsigned a=~0x00; a=a<<n; a=~a; printf("%.x\n",a); } int main(void) { // your code goes here lower_one_mask(17); return 0; }
C
# include <stdio.h> # include <stdlib.h> # include <string.h> # include "Listas_enlazadas.h" /**************************************************************** * Programa: lab_03_recursividad_07.c * * Objetivo: Escriba una función recursiva llamada sumaLista que * retorne la suma de los elementos de una lista de en...
C
#include "sh.h" char *check_is_alias(t_42sh *sh, char *str) { int i; t_alias *start; char *to_return; i = 0; start = sh->alias->begin; if (sh->alias->size == 0) return (NULL); while (i < sh->alias->size) { if (ft_strequ(start->to_sub, str) == 1) { to_return = ft_strdup(start->sub); return (to_re...
C
#include <stdio.h> #define EURO 68.27 #define POUND 80.05 #define DOLLAR 61.60 int main(void) { char currency; double value; printf("Enter value and currency (d - dollars, e - euros, p - pounds): "); if (scanf("%lf %c", &value, &currency) != 2) { fprintf(stderr, "Error: Invalid type of Input\n"); fprintf(...
C
#include<stdio.h> void main() { int x[5]={30,40,37,23,50},i,y; printf("enter the value of y\n:"); scanf("%d",&y); for(i=0;i<5;i++) { if(x[i]==y) break; } if(i<5) printf("found"); else printf("not found"); }
C
#include <stdio.h> int sort(int val1, int val2, int val3, int val4, int val5, int val6, int val7, int val8, int val9, int val10); //prototype function int main() { int num1, num2, num3, num4, num5, num6; int num7, num8, num9, num10; printf("Please input 10 numbers:\n"); scanf("%d", &num1); scanf("%d", &num2); ...
C
/** * \file * \brief Implementation of the ADC on the PRG_G board. * \author Erich Styger, erich.styger@hslu.ch * * This module implements the ADC (Analog to Digital Converter) driver. */ #ifndef SRC_ADC_H_ #define SRC_ADC_H_ #include <stdint.h> /** @addtogroup ADC * @{ */ /** \brief Selection of sensors ...
C
/**** DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE ** ** Version 2, December 2004 ** ** Copyright (C) 2013 Kristiyan Peychev <kurotsuki_l@yahoo.com> ** ** ** ...
C
/** * @file sol_1.c * @author LiYu87 (mickey9910326@gmail.com) * @brief 24. Swap Nodes in Pairs * @date 2021.04.27 * * Time Complexity: O(n) * Space Complexity: O(n) * * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ #include <stdlib.h> struct ...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> typedef struct livros /*dados do livro*/ { char titulo[60]; char autor[20]; int qtd_biblioteca, qtd_emprest, ano_publi; }livros; typedef struct registro /*ficha do livro*/ { char titulo[60]; char autor[20]; int ano_p; }registro; int in...
C
#include<stdio.h> void main() { int a,b,c,d; unsigned u; a=12;b=-24;u=10; c=a+u,d=b+u; printf("%d+%d=%d\n,%d+%d=%d",a,u,c,b,u,d); }
C
/* Date : 11-1-2021 Aim : Min and max out of array Source : c patterns app */ #include <stdio.h> void main() { int arr[] = {18, 29, 36, 6, 92, 14, 46, 76, 34, 67}; int min, max, i; max = arr[0]; min = arr[0]; for(i = 0; i < 10; i++) { if(arr[i] < min) min = arr[i]; ...
C
#include "ai_header.h" struct tree_node* create_node(int **map, int intree, int winorlose, int minmax_or_leaf) { struct tree_node *node = (struct tree_node*)malloc(sizeof(struct tree_node)); if (node == NULL) return NULL; node->map = map; node->evaluation_value = 9999; node->is_in_tree = intree; node->min_or...
C
#include <math.h> #include "Trig.h" #include "MathConstants.h" double Sec(const double x_rads) { //Secant if (cos(x_rads) != 0) { return 1 / cos(x_rads); } else { return -9999999999999; } } double Cosec(const double x_rads) { //Cosecant ...
C
#include <stdio.h> #include <conio.h> #include <stdbool.h> int main(){ int cari,low,high,tm; bool berhenti; berhenti = false; int arr[9] = {3, 9, 11, 12, 15, 17, 23, 31, 35}; int n = sizeof(arr)/sizeof(arr[0]); int c; printf("Indeks\t: "); for (c=0;c<n;c++){ printf("%d\t ",c); } printf("\nNila...
C
/* 2/10/15 Stefan Countryman * * A program for timing various looped operations on Unix-like machines. * * Most timing functionality is copied straight from RDM's real_time_clock. * * The program will print the results in CSV format. The user should run the * program and append each new line to the file ti...
C
#include <stdio.h> /*/ 19. Faa um algoritmo que leia dois valores inteiros (X e Y) e mostre todos os nmeros primos entre X e Y. /*/ int main(){ int x,y, cont, ax, i; printf("Digite um valor X:"); scanf("%d", &x); printf("Digite um valor Y:"); scanf("%d", &y); if (y<x){ ax = x; x = y;...
C
#ifndef TERMINAL_H #define TERMINAL_H #include <stddef.h> #include <stdint.h> /* Hardware text mode color constants. */ enum vga_color { COLOR_BLACK = 0, COLOR_BLUE = 1, COLOR_GREEN = 2, COLOR_CYAN = 3, COLOR_RED = 4, COLOR_MAGENTA = 5, COLOR_BROWN = 6, COLOR_LIGHT_GREY = 7, COLOR_DARK_GREY...
C
#include <stdio.h> int main123() { int arr[9] = { 1, 3, 5, 2, 1, 2, 4, 3, 4 }; int res = 0; int i; for (i = 0; i < 9; i++) { res ^= arr[i]; } printf("%d\n", res); return 0; }
C
// Program2, Blaise Takushi CS344, OSUID: 932347942, takushib@oregonstate.edu #include <ctype.h> #include <dirent.h> #include <limits.h> #include <pthread.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <sys/stat.h> #include <sys/types.h> #include <time.h> #include <unistd.h> #include <libgen.h> ...
C
#include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <sys/mman.h> #include <sys/time.h> #include <time.h> #include <pthread.h> #include <stdlib.h> #define KERRW_IOC_READ 0 #define KERRW_IOC_WRITE 1 #define KERRW_IOC_READ16 10 #def...
C
/* 画一个长方形 */ #include<stdio.h> int main(void){ int row; int column; puts("让我们来画一个长方形。"); printf("一边:"); scanf("%d",&row); printf("另一边"); scanf("%d",&column); for(int i=0; i<column;i++){ for(int m=0 ;m<row; m++){ printf("*"); } printf("\n"); } }
C
#include "lem_in.h" int type_num_ants(char *str) { if (if_is_digit_str(str)) if (count_ants(str)) return (1); return (0); } int type_room(char *str) { char **s; unsigned long int len; if (!str) return (0); s = ft_strsplit(str, ' '); len = two_dem_strlen(s) - 1; if (len != 3) { free_twodem_str...
C
#include <stdio.h> #include "myArray.c" int Partition_Lamuto(int A[], int lower_bound, int upper_bound); int Partition(int A[], int lower_bound, int upper_bound); void QuickSort(int A[], int lower_index, int higher_index) { if (lower_index < higher_index) { // int border = Partition_Lamuto(A, lower...
C
/******************************************************************* * Cellular Automaton *******************************************************************/ #include "mex.h" // #include "matrix.h" #include "math.h" /******************************************************************* * global parameters l...
C
// // ArrayList.c // ListMain // // Created by 김영후 on 2014. 12. 27.. // Copyright (c) 2014년 Hoo. All rights reserved. // #include "ArrayList.h" /* * 리스트 초기화 */ void ListInit(List * plist) { plist->numOfData = 0; // 리스트에 저장된 데이터의 수는 0 plist->curPosition = -1; // 현재 아무 위치도 가리키지 않음 } /* ...
C
#ifndef __datetime__ #define __datetime__ #include <stdio.h> #include <string.h> #include <stdlib.h> typedef struct { int year,month,day,hour,min,seg; }datetime_t; //Inicializa la estructura int datetime_create(datetime_t *self); //Setea fecha y hora int datetime_setdatetime(datetime_t *self, char* datetime); //Dev...
C
#include "stdlib.h" int containsFive(int n) { while(n != 0) { if(abs(n % 10) == 5) { return 1; } n /= 10; } return 0; } int dontGiveMeFive(int start, int end) { int total = 0; for(int i = start; i <= end; i++) { if(containsFive(i) == 0){ total++; } } return total; }
C
#ifndef __FILE_H__ #define __FILE_H__ typedef struct Directory { // The name of the directory char *name; // TODO: The list of files of the current directory struct FolderChain *folders; // TODO: The list of directories of the current directory struct FileChain *files; // The parent directory of the current director...
C
/* 인접 행렬로 표현된 그래프를 입력받아서 인접 리스트로 변환하는 C함수로 작성하라. */ #include<stdio.h> #include<malloc.h> #define MAX_VERTICES 50 #define MATRIC_VERTICES 6 typedef struct GraphNode{ int vertex; int weight; struct GraphNode *link; }GraphNode; typedef struct GraphType{ int n; GraphNode *adjList[MAX_VERTICES]; }GraphType; void ini...
C
#ifndef BST_H_ #define BST_H_ #include <stdio.h> #include <stdlib.h> #include "structures.h" #include "data.h" #include "stack.h" #include "queue.h" // create a new leaf and return it struct leaf* createLeaf(struct data *d); // create a new Tree struct tree* createTree(); // Insert a new node into tree void insert...
C
/*Binary Search Recursion*/ #include<stdio.h> int BinarySearch(int [], int, int, int); int main() { int n,data; int place; printf("Enter the Number: "); scanf("%d", &data); int A[13] = {1,4,6,8,10,25,67,78,98,100,201,403,607}; place = BinarySearch(A, data, 0, 12); printf("The index is: %d an...
C
/* * plus_one.c * * Created on: Apr 29, 2018 * Author: Harsh */ #include <stdio.h> #include <stdlib.h> #include "_linked_list.h" /** * Definition for singly-linked list.*/ struct ListNode { int val; struct ListNode *next; }; /* Method 1: Iterative + Reversal 1. Reverse the...
C
#include <X11/X.h> #include "tool_freehand.h" #include "tool.h" #include "network.h" #include <X11/Xlib.h> void tool_freehand(tool_freehand_context_t *context, canvas_event_t event) { if(event.type == ButtonPress) { context->is_painting = True; ll_point_clear(context); context->head->point.x = event.x; conte...
C
#include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> double Manhattan_Dist(double vectx[], double vecty[], int n) //Function to calculate Manhattan Distance { double man_dist = 0; for (int i=0; i<n; i++) { man_dist = man_dist + fabs(vectx[i] - vecty[i]); } ...
C
#include "linear_allocator.h" #include <stdio.h> #include <stdlib.h> #define ALLOCATED_MEMORY_SIZE 100 #define CHUNK_SIZE 23 int main(int argc, char *argv[]) { linear_allocator_t allocator; void *mem; allocator = linear_allocator_new(ALLOCATED_MEMORY_SIZE); while (mem = linear_allocator_alloc(alloc...
C
/***************************************************************** * Author: Joseph DePrey * Description: adventure.c provides an interface for playing a game using * the most recently generated rooms from buildrooms.c * In the game, the player will begin in the "starting room" and will win * the game ...
C
#include "mesin_kar.h" /** * Menghitung jumlah kemunculan karakter pada suatu pita karakter * needle merupakan huruf yang akan dihitung * filename merupakan nama file * Fungsi mengembalikan jumlah karakter yang muncul pada pita karakter */ /* State Mesin */ extern char CC; extern boolean EOP; /* pada impleme...
C
/* Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0. Assume the environment does not allow you to store 64-bit integers (signed or unsigned). Example 1: Input: x = 123 Output: 321 Exampl...
C
#ifndef __LIST__H__ #define __LIST__H__ /* Définition d'un Booléen */ typedef enum { false, true }Bool; /* Définition d'une Liste */ typedef struct ListElement { int value; struct ListElement *next; }ListElement, *List; /* Prototypes */ List new_list(void); Bool is_empty_list(List li); void print...
C
// Owner: Costa // Exercise: formula_bhaskara // Created in 11/01/2018 10:11:16 #include <stdio.h> #include <stdlib.h> #include <math.h> int main(){ double a, b, c; scanf("%lf %lf %lf", &a, &b, &c); double r1 = 0; double r2 = 0; double bhask = b*b -4*a*c; if(bhask < 0 || a == 0.0){ ...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> #include <math.h> #include "pe12.h" #include "pe13.h" #include "pe14.h" extern int random_s(void); extern void setNext(void); extern void reverse(void); void readLine(int argv, char * args[]); void showArray(double targer[], int size); int ...
C
#include<stdio.h> int main() { int a[2][2]; int b[2][2]; int i,j; printf("MATRIX A :"); for(i=0;i<2;i++) { for(j=0;j<2;j++) { scanf("%d",&a[i][j]); } } for(i=0;i<2;i++) { for(j=0;j<2;j++) { printf("%d\t...
C
#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> //дһMaxȽĽϴֵ int Max(int x, int y) { if (x > y) { printf("ϴֵa=%d\n", x); } if (x < y) { printf("ϴֵb=%d\n", y); } if (x==y) { printf("\n"); } return 0; } int main() { int a = 0; int b = 0; printf("a\n"); scanf("%d", &a); //ȡaֵ printf("b\n")...
C
/** * Ce programme montre comment il est possible de faire jouer de la musique à * votre programme. * * Cette démonstration utilise les fonctions suivantes : * *------------------------------------------------------------------------------ * MLV_init_audio : Cette fonction initialise la libraire MLV pour pouv...
C
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <string.h> #include <traildb.h> #include "tdb_test.h" static tdb *make_tdb(const char *root, const uint64_t *tstamps, uint32_t num, int should_fail) { static uint8_t uuid[16]; con...
C
/* You can produce input and output in more ways than with the scanf() and printf() functions. You can use these simple functions to build powerful data-entry routines of your own. Functions explained here are a little easier to use, and they provide some capabilities that scanf() and printf() dont offer. */ // PUTC...
C
#include<stdio.h> int main() { int t,x,y,n; scanf("%d",&t); while(t) { t=t-1; scanf("%d%d",&x,&y); if(x==y) { if(x%2==0) n=2*x; else n=2*x-1; printf("%d\n",n); } else if(x==y+2) { ...
C
void main(void) { int w; scanf("%d",&w); int day[]={0,31,28,31,30,31,30,31,31,30,31,30,31}; int d=12+w,i; for(i=1;i<=12;i++) { d=d+day[i-1]; if(d%7==5) printf("%d\n",i); } }
C
#include <stdio.h> #include <stdlib.h> int main() { int i, n, dim, *dec; setlocale(0, "rus"); printf("Введите размер массива: "); scanf("%d", &n); printf("Введите диапазон случайных чисел: "); scanf("%i", &dim); srand(time(0)); dec = malloc(n * sizeof(int)); printf("Сгенерированный...
C
#include <stdlib.h> #include <assert.h> struct list_elem { size_t size; int free; struct list_elem *prev; struct list_elem *next; }; struct list { struct list_elem head; struct list_elem tail; }; void list_init (struct list *list); void list_insert (struct list_elem *before, struct list_elem ...
C
int hash(char s[]) { char *p; int h = 0; for(p = s;*p;p++) { h = h*3 + *p; } return h; }
C
/* 15: 鿴 ύ ͳ ʱ: 1000ms ڴ: 65536kB , ΪһУ֮һոֿ һУһ 10 20 56 56 */ #include <stdio.h> int main() { int a,b,c,v; scanf("%d %d %d",&a,&b,&c); v=a>b?a:b; if (v<c) v=c; printf ("%d",v); return 0; }
C
#include<stdio.h> struct da { int max[10],a1[10],need[10],before[10],after[10]; }p[10]; void main() { int i,j,k,l,r,n,tot[10],av[10],cn=0,cz=0,temp=0,c=0; printf("\nENTER THE NO. OF PROCESSES: "); scanf("%d",&n); printf("ENTER THE NO. OF RESOURCES: "); scanf("%d",&r); for(i=0;i<n;i++) { printf("PROCESS %d \n",i+1); for...
C
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* * File: main.c * Author: AaronHenry * * Created on April 30, 2017, 4:52 PM */ #include <stdio.h> #include <stdlib.h> s...
C
/* $Id: xutf8.h,v 1.1 2015/06/15 04:50:41 gremlin Exp $ */ #ifndef XUTF8_H_ #define XUTF8_H_ #include "xstr.h" #ifdef __cplusplus extern "C" { #endif /* Return number of byte the unicode code point occupied. * Return 0 if the string is not encoded as valid utf8. */ size_t xutf8_cstr_to_code(const char *s, int *pc...
C
#include "core/pt.h" /* * Return the distance in tiles between two ships. * This will mostly be used in hit chance calculations. */ int calc_dist (const struct pt thisCoord, const struct pt otherCoord) { int x = thisCoord.x - otherCoord.x; int y = thisCoord.y - otherCoord.y; if(x < 0) x = -x; if(y < 0) y ...
C
10 /* Nonzero -- yields a true result */ !10 /* Yields a false (logically opposite) result */ int a = 10, b = 5, c = 0; a && b /* True -- both are nonzero */ a && c /* False -- one operand is zero */ a || c /* True -- one operand is nonzero */ int a = 10, b = 5; int i = 2, j = 9; a > b && i < j /*...
C
/* * procExit.c -- * * Routines to terminate and detach processes, and to cause a * process to wait for the termination of other processes. This file * maintains a monitor to synchronize between exiting, detaching, and * waiting processes. The monitor also synchronizes access to the * dead list. * * Copyrig...
C
// // rotation.c // openGLProject // // Created by 김혜지 on 2016. 5. 17.. // Copyright © 2016년 김혜지. All rights reserved. // #include <stdio.h> #include <GLUT/GLUT.h> #define PI 3.1415926 float x, y, z; float radius; float theta; float phi; float zoom = 60.0; int beforeX, beforeY; GLfloat vertices[][3] = { { -1...
C
#include "../common/common.h" #include "../common/trie.h" #include "../common/error.h" #include "server.h" #include <stdlib.h> /* BY gaochao Use the heap memory. ADD LOCK!!!!!!! */ struct trie_node *root; //indexed by name struct stored_data{ struct in_addr addr; in_port_t port; pid_t pid; }; void init() { root...
C
#include <string.h> #include <math.h> #include <windows.h> void Emp() { int i,j,a; gotoxy(22,7); printf("%c",201); for(i=0;i<=120;i++) { printf("%c",205); } printf("%c",187); gotoxy(22,8); printf("%c",186); for(i=0;i<=28;i++) { ...
C
#include<stdio.h> int main() { int i=20,j=30; swap(&i,&j) printf("%d %d",i,j); return 0; } void swap(int *x,int *y) { int temp; temp=*x; *x=*y; *y=temp; }
C
#include<stdio.h> extern int countv(char *); int main(){ int a; a = countv("2 3, 4 5, 6 7"); printf("%d\n",a); return 0; }
C
#include<stdio.h> int main(int argc, char *argv[]){ int flag,tmp,i,j,k,l,m,n; char c[1005]; scanf("%d",&n); scanf(" %s",c); flag=0; for(i=n-1;i>=0;i--) c[i+1] = c[i]; for(i=1;i<=n/4;i++){ for(j=1;j+i<=n;j++){ tmp = j; m = 0; while(c[tmp]=='*' && tmp<=n){ tmp = tmp+i; m++; } if(m>=5) ...
C
#include<stdio.h> #include<conio.h> void main() { char ch[25]={" "}; char c[25]={'\0'}; int i,flag=0,cnt=0; clrscr(); printf("\n Enter string"); scanf("%s",ch); printf("%s",ch); for(i=0;ch[i]!='\0';i++) { cnt++; } /* cnt=strlen(ch); for(i=0;i<cnt;i++) { c[i]=ch[i]; } */ printf("\nStrin...
C
#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<assert.h> typedef int QDataType; // ʽṹʾ typedef struct QListNode { struct QListNode* _pNext; QDataType _data; }QNode; // еĽṹ typedef struct Queue { QNode* _front; QNode* _rear; size_t size; }Queue; // ʼ void ...