language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <kern/syscall.h> extern void putchar(int c); extern int getchar(void); int main(void) { putchar('a'); putchar('b'); putchar('c'); /* while(1) { int c = getchar(); putchar(c); if(c == 'q') break; } */ return 0; }
C
#include <stdlib.h> #include <stdio.h> #include <math.h> static double count_quest(double p, double q); int main() { double n, p, q; double t = 0.0; int i; printf("n (1<=n<=1000000) ="); scanf("%lf", &n); printf("p (0<=n<=100) ="); scanf("%lf", &p); prin...
C
/* ** EPITECH PROJECT, 2018 ** my_put_nbr ** File description: ** A function that print a number */ #include "include/function.h" int conversion_for_decimal(int rest) { if (rest >= 0 && rest <= 9) rest = rest + 48; return (rest); } int my_put_nbr(int nb) { if (nb >= 10) { my_put_nbr(nb / ...
C
#include <stdio.h> // printf #include <signal.h> typedef int Int; typedef int Bool; typedef int Unit; #define false 0 #define true 1 #define unit 0 Bool and(Bool a, Bool b) { return a && b; } Bool or(Bool a, Bool b) { return a || b; } Bool xor(Bool a, Bool b) { return a != b; } Bool not(Bool a) { return !a; } Bool be...
C
#include <stdio.h> #include <stdlib.h> #define Maxterm 20 #define True 1 #define False 0 typedef struct Node* NodePtr; typedef struct ListNode* ListNodePtr; struct Node{ int id; ListNodePtr child; NodePtr parent; }; struct ListNode{ NodePtr data; ListNodePtr next; }; int num = 0; ...
C
/* ヘッダファイルのインクルード */ #include <stdio.h> /* 標準入出力 */ #include <stdlib.h> /* 標準ユーティリティ */ /* main関数 */ int main(void){ /* 変数・配列の宣言 */ char str[16]; /* 数値文字列を格納するchar型配列str(長さ16) */ double d; /* double型変数d */ /* 入力フォーム */ printf("str: "); /* strの入力フォームを出力. */ scanf("%s", str); /* scanfで入力された文字列をstrに格納. */ ...
C
#include <stdio.h> void inc(int *p); void pstr(char *c); struct s { int val; char *name; }; int main() { int *p; int i; i = 9; p = &i; printf("i is located at %p\n", p); printf("value of i: %d\n", i); inc(p); printf("i incremented: %d\n", i); char name[] = "Parker"; p...
C
#include <stdio.h> int isEven(int); int main() { int n; printf("Enter a number: "); scanf("%d", &n); if (isEven(n)) printf("Even number\n"); else printf("Odd number\n"); return 0; } int isEven(int n) { return !(n % 2); }
C
#ifndef UNIP_PIM_CLINIC_SETUP_H #define UNIP_PIM_CLINIC_SETUP_H #include <stdio.h> #include <stdlib.h> #include <io.h> void setup() { // Verifica se a pasta de dados esta criada int check = mkdir("dados"); if (!check) { mkdir("dados/tmp"); printf("* NECESSARIO CRIAR ESTRUTURA DE ARQUIVOS...
C
/** Program 4.4 Various input formatting options for reading integers are experimented in the program shown in Fig. 4.4. */ ///program begin #include<stdio.h> #include<conio.h> //main() function begin int main() { int a,b,c,x,y,z; int p,q,r; printf("Enter three integer numbers\n"); s...
C
#include<stdio.h> int main() { int i,j,r,c; printf("enter the rows and columns of matrices:\n"); scanf("%d%d",&r,&c); int arr1[r][c],arr2[r][c],arr3[r][c]; printf("enter the values of 1st matrix:\n"); for(i=0;i<r;i++) { for(j=0;j<c;j++) { printf("%d X %d :\t",i,j)...
C
/* * L3_dd_trg/input_drv_mouse * Mostly from the excellent ELDD book... */ #define pr_fmt(fmt) "%s:%s(): " fmt, KBUILD_MODNAME, __func__ #include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/fs.h> #include <linux/input.h> #include <linux/platform_device.h> #include <linux/mutex...
C
#include "mpi.h" #include <stdio.h> #include <stdlib.h> #include "../helper.c" #include "../init.c" MPI_Status status; double A[m][n], x[n], b[m]; int main(int argc, char **argv) { int num_procs, my_rank, num_workers, rows; int i, j, from_file, print_flag; double start, start_node, start_calc, start_comm_1, sta...
C
#pragma once #include "list.h" // Сделаем стек на основе списка: struct stack { Node* head; }; typedef struct stack Stack; void stack_init(Stack* s) { s->head = list_create(); } void push(Stack* s, int x) { list_add_first(&(s->head), x); } int pop(Stack* s) { return list_remove_first(&(s->head)); }...
C
/* ** Copyright 2012, albuer@gmail.com ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agre...
C
#include "file_writer.h" FILE* open_log_file(char *path) { FILE* fp = fopen(path,"a"); return fp; } void write_log_to_file(FILE* file, unsigned long long free_memory) { if (file) { fprintf(file,"free_memory=%llu\n",free_memory); } } void close_log_file(FILE* file) { if (file) {...
C
#include "Polygon.h" //polygon logic AlesiaPolygon* alesia__polygon__createPolygon(float x,float y) { AlesiaPolygon* result = calloc(sizeof(AlesiaPolygon),1); result->next = NULL; result->vertex = NULL; result->vertexCount = 0; result->initX = x; result->initY = y; result->lastX = x...
C
/* -*- C -*- */ #include <windows.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #define WPIPE "\\\\.\\pipe\\oskTERM" int main(int argc, char *argv[]) { HANDLE hPipe = INVALID_HANDLE_VALUE; char input[80]; printf("Running as %s\n", argv[0]); if( !strcmp(arg...
C
/* program 12 transpose of sparse matrix mohammed jasim e 31/3/15 s1337 */ #include <stdio.h> #define MAX 40 void read(int s[][3]); void display_sparse(int [][3]); void transpose(int [][3], int [][3]); void display(int [][3]); int main() { int a[MAX][3], b[MAX][3]; int flag; printf("Enter the order of the ma...
C
#include <stdio.h> #include <stdlib.h> int ser(int *x, int lo, int up, int y); int main(void) { int array[10] = { 2,3,8,9,55,22,33,44,77,88 }; printf(" %d", ser(array,0,9,77)); system("pause"); return 0; } int ser(int *x, int lo, int up, int y) { if(lo<=up) { int mid =lo+ (up-lo) / 2; if ...
C
#include "../includes/redNeuronal.h" #include <time.h> #include <math.h> /*ESTA VARIBLE SE USA PARA LAS CONDICIONES DE PARADA*/ redNeuronal* redpre=NULL; int etapa=0; double ecmAnt, ecmAhr; redNeuronal* iniRedPerceptron(int entrada, int oculta,int salida, double tasa){ double* pesos= NULL,** salidas= NULL; int i=0...
C
/* ** get_light.c for Raytracer2 in /rendu/semestre_02/gfx_raytracer2 ** ** Made by Ludovic Petrenko ** Login <ludonope@epitech.net> ** ** Started on Wed May 18 05:37:31 2016 Ludovic Petrenko ** Last update Sun May 22 16:12:10 2016 Ludovic Petrenko */ #include "raytracer.h" #include "tools/math.h" static void get_...
C
/******************************************************************************* ** File: ** ** TaskInput.c ** ** Contents: ** uC/OS-II programming ** ** History: ** Date Name Description ** ------------------------------------------------------------------------ ** ****************************...
C
/* ID: baikaiz1 PROG: castle LANG: C */ /** * Copyright (c) 2012 ZhongLigang. All Rights Reserved * $Id$ * * @file castle.c * @author ligang <ZhongLigang@gmail.com> * @date 2012-12-18 01:35:12 */ #include <stdlib.h> #include <stdio.h> #define MAX_ROWS 50 int matrix[MAX_ROWS][MAX_ROWS][5] = {0}; int sizes[MAX_...
C
#include <stdio.h> #include <stdalign.h> int main(int argc, char *argv[]) { (void)argc; (void)argv; #pragma pack(push, 1) struct foo { char c1; int i; char c2; }; #pragma pack(pop) struct bar { char c1; int i; char c2; }; printf("alignof in...
C
/** 3. Analyse the following code. **/ #include <stdio.h> #include <sys/types.h> #include <unistd.h> int main(void) { fork(); fork(); fork(); printf("SCOMP!\n"); return 0; } /** * a) How many processes are created by this code? **/ /* * 7 processes and the father process. */ /** * b) Draw a pr...
C
#include<stdio.h> int main() { int m,n,i; printf("Enter the value of m="); scanf("%d",&m); printf("Enter the value of n="); scanf("%d",&n); printf("Even numbers are- "); for(i=m;i<=n;i++) { if(i%2==0) { printf("%d, ",i); } } printf("\nOdd numbers are- "); for(i=m;i<=n;i++) { if(i%2!=0) { ...
C
#include<stdio.h> #include<stdlib.h> void main() { int temp1,temp2,temp3,temp4,i,winsize=8,noframes,moreframes; char c; int reciever(int); int simulate(int); temp4=0,temp1=0,temp2=0,temp3=0; printf("Enter number of frames"); scanf("%d",&noframes); for(i=0;i<200;i++) moreframes=noframes; while(moreframes>=0) { temp1=...
C
#include <stdio.h> int main(void) { int pieces, code; float total = 0; float pay, sales, hours; printf("Enter employee's number code (-1 to end): "); scanf_s("%d", &code); while (code != -1) { switch (code) { case 1: printf("Enter the manager's pay rate: "); scanf_s("%f", &pay); printf("Weekly...
C
#include <stdio.h> #include "wrapper.h" extern void NGCALLF(derrf,DERRF)(double *, double *); extern void NGCALLF(derrcf,DERRCF)(int *, double *, double *); NhlErrorTypes erf_W( void ) { /* * Input variables */ /* * Argument # 0 */ void *x; double *tmp_x = NULL; int ndims_x; ng_size_t dsizes_x[NCL_MAX_DI...
C
#include <cs50.h> #include <stdio.h> int main() { int h; int acrsum; do { printf("Height: "); h = get_int(); } while(h < 0 || h > 23); if(h==1) { printf("##\n"); } else { acrsum = h + 1; for(int across=0; across < h; across++) ...
C
/*-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-== Project 6 File: ListFunctions.c Created by: Fritts and Slayter Last edit on: 11/29/2013 (Fritts) Description: Functions for adding, deleteing, searching, and replacing data in linked lists. ==-==...
C
/** * Author: Jack Keating * Date: 2019/01/15 * * A simple hello world program in C * */ #include<stdlib.h> #include<stdio.h> int main(int argc, char **argv) { printf("Jack Keating\n"); printf("Mechanical Engineering\n"); printf("Max Van Arsdall\n"); printf("Undecided\n"); return 0; }
C
#include <stdio.h> #include <math.h> #include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> int main(int argc, char *argv[]) { const gsl_rng_type * T; gsl_rng * r; //select random number generator r = gsl_rng_alloc(gsl_rng_mt19937); FILE *fp; const int N = 1000,Iters = 100000; int accepted = 0; int ii; do...
C
#include<stdio.h> #include<stdlib.h> int main() { int a = 2; int b = 0; b = (a == 2) ? (3) : (4); printf("b = %d\n", b); return 0; }
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include"../inc/supplier.h" char New_Supplier_ID(Supplier Supp) { char a; FILE *f1=fopen("data1.csv","r"); if(f1==NULL) { perror("Unable to open the file"); } char buff[1024];//stores the first 1024 lines into buff int rc=0,cc=0,q=0; ...
C
#include "tls-socket.h" #include "sockutil.h" #include <openssl/bio.h> #include <openssl/ssl.h> #include <openssl/err.h> #include <stdio.h> #include <stdlib.h> struct tls_socket_t { socket_t tcp; SSL_CTX *ctx; SSL* ssl; }; int tls_socket_init() { SSL_library_init(); SSL_load_error_strings(); E...
C
#include <stdio.h> int compare( const void* a, const void* b) { int int_a = * ( (int*) a ); int int_b = * ( (int*) b ); if ( int_a == int_b ) return 0; else if ( int_a < int_b ) return -1; else return 1; } int main(void){ int vetor[10]=[6,5,2,3,4,1,9,8,7,0]; int i; qsort( vetor,...
C
#include<stdio.h> #include<unistd.h> int main() { /*this is my first program in C*/ printf("Hello World, This is my first code!"); printf("I Love C!!!"); return (0); }
C
/** * @file Calculator.c * @author mhmdreda99 (Moreda491999@gmail.com) * @brief * @version 1.1 * @date 2020-12-28 * * @copyright Copyright (c) 2020 * */ /***************************************************************************** * Module HEADER FILE * ****************...
C
// // Created by Holly Gong on 27/8/20. // #include "game.h" #include <stdlib.h> struct Game* create_game(struct Board* board1, struct Board* board2,struct Player* p1, struct Player* p2, int point) { struct Board* temp = create_board(board1->width, board1->height); printf("%s", print_board(temp)); ...
C
//#include<reg51.h> #include<stdio.h> #define lcd P1 //lcd --> port p1 is defined sbit rs=P1^0; sbit en=P1^1; sbit SDA=P2^1; // serial _data sbit SCL=P2^0; //serial clock sbit next=P2^2; //increment digit sbit inc=P2^3; ...
C
#include "assembler/label_table.h" #include "assembler/label.h" #include <stdlib.h> #include <stdio.h> #include <string.h> struct AssemblyLabelTable* alloc_label_table() { struct AssemblyLabelTable* table = malloc(sizeof(struct AssemblyLabelTable)); table->labels = NULL; table->count = 0; table->alloc_count ...
C
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <math.h> #include <stdlib.h> int check_date(int year, int month, int days) { if (month > 12) { return 0; } else { switch (month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: if (days > 31) { return 0; } else ...
C
/* * main.c * * Created on: Jan 22, 2014 * Author: mody */ #include <stdlib.h> #include <string.h> #include <avr/io.h> /* Scheduler include files. */ #include "FreeRTOS.h" #include"FreeRTOSConfig.h" #include "task.h" #include"usart.h" /*Set the priorties*/ #define Task1_PRIORITY1 2 #define Task2_PRIOR...
C
#include <stdio.h> #include <stdlib.h> #include "dll.h" /* Initialize an empty list in which the head and the tail are the same, i.e. they both point to a dummy node. */ dll_t *init_dll() { dll_t *dll = calloc(1, sizeof(dll_t)); dll_node_t *node = calloc(1, sizeof(dll_t)); node->next = node; node->prev...
C
#define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_STATIC #include "stb_image.h" #define STB_IMAGE_WRITE_IMPLEMENTATION #define STB_IMAGE_WRITE_STATIC #include "stb_image_write.h" #include "CStbImage.h" unsigned char* load_image(const char* path, int* width, int* height, int* channels, int desired_channels) { stb...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* pstate_env.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <math.h> #include <sys/mman.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <pthread.h> #include <errno.h> #include <string.h> #include "stringops.h" int main() { char file1[FILENAME_LENGTH], file2[FILENAME_LENGTH]; ...
C
#include <stdio.h> #include <stdlib.h> void Trim(int arr[],int size) { int left = 0; int right = size - 1; int tmp = 0; while (left < right) { while ((left < right) && (arr[left] % 2 == 1)) { left++; } while ((left < right) && (arr[right] % 2 == 0)) { right--; } if (left < ...
C
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <time.h> #define N_MAX 25600 float c_dot_product(const float *lhs, const float *rhs, size_t size) { assert(lhs && rhs); float sum = 0; for (size_t i = 0; i < size; i++) sum += lhs[i] * rhs[i]; return sum; } float asm_dot_prod...
C
/*СμѧУȤζ˶ᣬеһĿǣӡ ϻһЩӣÿдһ֣ʾҲɲμͼ л ʱվϽǵдšӡֵĸԺڵĸԽǵĸӻλáһֱҪֽ Ҫ·߸պùɡл仰 СһһжֿܵԾ·أ*/ #include <stdio.h> #include <stdlib.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int f(int x,int y); int main(int argc, char *argv[]) { printf("%d",f(5,4)); return 0; }...
C
/* * Demo.c * * Created on: Feb 14, 2017 * Author: Sweitz */ #include <stdio.h> #include <string.h> void copyDataBad(char *id) { char smallerBuffer[10]; strcpy(smallerBuffer, id); } int main(void) { char *userId = "0123456789"; copyDataBad(userId); return 0; }
C
#include <process.h> void send_mes_sync(int *buf, int can) { chan[can] = *buf; while(chan[can] != -1){} return; } void receive_mes(int *buf, int can) { while(chan[can] == -1){} *buf = chan[can]; chan[can] = -1; return; } void T1 (void *threadno) { int buffer = 10; send_mes...
C
#include <zeckendorf.h> #include <arithmetic.h> #include "zrep.h" #include <stdlib.h> #include <string.h> // cf. paper by Frougny et al. // add_same_len(s1, s2, len) returns the sum of Zeckendorf representations given by s1 and s2 // requires: s1 and s2 are char arrays of length len representing Zeckendorf representa...
C
// // OrdList.h // DataStructure // // Created by 润蕾 on 2018/4/15. // Copyright © 2018年 润蕾. All rights reserved. // #ifndef OrdList_h #define OrdList_h /* ADT OrderedList{ 数据对象:D = {a(i) | a(i) € Node, i = 1, 2……, n >= 0} 数据关系:R1 = {<a(i-1), a(i)> | a(i) € Node } 基本操作: InitList(&L) 操作结果:构造一个空的有序表L DestroyLi...
C
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <time.h> #include <sys/time.h> #include <stdint.h> #include <inttypes.h> #define MATRIX_A_ROWS 3 #define MATRIX_A_COLUMNS 2 #define MATRIX_B_ROWS 2 #define MATRIX_B_COLUMNS 3 #define NUM_THREADS 9 void *calc_cell(void *args); int **init_matrix(int ...
C
#include <stdio.h> void mergesort(int a[], int i, int j); void merge(int a[], int i1, int j1, int i2, int j2); unsigned long long int nCr (int n, int r); int main() { int count = 0; int n, i, k, t, b = 0; scanf("%d", &t); for (int l = 0; l < t; l++) { // printf("Enter no of elements:"); ...
C
#include <stdio.h> #include<conio.h> int sarrus(int m[3][3]) { return (m[0][0] * m[1][1] * m[2][2]) + (m[0][1] * m[1][2] * m[2][0]) + (m[0][2] * m[1][0] * m[2][1]) - (m[0][2] * m[1][1] * m[2][0]) - (m[0][1] * m[1][0] * m[2][2]) - (m[0][0] * m[1][2] * m[2][1]); } void matrixPrint(int m[3][3]) { int i, j; for (i = 0;...
C
#include <stdio.h> int main() { float a = 3.1415921, b = 3.14; double c = 23412.123412341; printf("a = %f, b = %f\n", a, b); printf("c = %lf\n", c); return 0; }
C
#include <stdio.h> #define PAWN 0 #define KNIGHT 1 #define BISHOP 2 #define ROOK 3 #define QUEEN 4 #define KING 5 #define BLACK 0 #define WHITE 1 #define VIRGIN 16 #define EMPTY -1 void piece2character(int code){ char *character_string = "pnbrqk"; if (code == EMPTY){ putchar(' '); return; } int type = (cod...
C
//{======================================================================= //! @file stack_cpu4.h //! @date 11.11.2013 4:10 //! @author Andrey Drobyshev <immortalguardian1@gmail.com> //! @version 4.0 //! //! This program contains functions for work with stack CPU. //}====================================================...
C
#include <stdio.h> #include <string.h> char arr[21]; int main() { int i; int max,len; scanf("%s",arr); len = strlen(arr); max = (len)/2-1; for(i=0;i<=max;i++) if(arr[0+i]!=arr[len-1-i]) {puts("false"); return 0;} puts("true"); return 0; }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* map.c :+: :+: :+: ...
C
#include <unistd.h> #include <sys/types.h> #include <errno.h> #include <stdio.h> #include <sys/wait.h> #include <stdlib.h> int main() { pid_t pidA; int randVal; int status; pidA= fork(); if (pidA >= 0) /* fork succeeded */ { if (pidA == 0) /* fork() r...
C
#include <math.h> #include "arm.h" int32 signed_sat(int64 val, int32 n, bool *issat) { int32 pown = powl(2, n - 1); int32 pown1 = pown - 1; if (val < -pown) { *issat = true; return -pown; } else if (val > pown1) { *issat = true; return pown1; } else { *issat = false; return val; } } uint32 un...
C
#include "string.h" #include "stdlib.h" #include "SymbolTable.h" void initializeTable(SymbolTable *S){ int index = 0; S->keys[index] = "SP"; S->addresses[index] = 0; index++; S->keys[index] = "LCL"; S->addresses[index] = 1; index++; S->keys[index] = "ARG"; S->addresses[index] = 2; index++; S->keys[index] = "T...
C
#include <stdio.h> int main() { #if 0 // pointer type int data = 0x12345678; printf("%p\n", &data); printf("%x\n", *(&data)); printf("%x\n", *((int*)0x7ffee4452a98)); printf("%x\n", *((char*)0x7ffee4452a98)); printf("%x\n", *((short*)0x7ffee4452a98)); printf("%x\n", *((int*)0x7ffee445...
C
#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> // Ce bo datoteka prevelika, bo prebral samo 10000 znakov. #define BUFSIZE 10000 #define err(mess) { fprintf( stderr, "napaka: %s\n", mess); exit(1); } void delete_line( int fd, int vrstica); void main( int argc, c...
C
#ifndef HASH_TABLE_H #define HASH_TABLE_H #include <stdlib.h> // mutate typedef of key_t, object_t and hf_param_t typedef int key_t; typedef int object_t; typedef int hf_param_t; typedef struct l_node { key_t key; object_t *obj; struct l_node *next; } list_node_t; typedef struct { int size; list_...
C
#include <stdio.h> int main() { int aux, numero1, numero2; printf("Escribe un primer n%cmero:\n", 163); scanf( "%d", &numero1 ); printf("Escribe un segundo n%cmero:\n", 163); scanf( "%d", &numero2 ); printf( "Los valores se han intercambiado\n" ); aux = numero1; numero1 = numero2; ...
C
/* * My drawing snake funs */ #include "my_snake.h" void init_curses() { /* 开启 curses 模式 */ initscr(); /* * 开启 cbreak 模式,除了DELETE\CTRL 等仍被视为特殊控制字元外 * 一切输入的字符将立刻被一一读取 */ cbreak(); /* * 用来决定当输入资料时 * 按下 RETURN 键是否被对应为 NEWLINE 字符 */ nonl(); /* * echo() and noecho() * 此函式用来控制从键盘输入字元时是否将字元显示在终...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* updatePlace.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> extern char ** environ; int main(){ char* s = getenv("USER"); printf("user is: %d\n", s ); const int consint; // consint = 32432; int data[5] = {10, 30, 60, 50, 40}; char string[] = "A B C 0123"; unsigned int temp; printf("data: %d\n", *(data + 1)); printf("Swapping...
C
#define MAX_QUEUE_SIZE 5000 typedef int element_type; //ring buffer //one slot is intentially set aside to mark if the buffer is full typedef struct{ volatile element_type data[MAX_QUEUE_SIZE + 1]; volatile int head; volatile int tail; } queue_type; extern void init_queue(queue_type * queue);...
C
#include <stdlib.h> #include <stdio.h> #include <assert.h> #include "uthread.h" #include "uthread_sem.h" #ifdef VERBOSE #define VERBOSE_PRINT(S, ...) printf (S, ##__VA_ARGS__); #else #define VERBOSE_PRINT(S, ...) ; #endif #define MAX_ITEMS 10 const int NUM_ITERATIONS = 200; const int NUM_CONSUMERS = 2; const int NU...
C
#include<stm32f10x.h> #include"bianma.h" #include"delay.h" //DIOΪģʽ void DIO_IN(void) { GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); } /...
C
/** * @file fileUtils.h * @author Bastien T. * @date 21 January 2018 * @brief Utility functions for files */ #ifndef TP3_UTILS_H #define TP3_UTILS_H #include <sys/types.h> /** * Returns a concatenation of the folder and the filename * @param folder The folder where resides the file * @param filename The file...
C
#include<stdio.h> #include<conio.h> #include<ctype.h> void main() { char character; clrscr(); printf("Enter the input:\n"); character=getchar(); if(isalpha(character)>0) printf("The input is a letter\n"); else if(isdigit(character)>0) printf("The input is a digit\n"); else printf("The input is not a alpha...
C
//counter implemented w/ threads #include <stdio.h> #include <pthread.h> #include <stdlib.h> #define NUM_THREADS 100 #define NUM_ITERATIONS 5000 //data structure definition typedef struct __counter_t { int value; pthread_mutex_t lock; } counter_t; void init(counter_t *c) { c->value = 0; pthread_mute...
C
#include<stdio.h> #include<stdlib.h> void main() { int r,c,r2,c2,i,j; printf("enter the row and column of first matrix-->"); scanf("%d%d",&r,&c); printf("enter the row and column of second matrix-->"); scanf("%d%d",&r2,&c2); int *arr=malloc(r*c*sizeof(int)); int *arr2=malloc(r2*c2*si...
C
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <signal.h> void despiertaNormal(){ } void ejecutals(){ printf("ejecutando ls\n"); if(fork() == 0) execlp("ls", "ls", NULL); else wait(NULL); } void ejecutapstree(){ printf("ejecutando pstree\n"); ...
C
// Write a program that opens the text.txt file (with the `fopen()` system call) located in this directory // and then calls `fork()` to create a new process. Can both the child and parent access the file descriptor // returned by `fopen()`? What happens when they are written to the file concurrently? //Answer: It l...
C
#include <sys/timeb.h> #include <errno.h> #include "lp.h" #include "lp_internal.h" #ifdef WIN32 #define HAVE_FTIME #endif /* Implement floattime() for various platforms */ static double floattime(void) { /* There are three ways to get the time: (1) gettimeofday() -- resolution in microseconds (2) ftime() -- reso...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_print_arg.c :+: :+: :+: ...
C
/* * Copyright © 2018-NOW Synapse Research Innovation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applic...
C
#include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <sys/ioctl.h> int main(int argc, char * argv[]) { char *arg = argv[1]; int i = atoi(arg); int f = open("/dev/BufferedMem", O_RDWR); if (f == -1) printf("file open error\n"); ioctl(f, _IOR('Q', 2, int), &i); return 0; }
C
#ifndef __RETRUINO_H_INCLUDED__ #define __RETRUINO_H_INCLUDED__ #include <TFT.h> #include <Arduios_Kernel.h> /* The Retruino library is used to access the components of the Retruino in a hardware independet way, that means, if you have another hardware just change the library and everything works. ...
C
/* * ttycap - routines for dealing with the teletype capability data base * Bill Joy UCB September 25, 1977 */ #ifdef ibm char ttycap[] "dd:ttycap"; #else char ttycap[] "/etc/ttycap"; #endif /* extern */ static char *tbuf; tgetent(bp, name) char *bp, *name; { register char *cp; register int /* cap, *...
C
#include <stdio.h> #include <stdlib.h> # define PRIMO 262139 int hashN(int n){ return n%PRIMO; } int main(void){ int v[PRIMO]; int n; scanf("%d", &n); for (int i = 0; i < n; i++){ int t; scanf("%d", &t); v[hashN(t)] = t; } int c; while(scanf("%d", &c)==1){ ...
C
/* * $Id: ShakerSort.c 6 2006-09-10 15:35:16Z marcus $ * * ShakerSort * Recolocando MIN e MAX por iteracao * */ void ShakerSort (long k[], int n) { int x,y; // loops de transversao int tmp, min, max; // de trabalho int i=n-1; // Extremo D for( x=0; x<(n-x-2); x++ ) { ...
C
#include <stdio.h> #include <stdlib.h> #define gc getchar_unlocked int get_i() { char c = gc(); while(c<'0' || c>'9') c = gc(); int ret = 0; while(c>='0' && c<='9') { ret = 10 * ret + c - 48; c = gc(); } return ret; } static void put_i(unsigned int n) { #define BSIZE 6 char buf[BSIZE]; int b...
C
#include <libraries/dos.h> #include "tree.h" struct FileHandler* filehandler; int bytes_written; int loop; int arraysize; UWORD* gpointer; char fp[5]; char tobewritten[4]; UWORD result; void main() { printf("Size of UWORD: %d\n", sizeof(UWORD)); // 52 rows, 58 colums. 52*58 = 3016 bits // 377 bytes no padding //...
C
#ifndef __MSA_rules_ye_Maths__ #define __MSA_rules_ye_Maths__ #include <math.h> /***************************** Misc *************************************/ #define MSA_pF(vv) ( (float*)(&vv) ) // cast as pointer to float /* #define _Step(x,a) ((x)>=(a)?1:0) // return 1 or 0 depending on sign #define _Sig...
C
/* * CSF Assignment 1 * Arbitrary-precision integer data type * Function implementations */ #include <stdlib.h> #include <string.h> #include <assert.h> #include "apint.h" #include <stdio.h> #include <math.h> /* Parameters: val (unsigned 64 bit value) * Declare and initialize new ApInt using val * */ ApInt *ap...
C
#ifndef DATABASE_UTILITIES_H #define DATABASE_UTILITIES_H #include <stdbool.h> #include <sqlite3.h> #include "cryptography.h" #define PUB_MSG_TYPE 1 #define PRIV_MSG_TYPE 2 /* holds the user information fetched from the database on a successful login or register */ typedef struct fetched_user_info { unsigned char ...
C
/************************************************************************************** : Weather : WeatherInfo.h : WeatherInfo, . **************************************************************************************/ #ifndef WEATHER_INFO_H #define WEATHER_INFO_H //...
C
#include "jpg.h" #include "targa.h" #include <sys/time.h> #ifdef PSOC #ifdef BENCH_JPEG #undef PSOC #endif #ifndef PSOC unsigned long micros() { struct timeval tv; gettimeofday(&tv,NULL); return (1000000*tv.tv_sec) + tv.tv_usec; } int main() { // load image from disk tga_image tga; load_tga(&tga...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include "bibl.h" #include "entree_sortie.h" #define TMAX 41 #define LMAX 100000 // TOUT MARCHE SAUF DOUBLON void initialise_biblio(Biblio* bib) { bib->L=NULL; bib->nbliv=0; } s_livre* creer_livre( int num, char* tit, char* aut ) { s...
C
#include<stdio.h> #include<stdlib.h> #define N 100 #define swap(a,b) {int temp=a;a=b;b=temp;} int arr[N]; void bubble_sort(int * a) { for ( int i = 0; i < N; i++) { int max = a[i]; int index = i; for (int j = i+1; j < N; j++) { if (a[j] > max) { max = a[j]; index = j; } } swap(a[i]...