language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdlib.h> #include <stdio.h> typedef struct TListeEntier TListeEntier ; struct TListeEntier { int valeur; struct TListeEntier *precedent; struct TListeEntier *suivant; }; typedef TListeEntier* TListe; TListe CreerListe(); int EstVide(TListe l); TListe AjoutDebut(TListe l, int val) ; void Affich...
C
#include <stdio.h> typedef struct { int a; int b; int c; } info_t; info_t info[] = { {0, 1, 2}, {3, 4, 5}, {6, 7, 8}, {9, 10, 11}, {12, 13, 14}, {15, 16, 17} }; #define SIZEOF(x) (sizeof(x) / sizeof(x[0])) int main() { for (int i = 0; i < SIZEOF(info); i++) ;//doing some stuff ...
C
#include <stdio.h> void f(int a, int b) { int z; z = ( a > b ) ? a : b; /* z = max(a,b) */ printf("z = %d\n",z); } void g(float f, int n) { printf("%f\n",( n > 0 ) ? f : n); } void h(int a[], int n) { int i; for (i=0; i < n; i++) printf("%6d%c",a[i], (i%10==9 || i==n-1) ? '\n' : ...
C
#include<stdio.h> #include<stdlib.h> #include<time.h> #define ROW 3 #define COL 3 //求二维数组的总和及平均值 //二维数组每行的总和及平均值 //二维数组每列的总和及平均值 int main(void) { int arr[ROW][COL] = {0}; int rowSum = 0; //行的和 int colSum = 0; //列的和 int tolSum = 0; //总的和 int i = 0; int j = 0; //产生随机二维数组 srand...
C
#include <stdio.h> int main() { int n,i,z=0; printf("enter the number..."); scanf("%d",&n); for(i=5; i<=n; i=i*5) z = z + (n/i); printf("%d",z); return 0; }
C
#include<stdio.h> #define x 50 int main(){ int v[x],i,a=0; for(i=0;i<x;i++){ v[i] = 1 + rand() % 100; } for(i=0;i<x;i++){ printf("%d\t",v[i]); } printf("\nDigite um valor para multiplicar: "); scanf("%d",&a); for(i=0;i<x;i++){ v[i] = v[i] * a; } for(i=0;i<x;i++){ printf("%d\t",v[i]); ...
C
/* * *** ***** ******* ********* */ #include<stdio.h> int main() { int i, j, k, n; printf("\nEnter line count: "); scanf("%d", &n); for(i=1; i<=n; i++) { for(j = n-1 ; j>=i; j--) printf(" "); for(k = 1; k<= 2*i-1; k++) printf("*"); printf("\n"); } }
C
/* ======================================== * * Copyright YOUR COMPANY, THE YEAR * All Rights Reserved * UNPUBLISHED, LICENSED SOFTWARE. * * CONFIDENTIAL AND PROPRIETARY INFORMATION * WHICH IS THE PROPERTY OF your company. * * ======================================== */ #include "project.h" CY_ISR_PROTO(ISR_U...
C
#include<stdio.h> #define MAXSIZE 100 //ṹ typedef struct Node{ char data; struct Node *lChild; struct Node *rChild; }BiTNode,*BiTree; //չд BiTree create(){ BiTree s; char ch; ch = getchar(); if(ch == '#') { return NULL; } else{ s = malloc(sizeof(BiTNode)); s->data = ch; s->lChild = create(); s...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.c :+: :+: :+: ...
C
#define _XOPEN_SOURCE 600 #include <SDL.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <stdbool.h> #include <time.h> #include <sys/time.h> #include <signal.h> #include <pthread.h> #include "timer.h" #include "../include/timer.h" // Timer_entry struct struct timer_entry { struct timeval tv...
C
#include<stdio.h> double S(int n){ if(n==1){ return 1; } return ((double)1)/n +S(n-1); } int main(){ printf("%.12lf",S(50)); }
C
#include "mish_core.h" static output_cohort cohorts[MISHEGOS_COHORT_NSLOTS]; void cohorts_init() { uint32_t nworkers = GET_CONFIG()->nworkers; for (int i = 0; i < MISHEGOS_COHORT_NSLOTS; ++i) { cohorts[i].outputs = malloc(sizeof(output_slot) * nworkers); } } void cohorts_cleanup() { DLOG("cleaning up"); ...
C
/*Задача 2 Пощенските такси на дадена куриерска фирма се определят според тежестта на пратките (с точност до цял грам) и обема, както е показано в таблицата. Тегло (с точност до 1 грам) Такса до 20 г 0,46 лева; 21-50 г 0,69 лева; 51-100 г 1,02 лева; 101-200 г 1,75 лева; 201-350 г 2,13 лева; 351-500 г 2,44 лева; 501-...
C
# include <stdio.h> int main () { int m[10]; for (int i = 0; i < 10; i ++) { printf("%p --> %d\n", &(m[i]), m[i]); } 1 == 2; m[2]; printf("function return: %d", fun(10)); // fun (14); return 0; } int fun (int a) { printf("hola %d", a); }
C
#include <stdio.h> #include <stdlib.h> typedef struct Pilha{ unsigned long long n; unsigned long long k; struct Pilha *prox; } Pilha; void push(Pilha *p, int n){ Pilha *novoNo = malloc(sizeof(Pilha)); novoNo->n = n; if(p->prox){ novoNo->k = (p->prox->k)*10; } else{ novoNo-...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_printf.c :+: :+: :+: ...
C
/* Project 3 * * Name: Anthony Dinh * Instructor: Hatalsky */ #include <stdio.h> #include <stdlib.h> #include "puzzleLib.h" /* this function is complete. Do not modify it */ void PrintPuzzle(int inPuzzle[PUZZLE_SIZE][PUZZLE_SIZE]) { int column,row; for (row=0;row < PUZZLE_SIZE;row++) { for(column=0;col...
C
/*HW1 Jingwen Ye jy879 Problem 2 tile compile with: gcc jy879_mm_tile.c -o tile run with: ./tile */ #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <time.h> /* clock_gettime lib */ #define BILLION 1000000000L int main(){ int i,j,dim_n,tile_size,k,ii,jj,kk; // get value from ...
C
#include<stdio.h> main() { int n,i,j,elt,temp,beg,end,mid,flag; printf("\n\n Enter the number of elements: "); scanf("%d",&n); int A[n]; printf("\n\n Enter the elements: "); for(i = 0; i < n; i++) scanf("%d",&A[i]); for(i = 0; i < n; i++) for(j = 0; j < n-i-1; j++) { if(A[j] > A[j+1]) { temp = A[j]; ...
C
#include "common.h" #include "kmer_hash.h" #include "packingDNAseq.h" #include "probe.h" int probe(gen_state_t *state, FILE *out) { rvm_txid_t txid; probe_state_t *pstate; assert(state->phase == PROBE); if(state->pstate == NULL) { TX_START(txid); state->pstate = rvm_alloc(cfg, sizeof(...
C
#include <stdio.h> int main(){ double num; scanf("%lf", &num); if(num < 0){ printf("%.2f", num * (-1)); }else{ printf("%.2f", num); } return 1; }
C
#include <stdio.h> #define uint unsigned int uint setbits(uint x, int p, int n, int y); int main(void) { int x,y; x = 218, y = 170; printf("%u\n", setbits(x, 3, 3, y)); /* ==> 210 */ return 0; } uint setbits(uint x, int p, int n, int y) { uint bitmask = ~(~0 << n); return (x & ~(bitmask << p)) | ((y & bitmask...
C
#include <stdio.h> #include <math.h> #include <string.h> #include <stdlib.h> float areaOfCircle(float r) { float area = M_PI * r * r; printf("r = %f, area = %f\n", r, area); return area; } int main(int argc, char* argv[]) { float start, end; if (argc == 3) { //if there are two arguments start = ...
C
#include "list.h" int count_s_nodes(struct s_node* head){ unsigned int temp=1; if(head == NULL){ return 0; } while(head->next != NULL){ temp ++; head = head->next; } return temp; }
C
#include "../headers.h" #include "mcmc_headers.h" FILE* getFile(char filename[100]){ FILE* out = fopen(filename, "w"); if(NULL==out) { printf("Cannot open data file %s\n", filename); exit(1); } return(out); } void outputMCMCSettings(st_mcmc_settings *mcmc_settings) { int thin, burn, parts...
C
/* printmsg.c: print a message on the console */ /* printmsg.c: print a message on the console */ #include <stdio.h> int main(int argc, char *argv[]) { char *message; if (argc != 2) { fprintf(stderr, "usage: %s <message>\n", argv[0]); exit(1); } message = argv[1]; if (!pr...
C
#include<stdio.h> int thesum(); int main(){ int sum; sum=thesum(); printf("The summession:%d",sum); return 0; } int thesum(){ int num1,num2; printf("Enter the 1st number:"); scanf("%d",&num1); printf("Enter the 2nd number:"); scanf("%d",&num2); return num1+num2; }
C
#include <stdio.h> #include <stdlib.h> #include <math.h> typedef enum { false, true } bool; void towerOfHanoi(int n, int *sourceArr, int *destArr, int *auxArr); void sort(int *arr, int val, int n, int size); void Binary(int n); void k_string(int n, int k); int findMax(int **intArr, bool **boolArr, int r,...
C
//Program that first asks the user how much change is owed and then spits out the minimum number of coins with which said change can be made #include <cs50.h> #include <stdio.h> #include <math.h> int main(void) { float change; //user input int cents; //change converted to cents after being * by 100 int ...
C
// // Function to reverse bits in a byte // // inputs: // unsigned char c: a byte of which to reverse the bits. // // outputs: // the bit reversed byte. // unsigned char bit_reverse( unsigned char c ) { unsigned char result = c; // to store the result // YOUR SOLUTION HERE return result; } ...
C
/*IMPORTANT: YOU MAY NOT HAVE A SPACE DIRECTLY BEFORE OR AFTER <,>,;,| RATHER THAN ls ; ls -l must be ls;ls -l*/ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <signal.h> #include <string.h> #include <errno.h> #include <time.h> #include <fcntl.h> #include <sys/stat.h> #include <sys/types.h> #i...
C
#include "Stack.h" void ShowArray(int* a, int n) { assert(a); for (int i = 0; i < n; i++) { printf("%d ", a[i]); } printf("\n"); } //Կǵݹ汾 void Test() { int arr[] = { 2, 3, 5, 1, 4, 6, 9, 8, 7 }; int size = sizeof(arr) / sizeof(arr[0]); ShowArray(arr, size); QuickSortNonR(arr, 0, size - 1); ShowArray(arr...
C
#include <stdio.h> int main(void) { int height; int lower,upper,step; printf("몇 cm부터 : "); scanf("%d", &lower); printf("몇 cm까지 : "); scanf("%d", &upper); printf("몇 cm마다 : "); scanf("%d", &step); for(height= lower; height <=upper;height +=step) printf("%dcm %...
C
#include "stdio.h" typedef char s8; typedef unsigned char u8; typedef short s16; typedef unsigned short u16; typedef int s32; typedef unsigned int u32; typedef long s64_; typedef unsigned long u64_; typedef long long s64; typedef unsigned long long u64; void main() { int nData1 = 337; int nData2 = -777; double dDa...
C
#include "header.h" int get_box(int index, int** conditions, int* answer) { int i; if (index == N * N) return (1); i = 1; while (i <= N) { answer[index] = i; i++; if (check_1234_row(index, answer) == 0) continue; if (check_1234_col(index, answer) == 0) continue; if (check_udlr(index, conditions...
C
#ifndef UTIL_H #define UTIL_H #include "Global.h" /* A 32 character circuluar string buffer. */ typedef struct { unsigned char readPos; unsigned char writePos; unsigned char count; char data[32]; } CircularBuffer_Str32; #define CB_STR32_SIZE 32 void Util_initBuffer(volatile CircularBuffer_Str32*); //Can al...
C
// // Joaquim Madeira, AlgC, May 2020 // // Graph EXAMPLE // #include "Graph.h" #include "GraphDFSRec.h" int main(void) { Graph* g01 = GraphCreate(6, 0, 0); GraphAddEdge(g01, 0, 5); GraphAddEdge(g01, 2, 4); GraphAddEdge(g01, 2, 3); GraphAddEdge(g01, 1, 2); GraphAddEdge(g01, 0, 1); GraphAddEdge(g01, 3, ...
C
#include <stdio.h> #include <conio.h> troca(int *n1,int *n2) { int t; t=*n1;*n1=*n2;*n2=t; printf("Valores invertidos: \n"); printf("1a. variavel: %d e 2a. variavel: %d", *n1,*n2); } void main() { int n1=0,n2=0; printf("Digite 2 numeros inteiros:\n"); printf("Digite 1o. numero inteiro:\n"); ...
C
#include <string.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <stdio.h> #include <stdarg.h> #include <stdlib.h> #include <sys/time.h> #include "axl_internal.h" unsigned long axl_file_buf_size; /* returns the current linux timestamp (secs + usecs since epoch) as a double */ double axl_secon...
C
#include<GL/glut.h> #include<stdio.h> int xl1=25,yl1=25,xl2=250,yl2=250,xb1=50,yb1=50,xb2=200,yb2=200,displayLine=1,xc=0,yc=0,r=50,mode=0,k[4]={10,10,5,10}; void plot(int x,int y) { glBegin(GL_POINTS); glVertex2i(x,y); glEnd(); glFlush(); } int abs(int a) { if(a<0) return -a; else return a; } void drawLi...
C
/** * CEL(C Extension Library) * Copyright (C)2008 - 2018 Hu Jinya(hu_jinya@163.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your o...
C
#include "bit_table.h" #include <stdlib.h> #include <mem.h> #define bits_to_bytes(bits) ((bits + 7) >> 3) //bits >> 3 + (bits & 7 ? 1 : 0); int write_bits(unsigned char **out, unsigned *used, unsigned *size, struct bit_table *node) { if (!out || !*out || !used || !size || !node) ...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include "utils.h" #include "token.h" #include "ast.h" #include "lexer.h" #include "parser.h" struct node *parser_parse_factor(struct token **token_list); struct node *parser_parse_expression(struct token **token_list); struct node *parser_parse_statement_lis...
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
#ifndef PROTOCOLS_H #define PROTOCOLS_H #include "includes.h" string IntToStr(int number, int sizeStr) { string output = ""; string number_str = to_string(number); if (number_str.size() > sizeStr) { perror("ERROR in 'IntToStr', number_str.size() is greater than sizeStr"); return outpu...
C
/* ============================================================================= * Filename : api.h * Summary : some definitions of common interface * Compiler : gcc * * Version : * Update : * Date : * Author : * * History : * * ===============================================================...
C
#include<stdio.h> #define ll long long int int main() { ll t,n,i,j,k,temp; scanf("%lld",&t); while(t--) { scanf("%lld",&n); ll a[n],count[n],front[n],back[n]; front[0] = 0; back[n-1] = 0; for(i=0;i<n;i++) { scanf("%lld",&a[i]); count[i] = 0; } for(i=1;i<n;i++) front[i] = front[i-1] + a[i...
C
#include "cola.h" #include "testing.h" #include <stddef.h> #include <stdio.h> /* ****************************************************************** * PRUEBAS UNITARIAS ALUMNO * *****************************************************************/ void pruebas_cola_alumno(){ //Vemos que las funciones...
C
#include <stdio.h> void find_two_largest(int a[], int n, int *largest, int *second_largest); int main(void) { int a[10], n=10, biggest, second_biggest, i; printf("enter 10 integers: "); for (i = 0; i < 10; i++) scanf(" %d", &a[i]); find_two_largest(a, n, &biggest, &second_biggest); print...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "hash.h" void* func_create_key_int(void* key) { int* k = (int*)key; int* t = (void*)malloc(sizeof(*k)); memcpy(t, k, sizeof(*k)); return (void*)t; } void func_erase_key_int(void* key) { free(key); } void* func_create_val_int(void...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* s_links.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #define TABLE_SIZE 128 #define BUFFER_SIZE 1024 int main(int argc, char *argv[]) { static struct { long offset; int length; } table [TABLE_SIZE]; char buf[BUFFER_SIZE]; long offset; int entry; int i; int length; int fd; //인자가...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_list.c :+: :+: :+: ...
C
#include <stdio.h> #include "variadic_functions.h" #include <stdarg.h> /** * sum_them_all - sum all * @n: first variable * * Return: 0 if n==0. */ int sum_them_all(const unsigned int n, ...) { va_list s_list; unsigned int i, a = 0; va_start(s_list, n); if (n == 0) { return (0); } for (i = 0; i < n; i++)...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* a_flag.c :+: :+: :+: ...
C
#include <stdio.h> int main () { long nb, nt, nn; int c; nb = 0; nt = 0; nn = 0; while ((c = getchar ()) != EOF) { if (c == ' ') { ++nb; continue; } if (c == '\t') { ++nt; continue; } if (c == '\n') { ++nn; continue; } } printf ("count blanks: %ld\tcount...
C
#include <stdio.h> #define SQR(x) (x * x) #define SQR1(x) ((x) * (x)) #define MAX(X,Y) (((X) > (Y)) ? (X) : (Y)) #define QUOTE(X) #X #define SNAP(X) printf("variable "#X" = %d\n",X) #define GLUE(X,Y) X##Y //gcc -E preprocessor_define_macro.c //shows preprocessor result int main(void) { int i = 4; int s...
C
#include "utilities.h" FILE * open_file_read(const char * filename) { FILE * input_file = fopen(filename, "r"); return input_file; } FILE * create_file_binary_write(const char * filename) { FILE * output_file = fopen(filename, "wb"); return output_file; } // TODO: javadoc // note that sets readable_bytes to 0...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* search_freed.c :+: :+: :+: ...
C
#include<stdio.h> main() { char i='A',n=5,j,k=65; for(i='A';i<('A'+n);i++) { for(j='A';j<=k;j++) { printf("%C",j); } k++; printf("\n"); } }
C
#include <unistd.h> /** * _strlen - char count * @s: string * Return: sl */ int _strlen(char *s) { int sl; while (*(sl + s)) sl++; return(sl); }
C
#include <stdio.h> #include <stdint.h> int main() { int32_t a = 61 - (22 / 25); printf("%d\n", 20 / a);; int32_t b = 18; printf("%d\n", ((21 * (a - (a - 33))) / a) / a);; printf("%d\n", a);; int32_t c = b; int32_t d = 9 / 19; int32_t e = 32; int32_t f = 23; printf("%d\n", 7);; printf("%d\n", 37);; int32_t g = c / 8; pr...
C
#include<stdio.h> #include<omp.h> void main() { int largest = 0; int i=0; int data[10]={34,6546,3254,76,123,7657,2134,5467,89,3467}; #pragma omp parallel for for ( i = 0; i < 10; i++ ) { #pragma omp critical if (data[i] > largest ) largest = data[i]; printf("now max=%d, TID=%d\n",largest,omp_get_thread_num...
C
#include <stdio.h> int main() { int c, v, fact = 1; printf("Enter a number to calculate its factorial\n"); scanf("%d", &v); for (c = 1; c <= v; c++) fact = fact * c; printf("Factorial of %d = %d\n", v, fact); return 0; } }
C
#include <pthread.h> #include <semaphore.h> #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include "lib.h" #include "globalVar.h" void initStruct(){ if (pthread_mutex_init(&work_mutex, NULL) != 0) { //creating mutex lock perror("Mutex initialization failed"); exit(1); } if (sem_init(&empty, 0, B...
C
#include "dog.h" #include <stdio.h> #include <stdlib.h> /** * new_dog - create a new dog with name age owner * @name: string * @age: double * @owner: string * Return: struct */ dog_t *new_dog(char *name, float age, char *owner) { dog_t *nath; char *na, *ow; int na_l; int ow_l; na_l = _strlen(name); ow_l = ...
C
/* ** var.c for ok in /home/alexandre/Documents/tek1/PSU_2016_42sh/src/ ** ** Made by Alexandre Chamard-bois ** Login <alexandre.chamard-bois@epitech.eu@epitech.eu> ** ** Started on Sat May 6 13:01:10 2017 Alexandre Chamard-bois ** Last update Sun May 21 21:15:00 2017 Alexandre Chamard-bois */ #include <stdio.h> #...
C
//Kumar Ankit #include <stdio.h> int main(void) { // your code goes here int t,sal; float hra, da, gs; scanf("%d",&t); while(t--) { scanf("%d",&sal); if(sal<1500) { hra=sal*0.1; da=sal*0.9; gs=sal+hra+da; printf("%0.2f\n",gs); } else if(sal>=1500) ...
C
#include <stdio.h> #include <assert.h> int score_board(int newscore) { if(newscore>=45&& newscore<=49) { if (newscore==49) newscore+=1; else newscore+=2; } else if(newscore>=40&&newscore<=44) newscore+=3; else if(newscore>=35&&newscore<=39) newscore+=4; else if(newscore...
C
#include<stdio.h> int main() { int n,n1,a,sum=0; printf("enter the no"); scanf("%d",&n); n1=n; while(n1>0) { a=n1%10; sum=sum+a; n1=n1/10; } printf("%d having a %d add no",n,sum); return 0; }
C
#include <unistd.h> #include <stdio.h> #include <stdlib.h> int ft_atoi(char *str) { short sign; unsigned long long result; result = 0; while ((*str >= 9 && *str <= 13) || *str == ' ') ++str; sign = (*str == '-' || *str == '+') ? -(*str++ - 44) : 1; while (*str && *str >= '0' && *str <= '9') re...
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 <openss1/md5.h> #include <unistd.h> #include <fcnt1.h> #include <stdio.h> #include <stdlib.h> unsigned char* file2md5(char* path) { int d; MD5_CTX5; char buf[512]; size_t bytes; unsinged char* out= (unsinged char*)malloc (md5_DIGEST_LENGHT * sizeof (unsigned char)); if(out==NULL)...
C
/* * A simple Gnome program, outside of GNOME tree, not using i18n * uiinfo.c */ /* the very basic gnome include */ #include <gnome.h> /* a callback for the buttons */ static void a_callback(GtkWidget *button, gpointer data) { /*just print a string so that we know we got there*/ g_print("Inside Callback\n"); } ...
C
// One-star problem // Problem UVA406 Prime Cuts /* This program is written by Prof. Chua-Huang Huang Department of Information Engineering and Computer Science Feng Chia University Taichung, Taiwan Disclaimer: The programming problem is downloaded from UVa Online Judge (https://uva.onlinejudge.org/). Th...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> void convertToString(char out[], short cmd){ for(short i = 15; i >= 0; i--){ out[i] = (char) ((((unsigned short)((short)(cmd << i))) >> 15) + 48); } } void convertToStringImg(char out[], short cmd){ for(short i = 7; i >= 0; i--){ out[i] = (char)...
C
/* * Bidirectional list implementation (C99 standard) * Usage: * #include <list.h> * ... * list l = Lists.new(); * * All interface sould be accessed through Lists constant. * * MIT LICENSE * @Piotr Styczyński 2017 */ #include "utils.h" #ifndef XTREE_LIST_H__ #define XTREE_LIST_H__ /* * Macro for int...
C
#include<stdio.h> int main() { int d, m, y, j, f, h, fh, day; printf("Enter the date (dd/mm/yyyy): "); scanf("%d/%d/%d", &d,&m,&y); j = d; switch(m - 1) { case 11: j += 30; case 10: j += 31; case 9: j += 30; case 8: j += 31; case 7: j += 30; case 6: j += 31; case 5: j += 30; ...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <signal.h> // This anomaly program is inspired by the "leak" anomaly described in the ISC-HPC 2017 paper by Tuncer et al. // "Diagnosing Performance Variations in HPC Applications Using Machine Learning", pp. 355-373, Springer. in...
C
/*This tests fullDeckCount()*/ #include "dominion.h" #include "dominion_helpers.h" #include <string.h> #include <stdio.h> #include <assert.h> #include "rngs.h" int main(){ struct gameState G; int runSuccess; int cardCount; int player = 0; int k[10] = {adventurer, council_room, feast, gardens, mine, remodel, sm...
C
#include <stdio.h> #define typename(x) _Generic((x), \ _Bool: "_Bool", unsigned char: "unsigned char", \ char: "char", signed char: "signed char", \ short int: "short int", unsigned sho...
C
#include <stdio.h> int main(int argc, char* argv[]) { int c; int blanks, tabs, nls; blanks = tabs = nls = 0; while((c = getchar()) != EOF) { if(c == '\n') ++nls; else if(c == ' ') ++blanks; else if(tabs == '\t') ++tabs; } printf("tabs: %d, blanks: %d, nls: %d\n", tabs, blan...
C
#include <float.h> /* \|A\|_\inf_{0 <= i <= n-1\\ 0 <= j <= n-1} = max_{0<=i<=n-1} (sum_{j=0} |a_ij|) */ double norma (int n, **a) { double norm; /* norma trobada */ double s; /* valor temporal, possible norma */ int i, j; norm = 0; for (i = 0; i < n; i++) { s = 0; for (j = 0; j < n; j++) s += fabs (a[i]...
C
#include<stdio.h> struct process { char pname; int at, bt, ct, wt, tt, priority; int status; }pqueue[10]; int limit; void at_Sorting() { struct process temp; int i, j; for(i = 0; i < limit - 1; i++) { for(j = i + 1; j < limit; j++) { if(pqueue[i].at > pqueue[j].at) { temp = pqueue[i]; pqueue[i] = pqueue[j]; pque...
C
#include<stdio.h> #include<unistd.h> #include<stdlib.h> #include<signal.h> #include<time.h> #include<errno.h> #include<fcntl.h> #include<string.h> #include<sys/wait.h> #include<sys/types.h> #include<sys/ipc.h> #include<sys/shm.h> #define SHMSIZE 1024 int main(void) { void *shared_Mem; int shmid; int *shmaddr; i...
C
void inorder(struct TreeNode* root,int* returnSize,int *a)/*前序遍历二叉树*/ { if(!root) return; a[(*returnSize)++]=root->val; inorder(root->left,returnSize,a); inorder(root->right,returnSize,a); } int size(struct TreeNode* root)/*求二叉树数据个数*/ { if(!root) return 0; return 1+size(root->left)+size(root->right); ...
C
#include"header.h" char rxdata[10]; //Uart Initialization void uart_init() { U1LCR = 0x83; U1DLL = (15000000)/(BAUD<<4); U1LCR = 0x03; } // Data transmission void transmit_data(char data) { // while(*data != '\0') // { while(U1LSR & 0x20 == 0); U1THR = data; ...
C
#include <avr/interrupt.h> #include <avr/io.h> /* ADC initialisieren */ void adc_init(void) { uint16_t result; ADMUX = (0<<REFS1) | (1<<REFS0); // AVcc als Referenz benutzen // ADMUX = (1<<REFS1) | (1<<REFS0); // interne Referenzspannung nutzen // ADMUX = (0<<REFS1) | (0<<REFS0); ADCSRA = (1<<ADPS1)...
C
#include <stdio.h> void main() { int a,b,c; printf("enter the number"); scanf("%d %d",&a,&b); c=a; a=b; b=c; printf("after swapping=%d %d",a,b); }
C
#include <stdio.h> #include <stdlib.h> #include <time.h> int taille = 5; void init_tab(int *tab,int a) { int j; for(j=0;j<taille;j++) { tab[j]=a; } } int prod_elem_tab(int *tab) { int j; int res = 1; for(j=0;j<taille;j++) { res = res*tab[j]; } return res; } int prod_elem_tab_modif(int *tab,int i...
C
/********************************* ƣ LCDʾ1302ʱ ***********************************/ #include <reg52.h> #include "1302.h" #include "LCD1602.h" sbit SPK = P3^5; unsigned char num,AC_hour=0,AC_minute=0x01; unsigned char tab[]="Alarm Clock"; void delay(unsigned char i); /************************ Զַ**********************...
C
#include<stdio.h> void main() { int arr[5] = {10, 20, 30, 40 ,50}; int *ptr; ptr = arr; printf("%u\n", *++ptr + 3); printf("%u\n", *(ptr-- + 2)+5); printf("%u\n", *(ptr+3)-10); }
C
//strcat через for #include <stdio.h> #include <string.h> #include <stdlib.h> char* strcat2(char *a, char *b) { size_t len1 = strlen(a); size_t len2 = strlen(b); char *result = (char*)malloc(len1 + len2 + 1); for(int i = 0; i < len1; i++) { r...
C
#include "Render.h" void remove_block(int y, int x) { move_cursor_to(y * BLOCK_HEIGHT, x * BLOCK_WIDTH); printf(" "); move_cursor_to(y * BLOCK_HEIGHT + 1, x * BLOCK_WIDTH); printf(" "); } void print_platform(point* platform) { move_cursor_to(CONSOLE_HEIGHT - 1, 0); for (size_t i = 0; i < CO...
C
#include "head.h" // ----------------------------------------------------------------------------- // MESIN LIST !!! // ----------------------------------------------------------------------------- void createList (list *L) { // inisialisasi list (*L).first = -1; int i; for (i = 0; i < 100; i++) { /*proses...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* utils.c :+: :+: :+: ...
C
#include <os_malloc.h> #include <cmsis_os.h> #include <app_debug.h> #include <string.h> static osMutexId os_malloc_mutex; static int32_t gs_malloc_counter = 0; void os_malloc_init(void) { gs_malloc_counter = 0; osMutexDef(debug_mutex_c); os_malloc_mutex = osMutexCreate(osMutex(debug_mutex_c)...
C
/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ int TreeDepth(struct TreeNode* root) { if (root == NULL) { return 0; } int dep, dep1, dep2; dep1 = TreeDepth(root->left); dep2 = TreeDepth(root->right); return dep1>de...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_del.c :+: :+: :+: ...