language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
/* Collection of functions over a CFG boars structure that are not related to actual state changes nor tactical evaluation; though they may still be useful. */ #include "config.h" #include <stdlib.h> #include <string.h> #include <assert.h> #include "alloc.h" #include "board.h" #include "cfg_board.h" #include "flog.h...
C
// autor: Ana Luisa // autor: Gabriel Sylar // arquivo: L5211.c // atividade: 2.1.1 #include <stdio.h> #include <pthread.h> #include <unistd.h> pthread_mutex_t mutex; pthread_mutexattr_t attr; void bar() { printf("Tentando pegar o lock de novo.\n"); pthread_mutex_lock(&mutex); printf("Estou com duplo acesso?\n...
C
#include<stdio.h> int main() { int i,j,n; //double a; scanf("%d",&n); double a[n]; for(i=0;i<n;i++) { scanf("%lf",&a[i]); } int max = a[0]; for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { if(a[i]>a[j]) { int temp; temp = a[i]; a[i] = a[j]; a[j] = temp; } } } for(i=0;i<n;i++) { ...
C
#include <stdio.h> #include "cuboid.h" double getLength() { double l; printf("Enter the length of the cuboid: "); scanf("%lf", &l); return l; } double getWidth() { double w; printf("Enter the width of the cuboid: "); scanf("%lf", &w); return w; } double getHeight() { double h; pri...
C
#include <string.h> #include "utils.h" int ymax(int a, int b) { return a < b ? b : a; } int wstrsize(wchar_t *szStr) { return (wcslen(szStr)+1) * sizeof(wchar_t) / sizeof(char); }
C
/* * Description: This sets up a generic timer that you can register. * Use TimerGetValue(<timer instance>) to get the certain timer instance value. * You can test the return value to see if the value is >= to a certain value * * * */ #include "LSP.h" #ifdef USE_MTIMERS #include "main...
C
#pragma once struct Position { int x; int y; unsigned int tileID; Position() = default; Position(unsigned int tileID, int x, int y) : tileID{ tileID }, x { x }, y{ y } {}; void move(int dx, int dy); }; bool operator==(Position& position1, Position& position2); bool operator!=(Position& position1...
C
/** * helpers.c * * Helper functions for Problem Set 3. */ #define SWAP(A, B) { int t = A; A = B; B = t; } #include <cs50.h> #include <math.h> #include "helpers.h" /** * Returns true if value is in array of n values, else false. */ bool search(int value, int values[], int n) { if (n < 0) { return fal...
C
#include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netinet/ip.h> #include <stdio.h> #include <string.h> #include <unistd.h> #include <arpa/inet.h> #include <errno.h> #include <stdlib.h> #include <assert.h> #include <pthread.h> #include <fcntl.h> #include <poll.h> #define DX 5e-10 struct ...
C
/* * Author: Nikhil Jagdale * Description: This program provides dummy GPS co-odrindates generated ramdomly * along with the current system date and time. Information is packed * in a struct for the client to further process * * Copyright (c) 2015 Nikhil Jagdale */ #include "G...
C
#include "common.h" #include "vga.h" extern char get_char(); int str2int(char *b, int i); int read_int(char *prompt) { // display prompt draw_string(prompt); // read char buffer[20]; int i = 0; char c; while( (c = get_char()) != '\n' ) { buffer[i ++] = c; } buffer[i] = '\0'; return str2int(buffer, --i)...
C
#include "hash_tables.h" /** *hash_table_delete - deletes a hash table *@ht: hashtable used * * Return: void */ void hash_table_delete(hash_table_t *ht) { hash_node_t *temp, *ptr; unsigned long int count; if (!ht) return; for (count = 0; count < ht->size; count++) { ptr = ht->array[count]; while (ptr) {...
C
/*Lee un maximo de caracteres del teclado y lo guarda en el puntero dado. Si hay * mas caracteres de los que se pueden leer estos son descartados * ARGUMENTOS: * cadena: Un array o puntero de tamano maximo+1 (debe haber espacio para * el NULL final) en donde se va a guardar la lectura del teclado * tamano: El...
C
// // Created by puzankova 30.05.18 // #include "priority_queue.h" #define ALLOCATE(t, n) (t *) malloc((n) * sizeof(t)) struct Node { double value; int key; struct Node* next; struct Node* prev; }; int capacity = 0; struct Node *highest = NULL; void restore_props() { struct Node *cur = highest; while(...
C
#include <stdio.h> #include <stdlib.h> typedef unsigned char Byte; typedef unsigned short USHORT; typedef struct h_tree{ Byte symbol; int frequency; struct h_tree *left; struct h_tree *right; } Node; typedef Node* NODE; NODE create_node(){ NODE htree = (NODE) malloc(sizeof(No...
C
#include <stdlib.h> #include <stdio.h> int main(int argc, char * argv[]) { if (argc < 3) fprintf(stdout, "Il faut donner un mot et une phrase en arguments sur la ligne de commande.\n"); else { int taille = 0; while(argv[1][taille]!= '\0'){ taille++; } char * mot_a_trouver = malloc(...
C
/* This program initializes 3 (3x4) 2D arrays. It then multiplies the elements of the 1st and 2nd array and stores the answer of each in the elements of the 3rd array. Author: Robert Eviston Date: 18th November 2013 */ #include <stdio.h> #define ROW 3 #define COL 4 main() { int matrix1[ROW][COL]; int matrix2[...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* error.c :+: :+: :+: ...
C
/** ****************************************************************************** * @file crc.c * @author SE4 Sistemi Embedded Team (Di Fiore Giovanni, Iannucci Federico, Miranda Salvatore) * @version V1.0 * @date 05/lug/2015 * @brief TODO: brief for crc.c ***************************************...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> int main () { float N1, N2, M; printf("Informe a nota 1: "); scanf("%f", &N1); printf("Informe a nota 2: "); scanf("%f", &N2); if(N1>=0 || N2>=0) { M = (N1+N2)/2; if(M<4) { printf("Reprovado"); } else { if(M>7) { pri...
C
#ifndef __M_SERIAL_H_ #define __M_SERIAL_H_ #include<windows.h> /** * @brief serial_exists * * Check if a serial port exist * * @param[in] port number of port: 7 for "COM7" * * @return TRUE if serial port found, FALSE when not found */ BOOL serial_exist( int port); /** * @brief serial_open * * Open a seri...
C
//选择排序 void SelectSort(int *array, int size) { for (int i = 0; i < size - 1; i++) { int MaxPos = 0; for (int j = 1; j < size-i; j++) { if (array[j]>array[MaxPos]) { MaxPos = j; } } if (MaxPos != size - i - 1) { Swap(&array[MaxPos], &array[size - 1 - i]); } } } void SelectSortOP(int *...
C
#include <stdio.h> int main() {//Вывести все различные элементы последовательности, упорядоченные по возрастанию. int N, a=0, b=0, i=0; scanf ("%d", &N); for (i; i<N; i++) { a=b; scanf ("%d", &b); if (b!=a) printf ("%d ", b); } return 0; }
C
//IEEE Giresun SB //Bubble Sort Algorithm #include <stdio.h> #include <stdlib.h> //rand() ve srand() için stdlib kütüphanesi ekleniyor #define BOYUT 100000 //BOYUT ismindi dizi boyutu için sabit tanımlanıyor int main(void) { int dizi[BOYUT] = {0}; //Dizinin her ekemanına sıfır atanıyor size_t i, gecis; ...
C
#include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <pthread.h> #include <netinet/in.h> #include <stdio.h> #include <string.h> #include <unistd.h> #include <arpa/inet.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/mman.h> #include <sys/types.h> int main(int argc, const char * argv[]...
C
#include <stdio.h> int main() { char* p1 = "anything"; char* p2 = "anything"; printf("p1=%x, p2=%x\n", p1, p2); return 0; }
C
#ifndef SPLAYTREE_H #define SPLAYTREE_H #include <cstdlib> #include <cstdio> #include <cmath> #include "chem_global.h" #include <climits> #include <cfloat> #include <algorithm> #include "defines.h" #define KEYTYP int #define VALTYP double /* floor function for negative values */ #define NEGFLR(x) ( ((x)<0) ? ( ((...
C
#include <stdio.h> #include <stdlib.h> #include <pthread.h> struct foo { int a , b, c, d ; }; void printfoo(char * s , struct foo * fp); void * thr_fun1(void * arg); void * thr_fun2(void * arg); int main() { int err ; pthread_t tid1 ; pthread_t tid2 ; struct foo * fp ; err = pthread_create(&tid1,NULL,thr_...
C
/* * ===================================================================================== * * Filename: main.c * * Description: * * Version: 1.0 * Created: 08/16/2015 01:52:04 PM * Revision: none * Compiler: gcc * * Author: Jiang JiaJi (@.@), jialij@xilinx...
C
/* * Bootstrap Scheme - a quick and very dirty Scheme interpreter. * Copyright (C) 2010 Peter Michaux (http://peter.michaux.ca/) * * This program is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public * License version 3 as published by the Free Software Foun...
C
#include<stdio.h> #include<mpi.h> #define MASTERTAG 1 #define SLAVETAG 4 int processNumber, numOfProcesses, lowerBound, upperBound, allocatedPortion, i, j, k; double matrixA[100][100], matrixB[100][100], matrixC[100][100]; MPI_Status status; MPI_Request request; void initializeAB() { for (i = 0; i <...
C
#include <OWL/Optimized3d/tensor/tensorf32.h> //Return a^n static size_t powint(unsigned int a, unsigned int n) { size_t res = 1; size_t p = a; for(unsigned int n_ = n ; n_ != 0 ; n_ >>= 1u) { if((n_ & 1u) != 0) { res *= p; } p *= p; } return res; ...
C
#pragma once #include <stdint.h> #ifndef UINT32_MAX #include <limits.h> #define UINT32_MAX ULONG_MAX #endif uint32_t xor128(void) { static uint32_t x = 123456789; static uint32_t y = 362436069; static uint32_t z = 521288629; static uint32_t w = 88675123; uint32_t t; t = x ^ (x << 11); x = y; y = z; z = w; re...
C
/* Beat Hirsbrunner and Fulvio Frapolli, University of Fribourg, January 2008 */ #include <stdio.h> int main(int argc, char *argv[]) { FILE *f; unsigned long pos; /* position to read from */ if (argc != 2) { printf("Usage: %s input_file\n", argv[0]); return -1; } f = fopen(argv[1], "r"); ...
C
#include<stdio.h> #include<conio.h> #include<stdlib.h> struct NODE { int info; struct NODE *next; struct NODE *pre; }; typedef struct NODE *cdnode; cdnode insertl(cdnode ,int); cdnode insertb(cdnode ,int); cdnode insertsp(cdnode ,int,int); cdnode createnode(cdnode,int); cdnode deletel(cdnode); cdnode deleteb(cdnode ...
C
#include <stdio.h> #include <string.h> #include "strutil.h" int main() { char buffer[128]; char buffer2[128]; strcpy( buffer, "Esto ES UNA prueba" ); printf( "Cadena original: '%s'\n", buffer ); strtolower( buffer ); printf( "Cadena: '%s'\n", buffer ); strtoupper( buff...
C
#include <stdio.h> #include <sys/fcntl.h> #include <stdlib.h> #include <unistd.h> typedef struct record { int num; char *name; } rec; int main(int argc, char *argv[]) { int fd = open(argv[1], O_RDWR); if (fd == -1) { printf("Unable to open the file\n"); exit(1); } printf("...
C
#include <stdio.h> #include <sys/types.h> #include <fcntl.h> #include <sys/ioctl.h> #ifdef OLD_FBIO_H_LOC #include <sun/fbio.h> #else /*OLD_FBIO_H_LOC*/ #include <sys/fbio.h> #endif /*OLD_FBIO_H_LOC*/ static char* typename(); void main( argc, argv ) int argc; char* argv[]; { int fd; struct fbgatt...
C
#include<stdio.h> int main() { int i=0,j=0; for(i=0;i<10;i++) { j=i; while(1) { if(j==5) break; printf("%d\n",j); j++; } } return 0; }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* errors_handler.c :+: :+: :+: ...
C
///String function strlen,strcpy,strcat,strcmp. #include<stdio.h> #include<string.h> int main() { char s[100],s1[100]; int i,ln,ck; gets(s); //scanf("%s%s",s,s1); //strcpy(s,s1); ///strcat(s," "); ///strcat(s,s1); ///ln=strlen(s); ///ck=strcmp(s,s1); strrev(s); printf("%s",s)...
C
#include <stdio.h> #include "Tokeniser.c" int main(){ char* value = "if 'hello' == 1 {"; Tokeniser tokeniser; Tokeniser_create(&tokeniser, value); /* Token tok; Token_create(&tok, STRING_TOKEN, "hello world"); Tokeniser_add(&tokeniser, &tok); //printf("%s", tokeniser.tokens[0]->value); */ Tokeniser_token...
C
#include <iostream> #include <algorithm> using namespace std; int main() { int n; cin >> n; string t[n]; for (int i = 0; i < n; i++) cin >> t[i]; sort( t, t + n); for (int i = 0; i < n; i++) cout << t[i] << '\n'; }
C
#include <stdio.h> #include <stdlib.h> int Recur_Bin(int, int); int Itera_Bin(int, int); int main(void) { int input_1,input_2; printf("JCWUW:"); scanf("%d", &input_1); printf("JCWUU:"); scanf("%d", &input_2); printf("Recur:\n __\n"); printf(" / \\ %d\n", input_1); printf("x %d\n", Recur_Bin(input_1,...
C
int test(float x, double y) { return x + y; } int main() { printf("%d (expected 15)\n", test(7.753f, 8.222)); return 0; }
C
#include "gpio_driver.h" int mem_fd; void *gpio_map; volatile unsigned *gpio; unsigned char gpio_bus[GPIO_BUS_SIZE] = {24, 4, 17, 22, 9, 25, 18, 23}; unsigned char clock_pin = 8; unsigned char key_pin = 10; unsigned char bus_dir_pin = 21; unsigned initialized = 0x00; unsigned char debug_flag = 0x01; void set_debug_...
C
//Henry Plaskonos //ex7.3 //8 Oct 2018 //Numerically integrates a function with simpsons. #include <stdio.h> #include <math.h> #include "comphys.h" #include "comphys.c" double f(double n); double simpson(double a, double b, int points, double (*func)(double)); int main() { int ni; int points; double y; ...
C
#include <stdio.h> #define SIZE 10 int sum(int *start, int *end); int main(void){ int marbles[SIZE] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; printf("the total of numbers is %d", sum(marbles, marbles+SIZE)); return 0; } int sum(int *start, int *end){ int total = 0; while(start < end){ total += *s...
C
#ifndef GRAPH_H #define GRAPH_H #include "maplocation.h" #define MAX_GRAPH_EDGES 32 typedef MapLocation GraphVertex; typedef char Direction; typedef struct GraphEdge { GraphVertex start; Direction direction; GraphVertex end; } GraphEdge; typedef struct Graph { GraphEdge edges[MAX_GRAPH_EDGES]; ...
C
/** Square Tone Generator */ /* @section I N C L U D E S */ #include "at89c5131.h" #include "stdio.h" #include "math.h" unsigned char sendMSB [] = {0x77, 0x7a, 0x7b, 0x7d, 0x7e, 0x7f, 0x7f, 0x7f, 0x7e,0x7d, 0x7b, 0x7a, 0x77, 0x75,0x74,0x72,0x71,0x70,0x70, 0x70,...
C
#include "game.h" void print_game_rules(void) { printf("\nA player rolls two dice. Each die has six faces. \nThese faces contain 1, 2, 3, 4, 5, and 6 spots. \nAfter the dice have come to rest, the sum of the spots on the two upward faces is calculated. \nIf the sum is 7 or 11 on the first throw, the player wins. \...
C
#include <stdio.h> void strCpy(char *s, char *t); int main() { char str1[] = "hello, world"; char str2[16]; strCpy(str2, str1); printf("now the str2 is: %s\n", str2); } /* 字符串复制(指针进阶版)*/ void strCpy(char *s, char *t) { while ((*s++ = *t++) != '\0') ; }
C
#ifndef STATIC_HASH_TABLE_H_INCLUDED_ #define STATIC_HASH_TABLE_H_INCLUDED_ #define STATIC_HASH_TABLE_SIZE 10 #include <stdlib.h> #include <stdio.h> #include <stdbool.h> typedef struct bucket_ { char* key; int value; struct bucket_* next_bucket; struct bucket_* prev_bucket; } bucket; typedef struct static_hash_...
C
// Copyright 2019 Google LLC // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
C
#include <stdio.h> #include <math.h> #include <malloc.h> float Determinante(int n, float **m){ int sinal = 1; int i, j, k; float det = 0; float **A; if(n == 1){ return m[0][0]; } else { A =(float**) malloc((n-1)*sizeof(float*)); for (i=0;i<n;i++) { A[i] = (float*) malloc((n-1)*siz...
C
// Copyright 2007-2009 Russ Cox. All Rights Reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. #include <stdio.h> #include <stdlib.h> #include "reos_pattern.h" #include "unicode_inst.h" #include "unicode_tree.h" #include "unicode/uchar.h" #include "unicod...
C
#include<stdlib.h> #include<limits.h> #include "shedl_utils.c" void srtf(struct Proc* procs, int n){ sort_procs(procs, n); print_procs(procs,n); int c=0/*keep track of finished process*/, time=0; int shortest = INT_MAX/*a high fucking value*/; int index = -1/* assume that we have not found our sm...
C
#include "generator.h" #include <stdio.h> static PyObject* generator_new(PyTypeObject* type, PyObject* args, PyObject* kwargs) { // Parse arguments (iterator: set of dicts) PyObject *sequence; if (!PyArg_ParseTuple(args, "O", &sequence)) { return NULL; } // Check arguments if (!PySequ...
C
#define STACK_MIN_SIZE 1 #define EMPTY_STACK -1 typedef struct stack_record *Stack; struct stack_record{ int capacity; int stack_top; stack_elem_t *elements; }; Stack create_stack(int size); void dispose_stack(Stack S); void push(stack_elem_t element, Stack S); int is_full(Stack S); int is_empty(Stack S); Stac...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> /* use the second bit to store result, keep first bit to calculate neighbors DIE2DIE: 00 LIVE2DIE: 01 DIE2LIVE: 10 LIVE2LIVE: 11 */ enum { DIE2DIE = 0, LIVE2DIE = 1, DIE2LIVE = 2, LIVE2LIVE = 3 }; int neighbors(int **board, int boardRowSize,...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* l3d_ray_hit_utils2.c :+: :+: :+: ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* output_h.c :+: :+: :+: ...
C
#include<stdio.h> void toh(int,char,char,char); int main() { int num; printf("Enter the number of the disk:"); scanf("%d",&num); printf("\nThe sequence of moves in the tower of hanoi are:"); toh(num,'A','C','B'); return 0; } void toh(int num,char frompeg,char topeg,char auxpeg) { if(n...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* algo.c :+: :+: :+: ...
C
#include<stdio.h> unsigned long int numberOfZeros(unsigned long ); int main(){ unsigned long int result; unsigned long int number; int testcases; scanf("%d",&testcases); while(testcases-- > 0){ scanf("%lu",&number); result= numberOfZeros(number); printf("%lu\n",result); } getch(); ...
C
#include <stdio.h> #include <stdlib.h> typedef struct treenode //树的节点 { char data ; treenode * leftchild, * rightchild ; }TreeNode; typedef TreeNode * StackElemType ; //定义栈包含的数据类型 typedef struct stacknode //栈的节点 { StackElemType data ; stacknode * next ; }StackNode; typedef TreeNode * Queue...
C
#include <string.h> size_t my_strlen(char *s) { return ((s) ? (strlen(s)) : (0)); }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <security/pam_appl.h> #include <security/pam_ext.h> #include <security/pam_modules.h> #include <security/pam_modutil.h> /* expected hook */ PAM_EXTERN int pam_sm_setcred( pam_handle_t *pamh, int flags, int a...
C
#include<stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char **argv[]){ int n = atoi(argv[1]); if(n>0 && n<11){ for (int i = 1; i <= n; ++i) { printf("%d\n", i); } } if (n==0) { return 0; } for (int i = 0; argv[i]!='\0'; ++i) { if (argv[i]>= 'A' && argv[i]<= 'Z') { retur...
C
#include <dispatch/dispatch.h> #include <stdio.h> // Pure GCD cat-like program (used to test the overhead of OCaml's runtime) dispatch_group_t cat(dispatch_fd_t fd) { dispatch_group_t group = dispatch_group_create(); dispatch_queue_t queue = dispatch_queue_create("ocaml.rw.queue", DISPATCH_QUEUE_SERIAL); dispatc...
C
#include "../Headers/ShiftAnd.h" int * FazMascara(char * P,int m){ //Realiza o alocamento e preenchimento da mascara do padrao int * M; M = (int *)calloc(256, sizeof(int)); //128 for(int i=0;i < m; i++){ M[P[i]] = M[P[i]] | 1 << (m-i-1); } return M; } void ShiftAnd(char * P, char * T,int m,int n){ //Alg...
C
/** * @author: Ashish A Gaikwad <ash.gkwd@gmail.com> * Shell Sort Algorithm (modified Insertion sort) in C */ #include <stdio.h> #define MAX 30 int main() { int total, kira, series[MAX]; printf("Enter Number Of Elements:\n"); scanf("%d", &total); for(int i=0; i<total; i++) { printf("Number %d: ", i+1); scan...
C
#include "lexos/kprint.h" #include "lexos/panic.h" #include "lexos/arch/apic.h" /* Local variable */ static volatile uint32_t *lapic = NULL; static volatile uint32_t *ioapic = NULL; void apic_find(acpi_madt_s *madt) { if (!madt) { panic(NULL, "MADT POINTER IS NULL.\n"); } lapic = (uint32_...
C
/* Name: Zaynab Ghazi * File: music.h * Desc: * Header corresponding to "music.c" */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include "ArrayList.h" //create s ong struct: struct song{ char* title; char* artist; char* duration; char* release; char* fade_out_t0; char* tempo; cha...
C
/* --------------------------------------------------------- */ /* --------------- A Very Short Example -------------------- */ /* --------------------------------------------------------- */ #include <stdio.h> #include <stdlib.h> /* free() */ #include <stddef.h> /* NULL */ #include "cmaes_interface.h" double fitfun(...
C
#include <stdio.h> #include <math.h> int main(){ double b=3.14,f=(9*b/5-b/5)/10,x=b/5,result1=0; for(;x<9*b/5;x+=f) { result1=-log(fabs(2*sin(x/2))); double result2=0,result3=0; for(int n=1;n<41;n++) { double el; el=cos(n*x)/n; ...
C
// Program name: Required Exercise 2.0B // // Author: Ashley Bruce // Date: 09-11-19 // Course: Computer Science 217 // // // Description: Modifying the program to calculate the course effeciency at Cuesta // #include <stdio.h> #include <stdlib.h> int main (void) ...
C
/* ** EPITECH PROJECT, 2020 ** af ** File description: ** * */ #include "my.h" int get_ch(char str) { if (str == '1') return 1; if (str == '2') return 2; if (str == '3') return 3; if (str == '4') return 4; if (str == '5') return 5; if (str == '6') ...
C
#include <stdio.h> #include <string.h> #include <locale.h> int main(){ char s[11]; char a[] = " / / "; printf("Ange datum i svenskt format ÅÅÅÅ-MM-DD: "); scanf("%s", s); strncpy(a, s+5, 2); // Månad strncpy(a+3, s+8, 2); // Dag strncpy(a+6, s+2, 2); // År printf("I amerika skriver ...
C
#include <stdlib.h> #include <string.h> #include <stdio.h> #include <sys/socket.h> #include <sys/types.h> #include <sys/wait.h> #include <netinet/in.h> #include <unistd.h> #include <fcntl.h> #include <signal.h> #include <stdbool.h> #include <sys/ipc.h> #include <sys/shm.h> #include "handler.h" enum { MAX_CONNECTIONS_...
C
#include "Stack.h" void * stack_new(size_t element_size) { pStack ptr = (pStack)calloc(1, sizeof(Stack)); if (NULL == ptr){ fprintf(stderr, "stack allocate error\n"); } ptr->element_size = element_size; ptr->data = NULL; ptr->size = 0; ptr->capacity = 0; /* Initialize method */...
C
#include <fstream> #include <iostream> #include <string> #include <iomanip> using namespace std; enum RelationType {LESS, EQUAL, GREATER}; class ItemType { public: void WriteItemToFile (ofstream& outFile) ; RelationType ComparedTo(ItemType& item) const; // Purpose: To compare to items of the sam...
C
// Interface to the Student DB ADT // !!! DO NOT MODIFY THIS FILE !!! #ifndef STUDENT_DB_H #define STUDENT_DB_H #include "List.h" #include "Record.h" typedef struct studentDb *StudentDb; /** * Creates a new student DB */ StudentDb DbNew(void); /** * Frees all memory allocated to the given student DB */ void ...
C
/*x = achar o ponto médio y = fórmula x1,x2 são os intervalos */ #include<stdio.h> #include<stdlib.h> #include<math.h> int main(){ float x1,x2,x,y,e= 0.0001,calc,calc1; x1= 0; x2= 2; calc= pow(x1,3)-x1-1; calc1= pow(x2,3)-x2-1; if(calc>calc1){ printf("decrescente\n"); }else printf("crescente\...
C
/******************************************************************** * * @Arxiu : command.c * @Finalitat : Funcions que conformen el TAD comanda. * @Autors : Esteve Genovard Ferriol - ls30742 & Sergi Simó Bosquet - ls30685 * @Data Creació: 12 de Desembre del 2016 * **********************************************...
C
#include <stdio.h> #include <string.h> #include <capstone/capstone.h> #include "lib.h" typedef char *(trans_insn_fn_t)(cs_insn *insn); trans_insn_fn_t trans_mov; trans_insn_fn_t trans_movz; trans_insn_fn_t trans_adr; trans_insn_fn_t trans_svc; static trans_insn_fn_t *trans_insn_fn_table[] = { trans_mov, trans_...
C
#include "core/time.h" #include "platform/timer.h" #include "math/math.h" // -------------------------------------------------------------------------------- // Time, DeltaTime, FrameCount engine_time_t engine_time = { 0, 0, 0, 0, 1, 1 }; // Time, CosTime, SinTime, DeltaTime vec4_t engine_shader_time = { .vec = { 0,...
C
//*BFS*// //*Prasansha Satpathy*// //*02- C2*// #include <stdio.h> int rear = 0 , front = -1; int queue[100]; int color[100], dist[100], graph[100][100]; int nodes, edges; int WHITE = 0; int GRAY = 1; int BLACK = 2; void enqueue(int root_node) { queue[rear] = root_node; rear = rear + 1; } ...
C
#include <sys/queue.h> #include "utils.h" struct buffer{ char *buf; int size; LIST_ENTRY(buffer) next; }; static LIST_HEAD(buffer_chain, buffer) buffer_chain_head; int buffer_total_size = 0; static void clear_buffer_chain(){ while(buffer_chain_head.lh_first != NULL){ struct buffer *tmp = buffer_chain_head.lh_firs...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> /** * Auto-generated code below aims at helping you parse * the standard input according to the problem statement. **/ int char_to_strbinary(char *in, char * out){ for(int i=0; i<strlen(in) -1; i++){ char c=in[i]; c<<=1; f...
C
#include <stdio.h> #include <stdlib.h> int f[1001][8193] = {{0}}, w[1001], v[1001]; char b[1001][8193]; int T = 0, R[1001]; void printKnaspItem(int i, int W) { if (i == 0 || W == 0) return; if (b[i][W] == '<') { printKnaspItem(i - 1, W - w[i]); ++T; R[T] = i; } else ...
C
/* * dsa-verify.c * * Created on: Oct 31, 2019, 12:58:33 PM * Author: Joshua Fehrenbach */ #include "dsa.h" #include "dsa-hash.h" int dsa_verify(const struct dsa_params *params, mpz_srcptr y, const uint8_t *digest, size_t digest_size, struct dsa_signature *sig) { mpz_t w, v, tmp; int res; /* Check th...
C
/* * ===================================================================================== * * Filename: fork_sig_sync.c * * Description: * * Version: 1.0 * Created: 09/20/2014 10:43:47 AM * Revision: none * Compiler: gcc * * Author: Kevin (###), kevin101@g...
C
#include "ee.h" #include "stm32f4xx.h" #include "joystick.h" /* Returns -1 if it's on the left, 1 on the right, 0 in the middle */ char get_x(uint32_t convertedVoltageADC){ if(convertedVoltageADC > 3000) //left return 1; if(convertedVoltageADC < 300) //right return -1; else return 0; } /* Returns -1 if it...
C
#include<stdio.h> int main() { int i,j,k; printf("Enter the value of i and j:"); scanf("%d%d",&i,&j); k=(--i)*2+2*(3j+5); printf("The output of expression \(--i\)\*2+2\*\(3j+5\) is %d",k); }
C
/************************************************************** Target MCU & clock speed: ATmega328P @ 8Mhz internal Name : LEDintr_WDT_328P.c Author : Insoo Kim (insoo@hotmail.com) Date : Sun April 12, 2015 Description: Blink LED of PB0, using timer1 interrupt (T=1s) HEX size[Byte]: 218 out of 32K ...
C
#include "holberton.h" /** * _strcat - appends strings * @dest: destination to append * @src: what to append * Return: pointer to dest */ char *_strcat(char *dest, char *src) { int tupapiesteban, j; for (tupapiesteban = 0; dest[tupapiesteban] != '\0'; tupapiesteban++) { } j = 0; while (src[j] != '\0') { ...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <assert.h> #include <ctype.h> #include <string.h> #include <sys/types.h> #include <sys/wait.h> #include <sys/stat.h> #include <unistd.h> int main(int argc, char *argv[]) { //Constants const int MAX_LINE = 1024; int batch_mode = 0...
C
/* fifobuffer.c *************************************************************** Contains functions for a FIFO-styled buffer that can be used as an intermediary storage when reading/writing data is unsynchron ized. The buffer is stoed in the heap. Use Mutex locks when rea ding/writing to the buffer. The implemen...
C
#include <stdio.h> #include<conio.h> int main(void) { char a[50]; int i,n; scanf("%s %d",a,&n); int len; len=strlen(a); for(i=n;i<=len;i++) { printf("%c",a[i]); } getch(); }