language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <assert.h> #include "equivalence.h" #include "bryant.h" #include "var.h" #define HAS_CONTRADICTION(F) (F->pars[TRUE_VAR]==FALSE_VAR) #if !defined(max) #define max(a,b) ((a)<(b) ? (b) : (a)) #endif #if !defined(min) #define min(a,b) ((a)<(b) ? (a) :...
C
/* file: Depuncture.c Description: Depuncture bits by zero-padding deleted bits. The calling syntax is: [output] = Depuncture(input, pun_pattern, tail_pattern ) output = Unpunctured codeword input = Punctured codeword pun_pattern = Puncturing pattern for encoded data bits ...
C
/* ============================================================================ Name : CompoundInterst.c Author : Jerin Version : Copyright : Your copyright notice Description : Hello World in C, Ansi-style ============================================================================ */ #inclu...
C
#include<stdio.h> #include<stdlib.h> #include<time.h> int main(){ int arr[100000],i,j; arr[0]=-1; srand(time(NULL)); for(i=1;i<100000;i++){ arr[i]=rand(); } for(i=2;i<100000;i++){ int temp=arr[i]; for(j=i;temp<=arr[j-1];j--){ arr[j]=arr[j-1]; } arr[j]=temp; } for(i=0;i<100000...
C
#include "Text_LCD.h" void LCD_pulse_enable(void) // 하강 에지에서 동작 { PORT_CONTROL |= (1 << E_PIN); // E를 HIGH로 _delay_us(1); PORT_CONTROL &= ~(1 << E_PIN); // E를 LOW로 _delay_ms(1); } void LCD_write_data(uint8_t data) { PORT_CONTROL |= (1 << RS_PIN); // 문자 출력에서 RS는 1 if(MODE == 8) { PORT_DAT...
C
#include <stdio.h> #include <getopt.h> #include <string.h> #include <stdlib.h> #include <string.h> void imprime_uso(); void procesarArchivo(const char * separador,int primeraLinea,int incremento,int numerarVacias,int cantidadVaciasJuntas,char * archivo); int main(int argc, char *argv[]) { int index; int primeraLine...
C
/************************************************************************** * Copyright 2015 Sensel, Inc. * * 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/lic...
C
#include<stdio.h> main() { char ch; printf("enter the hex value.."); scanf("%x",&ch); printf("before swaping nibble....%x\n",ch); ch=ch>>4|ch<<4; printf("after swaping nibble....%x\n",ch); }
C
/* ** in_str.c for 42shlib in /media/data/all/projects/42sh-v1/lib/my/src/string ** ** Made by kevin labbe ** Login <labbe_k@epitech.net> ** ** Started on Tue Apr 23 14:26:16 2013 kevin labbe ** Last update Tue Apr 23 14:26:23 2013 kevin labbe */ #include "my.h" int in_str(char chr, char *str) { while (*str) ...
C
#include<stdio.h> void main(void) { int a; for(a = 0; a < 5; a++) { printf("a is equal to %d\n", a); } printf("a is equal to %d and I've finished\n", a); }
C
#include "main.h" static int usage() { printf("./rpi-toolbox util read|write [port] [0|1]"); return -1; } int util_main(int argc, const char* argv[]) { if (argc < 5) { return usage(); } init_gpio(); int port = atoi(argv[3]); int on = atoi(argv[4]); if (strcmp(argv[2], "write")...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> typedef struct graph graph; struct graph{ size_t v_count; bool *isvisited; bool **adj_matrix; int *prev_list; }; graph* create_graph(int); void set_edge(graph*,int,int,bool); bool dfs(graph*,int,int); int main(){ graph *g = create_...
C
// run it by gcc -o pthread pthread.c -lpthread #include<stdio.h> #include<stdlib.h> #include<pthread.h> #include<unistd.h> void *myfunc(void *myvar); int main() { pthread_t thread1, thread2; char *msg1="First thread"; char *msg2="Second thread"; int ret1,ret2; ret1=pthread_create(&thread1,NULL,myfunc,(void *) msg...
C
#include <stdio.h> int main() { int num; int m,n; printf("请输入A(B)矩阵的行数(列数)和列数(行数)[行数小于列数]:"); scanf("%d %d",&m,&n); int a[m][n]; int b[n][m]; for(int i = 0;i < m;i++) { for(int j = 0; j < n; j++) { printf("请输入a[%d][%d](b[%d][%d])的值:",i,j,j,i); scanf("%d",&num); a[i][j]= num; b[j][i]= num; ...
C
#include <getopt.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "numstoany.h" #include "xmemtools.h" int main(int argc, char *argv[], __attribute__((unused)) char *envp[]) { unsigned short inpbase = 0; unsigned short outbase = 0; char *number = NULL; char *characters ...
C
//////////////////////////////////////////////////////////// // reg.h // Library Management Interface register contents to KSZ9896 switch // b.r.koball // k.i.fire // V1.0 // 2018-11-07 // //////////////////////////////////////////////////////////// #include "reg.h" //#ifdef HELP #include <stdio.h> #include <st...
C
#include <stdio.h> int cube(int x) { return x*x*x; } int s(int n) { int i, sum=0; for (i = 1; i <= n; i++) { sum += cube(i); } return sum; } int main(int argc, const char *argv[]) { int n, i; scanf("%d", &n); for (i = 1; s(i) <= n; i++) {} printf("%d\n", i-1); return 0...
C
// Use a PWM to adjust the brightness of LED1 #include "wiced.h" #define PWM_PIN WICED_PWM_5 void application_start( ) { float duty_cycle = 50.0; wiced_init(); /* Initialize the WICED device */ wiced_gpio_deinit(WICED_SH_LED1); // Need to de-init the GPIO if it is already set to drive the LED while (...
C
/** * @author: Anthony Palumbo * date: 12-27-2016 * description: Generates a text file with random numbers. */ #include <stdlib.h> #include <stdio.h> #define NUM_OF_INTEGERS 50000 #define MAX_VAL 1000 /** * Main function that is run. * @return: 0 on exit success */ int main(void) { FILE *pFile = fopen("inp...
C
#include<stdio.h> int main(void) { int i,c,n,a=1,b=10; printf("\n enter the number"); scanf("%d",&n); if(a<b) { for(i=1;i<=n;i++); { c++; } } if(c==2) { printf("\n given no.is a prime no"); } else { printf("\n ginen no. is not a prime no."); } }
C
/*! \file \brief Library for implementing linkedlists */ #include "linkedlist.h" #include <stdlib.h> #include <string.h> #define SUCCESS 1 #define FAIL 0 #define COMP_CALLBACK int (*comparator)(void *a, void *b) #ifdef DEBUG #define DEBUG_OUTPUT(string) (printf("[debug] %s\n",string)) #else #...
C
/* REQUIRED REGISTERS (defined in REGS.h in HWL folder): (OCRn) for reading/writing value to be compared with in comparison modes. (TCCRn) for choosing which mode from the modes mentioned below is active. (TIFR) for getting the status of the different flags used below. (TIMSK) for masking (aka enabling or disabl...
C
#include<bits/stdc++.h> using namespace std; int rows,columns; char park[1000][1000]; int gate1[1][2],gate2[1][2],gate3[1][2],cage[1][2]; int persondistance,dinodistance; int numberofgrasslands=0; int safeareas=0; class QItem { public: int row; int col; int dist; QItem(int x, int y, int w) : row(x), col(y), dist...
C
/* ESTE CÓDIGO ES UN CONVERSOR * DE DÍAS A SEGUNDOS*/ #include <stdio.h> int main() { int numero_de_dias; int hora = 24; int minuto; int segundo; printf ("===========CONVERSOR DE DIAS A SEGUNDOS===============\n"); printf ("Ingrese el numero de días: "); scanf ("%d", &numero_de_dias); mi...
C
#include "utils.h" #include <assert.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int GetStringCharCount(char const *str) { int size = -1; while (str[++size] != '\0') ; return size; } int GetIntCharCount(int num) { if (num = 0) { return 0; } int size = 0; while ...
C
#include <stdio.h> int a ; // BSS or uninitialized data int b =10 ; // Data Segment or DS static int c ; // BSS static int d = 10 ; // DS int sum( int a , int b) // stack { return a + b ; // stack } void main() { static int e ; // BSS static int f = 20 ; // DS int g = 20 ; // stack int h ; // st...
C
/* * File: timer.c * Author: Cesar Aguirre * * */ #include <xc.h> void initTimer1(){ //TODO: Initialize Timer 1 to have a period of // 1 seconds. Enable its interrupt TMR1 = 0; PR1 = 39062; // 1 Second T1CONbits.TCKPS = 3; // Prescalar 256 T1CONbits.TCS = 0; IEC0bits.T1IE = 1; ...
C
#include "header.h" int main(int argc, char* argv[]) { struct sockaddr_un serverAddr = { 0 }; int serverFd = 0; if ((serverFd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { perror("socket error"); goto ErrorExit; } // bind the server. serverAddr.sun_family = AF_UNIX; strncpy(serverAddr.sun_path, BIND_SOCKET,...
C
// goldpan.c #include <std.h> inherit OBJECT; int count; void create(){ ::create(); set_id(({"pan","gold pan"})); set_name("pan"); set_short("a pan"); set_long("This is a small circular aluminum pan. It is somewhat cone shaped and the inside edge of one side has a set of ridges built into it that lo...
C
#include "tidbot.h" #include "cfg.h" #include "time.h" #define MACHINE_FILE "machine_list.txt" int balls_locked = 0; char* random_machine (const char *target, const char *channel) { FILE *machine_file; char lineread[1024] = ""; char reply[1024]; char *machine; char *manufacturer; char *year; ...
C
#include "stdio.h" #define M 3 #define N 4 #define Max ((M)>(N)?(M):(N)) /* 34оΪ */ typedef struct mtxn { int row; int col; struct mtxn *right,*down; union {int value; struct mtxn *link; }tag; }manode; /* ʮĽͶ */ /* һά󴴽ʮʾ */ manode *creacroslist(manode *h[],int A[M][N]) { int ...
C
/*1 3 2 4 5 6 10 9 8 7 11 12 13 14 15*/ #include <stdio.h> int main() { int i, j, count, value, N; printf("Enter rows: "); scanf("%d", &N); count = 0; for(i=1; i<=N; i++) { value = (i & 1) ? (count + 1) : (count + i); for(j=1; j<=i; j++) { p...
C
#include<stdio.h> int main() { int a,b,i,sum=0; scanf("%d", &a); while(1 == scanf("%d", &b)) { if(b>0) break; } for(i=a;i<a+b;i++) { sum += i; } printf("%d\n", sum); return 0; }
C
#include "bst.h" #include "asserts.h" #include "mem.h" #include "stack.h" #include "string_utils.h" #include <inttypes.h> typedef enum { UBST_NODE_BLACK, UBST_NODE_RED, } ubst_color_t; struct ubst_node { ugeneric_t k; ugeneric_t v; struct ubst_node *left; struct ubst_node *right; ubst_col...
C
/*6. Desenvolva um algoritimoque o usurio informe dois nmeros e que atravs de chamada de funes seja retornado em tela o seguinte: */ #include<stdio.h> void dobro(int a ,int b){ a = a*2; b = b*2; printf( "dobro = a[ %d ]b[ %d ] \n",a,b); } void qudrado (int a ,int b){ a = (a*a); b = (b*b); prin...
C
#include <stdio.h> int main() { int a; float b; const float c = 3.141592; b = 3.14; printf("%f\n", b); printf("%.3f\n", c); scanf_s("%d", &a); a = a << 3; printf("a=%d\n", a); }
C
/* * LinkedList.c * * Created on: Sep 8, 2017 * Author: Alex Lim * * Description: Basic singly linked list with user input to append * to head element dynamically. */ #include <stdlib.h> #include <stdio.h> // the type for the node that makes up the body of the list struct node { int data; // data ...
C
/* * fixeddict->c * * Implements a fixed-size dictionary sorted alphabetically * * Created on: 21/12/2011 * Author: piranna */ #include "fixedDict.h" #include <string.h> // memset, strcmp, strncpy void fixedDict_init(fixedDict* dict, pairKeyValue* pairs) { dict->pairs = pairs; dict->length = 0; } v...
C
#include <signal.h> #include <stdio.h> #include <unistd.h> #include <time.h> static int signals = 0; void handler(int sig_no, siginfo_t *info, void *context) { printf("I received a signal %d from a process with pid: %d ", info->si_signo, info->si_pid); if (sig_no == SIGUSR2) printf("(SIGUSR2)!\n"); ...
C
/* Thomas Stoeckert COP 3223H - Final Project This file holds all the structs and helper functions related to the structs. It's quite massive. But anything that deals with an ll object is very similar to each other, since I have to repeat it for each type of node. I've documented the first set,...
C
/* libco.amd64_gcc (2015-04-22) author: byuu, Alex W. Jackson license: public domain */ #define LIBCO_C #include "libco.h" #include <assert.h> #include <stdlib.h> #ifdef __cplusplus extern "C" { #endif static thread_local long long co_active_buffer[64]; static thread_local cothread_t co_active_handle = 0; sta...
C
#pragma once //--- Calculation with DP ----------------------------------------------------- // PRECONDITION: 0 <= n <= 66 struct CombAllDP { vector<vector<long long>> C; CombAllDP() { } CombAllDP(int n) { build(n); } // find all nCr (0 <= n <= N, 0 <= r <= n) void build(int n) ...
C
/* run.config COMMENT: Temporal analysis with respect to scopes */ #include <stddef.h> int main() { int *p = NULL, *q = NULL; { int i = 9; p = &i; q = p; } /*@assert ! \valid(p); */ /*@assert ! \valid(q); */ { int j = 8; p = &j; /*@assert \valid(p); */ *p = 1; /* ...
C
/* help.c - Routines having to do with help XRogue: Expeditions into the Dungeons of Doom Copyright (C) 1991 Robert Pietkivitch All rights reserved. Based on "Advanced Rogue" Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T All rights reserved. Based on "Rogue: Ex...
C
/* Copyright (C) 2011-2012,2018 G.P. Halkes This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY W...
C
#include <stdio.h> int main(int argc, char const *argv[]) { int const array[5] = {1, 2, 3, 4, 5}; printf("Puvoni hodnoty: "); for (int i = 0; i < 5; i++) { printf("%d, ", array[i]); } printf("\n"); printf("Nove hodnoty: "); for (int i = 4; i >= 0; i--) { printf("...
C
#ifndef WRITE_POPULATION_STATISTICS_IN_FILE_H #define WRITE_POPULATION_STATISTICS_IN_FILE_H #include "create_population.h" #include "agent_struct.h" #include "counters_struct.h" //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Write Population Statistics in File void writePopulationStatisticsInFile( FILE *simulation_s...
C
#include <stdio.h> #include <stdlib.h> #ifndef DECOMPRESSIONE_H_ #define DECOMPRESSIONE_H_ /* * Metodo per la lettura del file codificato un bit alla volta */ int leggiBitPerBit(FILE *fp, unsigned char *buffer, int *dimBuffer, long int dimFile, int leggiBit); /* * Metodo per la lettura di un intero carattere dal ...
C
/** * @file spi.c * @author Stanislav Bobovych * @details * Bare bones master spi driver. */ #include <avr/io.h> #include "spi.h" void SPI_init(void) { /* Set MOSI and SCK output, all others input */ DDR_SPI |= (1<<DD_MOSI)|(1<<DD_SCK); //DDRB |= ( 1 << PB5 ) | ( 1 << PB7 ); /* Enable SPI, Master, set clock ...
C
//~ Input: 234567 //~ Output: sum of left half even number is: 6 #include<stdio.h> int rv(int u) { int r=0; while(u!=0) { r = r*10+u%10; u = u/10; } return r; } int lgt(int w) { int y; while(w!=0) { w = w/10; y++; } return y; } int LftEvSm(int rev,int s) { int c=0,y=0,h; while(rev!=0) { if(c >...
C
//Primos #include <stdlib.h> #include <stdio.h> int main() { int i, cont = 0; for(i = 2; i < 100; i++) { if(i % 2 != 0 && i % 3 != 0 && i % 5 != 0 && i % 7 != 0) { cont ++; printf("\n %d es un numero primo! \n", i); } else { if(i...
C
#include <stdio.h> #include <stdlib.h> #include <errno.h> #include <sys/types.h> #include <unistd.h> #include <string.h> #include <pthread.h> #include <math.h> #include <sys/time.h> typedef struct imageMatrix { int width; int height; unsigned char** matrix; } imageMatrix; imageMatrix inFileMatrix; imageMa...
C
#ifndef MAIN_MENU_H #define MAIN_MENU_H #include "menus.h" /// this enum contains the choices available in main menu typedef enum mainMenuChoices { MusicsMenu, PlaylistsMenu, ExitApplication } MainMenuChoices; /// this struct contains all UI elements present in main menu typedef struct mainMenuUI { MenuUI *info;...
C
/*! * @file running_mean.c * * @brief ECE 486 Spring 2019 Lab 1 running_mean.c calculates the running mean * * @author ECE486 Lab Group 9 * @author Spencer Goulette, Jason Millette, Steven Ferrarese * * @date Feb 4, 2019 * * Contains three major functions. The first function is the init_running_mean * funct...
C
#include<stdio.h> void main() { char n; printf("enter the letter"); scanf("%c",&n); if(n==a||n==e||n==i||n==o||n==u) { printf("VOWELS"); } else { printf("consonants"); } }
C
#include "klib.h" #if !defined(__ISA_NATIVE__) || defined(__NATIVE_USE_KLIB__) size_t strlen(const char *s) { size_t ret = 0; while (s[ret] != '\0') { ret++; } return ret; } char *strcpy(char *dst,const char *src) { size_t i = 0; for (i = 0; src[i] != '\0'; ++i) { dst[i] = src[i]; } dst[i] = ...
C
/* * CS 24000 First mid-semester exam. * Problem #3-3 * * void censorWord(char * str, char * badword) * * Arguments: * char * str -- a pointer to a string * char * badword -- a word to replace in string * * Description: * Given a string of input, replace all occurrences of the word badword in ...
C
// 剑指 Offer 13. 机器人的运动范围 // 地上有一个m行n列的方格,从坐标 [0,0] 到坐标 [m-1,n-1] 。一个机器人从坐标 [0, 0] 的格子开始移动,它每次可以向左、右、上、下移动一格(不能移动到方格外),也不能进入行坐标和列坐标的数位之和大于k的格子。例如,当k为18时,机器人能够进入方格 [35, 37] ,因为3+5+3+7=18。但它不能进入方格 [35, 38],因为3+5+3+8=19。请问该机器人能够到达多少个格子? //   // 示例 1: // 输入:m = 2, n = 3, k = 1 // 输出:3 // 示例 2: // 输入:m = 3, n = 1, k = 0 ...
C
/********************************************************************************************** Program srchedge.c Written by Young K. Kwon For Charlie Avis, JPL Date complete: March 12, 1996 srchedge.c: INPUT IMAGE: Only black and white halfword(2 bytes) vicar images are valid. The input image only has a dark ...
C
/*robot.c neural network robot of craziness */ # include < mega32.h > #include < stdlib.h > #include < stdio.h > #include < math.h > #include < delay.h > // Timeout Values for each task #define t1 2 //2 5 is debugging # define t4 20 //20 5000 is debugging # define t5 14000 //14000 10000 is debugging...
C
/* * This file is part of the AprilTag library. * * AprilTag is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * April...
C
/* * Largest Palindrome in the String * * Created on: September 28, 2012 * Author: Swapnil */ // Find the longest palindrome in a string // Returns the length of the maximum palindrome and stores the position in pointer int find_largest_palindrome(char *str, int *pos) { int length = 1, max = 1; // char...
C
/* ex4-5c.c */ #include <stdio.h> #include <stdlib.h> int main() { /* 將範例4-4b的else-if敘述更改為switch敘述,並 將int改為char型態,示範switch在字元常數下的用法 */ char level; printf("請問你是幾年級的學生(1…5): "); scanf("%c", &level); switch(level) { case '1': printf("你是大一新生\n"); break; cas...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.c :+: :+: :+: ...
C
/* Student Name :kamal rokka Roll no.: Lab no.: Program:assighment operator Date: subject: */ #include<stdio.h> int main() { int a,b; printf("enter first no.:\n"); scanf("%d",&a); printf("enter secod no.:\n"); scanf("%d",&b); a+=b; //a=a+b printf("result o...
C
#include "udp_task.h" static void udpTask(RingbufHandle_t buffer); TaskHandle_t createUdpTask(RingbufHandle_t buffer) { xTaskHandle xHandle = NULL; xTaskCreate(udpTask, UDP_TASK_TAG, 8192, buffer, 5, &xHandle); if (xHandle == NULL) { ESP_LOGE(UDP_TASK_TAG, "Could not create task"); abort(); } ret...
C
#include <stdio.h> typedef struct Car1{ int num; double gas; unsigned int tire : 3; unsigned int roof : 1; unsigned int color : 4; }Car1; typedef struct Car2{ int num; double gas; unsigned int tire; unsigned int roof; unsigned int color; }Car2; int main(void) { printf("ビットフィールドを使った構造体のサイズは%luバイ...
C
// RUN: %splay %s | lli | FileCheck %s #include <stdio.h> #include <stdlib.h> static int sum(int n) { int i, result = 0; for (i = 1; i <= n; ++i) result += i; return result; } int main(int argc, char **argv) { // CHECK: 15 printf("%d\n", sum(5)); // CHECK: 5050 printf("%d\n", sum(100)); }
C
#define K 4 #define M 10 #define FIRST_PLAYER -1 #include <string.h> #include <stdlib.h> #include <stdio.h> #include <stdbool.h> #include "game_tree.c" const int JOGO_FINALIZADO = 1; const int JOGADA_BEM_SUCEDIDA = 2; const int JOGADA_INVALIDA = 3; struct Node * tree; int currentPlayer = FIRST_PLAYER; char* playerN...
C
#include"myheader.c" NODE*del(NODE*head) { int r; NODE*temp,*pre; if(head==NULL) { printf("List is empty..\n"); return head; } printf("Enter rol to del..\n"); scanf("%d",&r); temp=head; while(temp) { if(temp->roll!=r) { pre=temp; temp=temp->link; } else break; } if(temp==NULL) { printf("rol not found..\n"); return h...
C
#include <stdio.h> #include <stdlib.h> #include "List.h" ListNode* List_Init(void) { printf("Please input your data end by '#':\n"); char c = '\0'; ListNode* head = NULL; ListNode* prev = NULL; while (c = getchar()) { if( '#' == c) break; ListNode* p = (ListNode*)malloc(sizeof(*p)); if(NULL == p) { p...
C
#include <stdio.h> void main(){ float peso, altura; int idade, ano_nascimento, dia_nascimento; scanf("%f", &peso); scanf("%f", &altura); scanf("%d", &idade); scanf("%d", &ano_nascimento); scanf("%d", &dia_nascimento); float formula = (((((peso + altura) / idade) + ano_nas...
C
//Project 1 //Author: Carter Mooring //Date: Sept. 11th, 2020 // Implementation of merge sort using a linked mainList. //compile a C program: gcc hello.c //gcc -o hello hello.c //run a C program: ./hello #include <stdio.h> #include <stdlib.h> //Define the link node as a struct struct node{ int data; s...
C
#include <vm_pool.h> #include <page_table.h> #define PAGE_SIZE (4 * 1024) void init_vmpool(struct vmpool *pvmpool, struct pagetable *_pagetable, unsigned int _base_address, unsigned int _size) { pvmpool->ppagetable = _pagetable; pvmpool->base_address = _base_address; pvmpool->size = _size; #if 0 ...
C
/********************************************* * * Convert a tree to its mirror tree * *///////////////////////////////////////////// #include <stdio.h> #include <stdlib.h> typedef struct treeNode{ int data; struct treeNode *left; struct treeNode *right; } node; node *create() { int n; node *p; printf("...
C
#include <stdio.h> #include "reverse.h" int main(){ char s[100] = "!dlrow ,olleH"; reverse(s); printf("%s\n", s); return 0; }
C
/** ******************************************************************************* * @file brk.c * @author Olli Vanhoja * @brief Change space allocation. * @section LICENSE * Copyright (c) 2014, 2015 Olli Vanhoja <olli.vanhoja@cs.helsinki.fi> * All rights reserved. * * Redistribution and use in source a...
C
#include <msp430.h> #define STOP_WATCHDOG 0x5A80 // Stop the watchdog timer #define ACLK 0x0100 // Timer ACLK source #define UP 0x0010 // Timer UP mode #define ENABLE_PINS 0xFFFE // Required to use input and outputs #define SLOW 0x00C0 // Slow down ACLK by factor of 8 /** * m...
C
#include <stdio.h> #include <stdlib.h> int verifica_input(int valore) { if (valore > 0) { return valore; } else { printf("%d is invalid\n", valore); exit(0); } } int calcola_somma(int n1, int n2) { return n1 + n2; } int main(int argc, char *argv[]) { int a, b, somma; a = verifica_input(atoi(argv[1]))...
C
#include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <sys/socket.h> #include <netdb.h> #include <string.h> #include "server.h" int clientContinue = 1; char * commandFind(char* inputString) { char * exitCommand = "@exit"; if(strncmp(exit...
C
#ifndef _CLIENT_H_ #define _CLIENT_H_ #include "structs.h" /* Holds all the information relative to a client. */ typedef struct{ pid_t pid; //the calling process pid request_t * request; //pointer to the request made by this client answer_t * answer; //pointer to the answer received by this client in...
C
#include "electricalcalc.h" void kwtoamps1p(float *realpower, float *powerfactor, int *rmsvoltage) { printf("Enter real power (KW): "); scanf("%f", realpower); printf("Enter powerfactor: "); scanf("%f", powerfactor); printf("Enter RMS voltage: "); scanf("%d", rmsvoltage); } void kwtoamps3p(flo...
C
#include<stdio.h> #include<unistd.h> #include<stdlib.h> #include<fcntl.h> int main() { int pipefd[2]; char c = 'R'; unsigned int count = 0; if(pipe2(pipefd,O_NONBLOCK) == -1) { perror("pipe"); return (EXIT_FAILURE); } printf("readend = %d\n",pipefd[0]); printf("writeend = %d\n",pipefd[1]); while(wri...
C
#include <stdio.h> #include <omp.h> #include <limits.h> int sum = INT_MIN; int main(void) { double start = omp_get_wtime(); #pragma omp parallel for num_threads(4) for(int i=0;i<(INT_MAX>>7);i++) { sum++; } sum+=1; printf("%lf \n", omp_get_wtime()-start); return 0; }
C
///ѧеĽ׳ˣһн׳˺Ľ /*#include<stdio.h> //׼룬ͷļ #include<stdlib.h> //׼ͷļ int fun(int); //һзֵĺ int main(void)//ҽһ { int n; //nںһ printf("׳˵\n"); //ӡʾ scanf_s("%d", &n); //һ printf("%d!=%d", n, fun(x)); //мĽĹеԶ庯 system("pause"); //system()ϵͳpause ͣ return 0; //˳ } int fun(int x) // { if (n ...
C
#include <stdio.h> #include <string.h> #include "mpi.h" int main( int argc, char *argv[]) { char message[20]; int myrank, size; MPI_Status status; MPI_Init( &argc, &argv ); MPI_Comm_rank( MPI_COMM_WORLD, &myrank ); MPI_Comm_size( MPI_COMM_WORLD, &size ); if (myrank == 0) /* code for ...
C
#include "hash_tables.h" /** * hash_table_set - This function adds an element to the hash table * @ht: A pointer to the hash table * @key: The key to add to the hash table * @value: The corresponding value to add to the hash table * Return: 1 for success, 0 otherwise */ int hash_table_set(hash_table_t *ht, const...
C
/* * matrix.c * * Created on: 04/06/2018 * Author: ie714715 */ #include <stdlib.h> #include <stdio.h> int CrearMatriz(int **apuntador, int n, int m); int main(){ setvbuf(stderr, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0); int **m; //matriz[3][2]; int i,j; m = (int**)malloc(size...
C
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // File name : vector_rce.c // Version : V0.1 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #include "vector_table.h" #include "debug.h" void DummyHandler(void) { MSG("WARNING: Default dummy interrupt hand...
C
#include "mapview.h" #include <stdlib.h> #include <stdio.h> int main(int argc, char *argv[]) { int start_sector; int sector_count; if (argc < 4) { printf("Usage: %s [dev] [src_lsn] [# of sectors]\n", argv[0]); return 1; } if (0 != init_mapview(argv[1], 4096)) { printf("Can ...
C
#include "3-calc.h" /** * main - Performs operation corresponding to math oeprator * @argc: Number of args * @argv: Strings of args * Return: Result of proper operation, or exit if fail */ int main(int argc, char **argv) { int (*operator)(int, int); if (argc != 4) { printf("Error\n"); exit(98); } operator =...
C
/******************************************************************************* * FILENAME : modules/visual.h * * DESCRIPTION : * Module that contain all of the visual functions. * * NOTES : * - * * */ /** * Exibe o titulo do sistema. * * @return não retorna valores * @author ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "fonctions.h" int main() { char caractere = NULL; char* motSecret = "MARRON"; char *suiteMot = NULL; int i = 0; int nbreLettre = 5; int nbreCoupsRestants = 10; int issue = PERDANT; int longueurMot = strlen(motSecret); ...
C
#include <omp.h> #include <stdio.h> #include <unistd.h> #include <stdlib.h> // export OMP_NUM_THREADS=4 int function(int x) { static int n = 0; n = n + 1; printf("function: (%i) n=%d\n", x, n); fflush(stdout); return 2*x + n; } int function_synchronized(int x) { static int n = 0; #pragma omp ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* libft.h :+: :+: :+: ...
C
#include <stdio.h> #define SQ_1(y) (y)*(y) #define SQ_2(y) y*y int main() { int a = 0,num_1 = 0,num_2 = 0; scanf("%d",&a); num_1 = SQ_1(a+1); //num_1 = (a+1)*(a+1); num_2 = SQ_2(a+1); //num_2 = a+1*a+1; printf("num_1 = %d\n",num_1); printf("num_2 = %d\n",num_2); return 0; }
C
#include <stdio.h> void quick_sort(int[],int,int); int partition(int[],int,int); int main() { int a[30],n,i; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a[i]); } quick_sort(a,0,n-1); printf("\nArray after sorting:"); for(i=0;i<n;i++) { printf("%d ",a[i]); } printf("\nMax number:%d\n",a[n-1]); pri...
C
// Harvard CS50 // vinegere.c #include <cs50.h> #include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> int main(int argc, string argv[]) { if(argc !=2) { printf("Invalid entry, try again\n"); // print error for more than 2 entries return 1; } else // c...
C
#include <vector> #include "TF1.h" #include "TFile.h" #include "TGraph.h" #include "TH1D.h" #include "TString.h" #include "Math/Interpolator.h" class MyFunctionObject { public: std::vector<double> X; std::vector<double> Y; TGraph* g; ROOT::Math::Interpolator* eng; // use constructor to customize your func...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> main() { float id,h,ph,pf; printf("digite um 1 para mulher ou 2 para homem\n"); scanf("%f",&id); printf("digite a altura\n"); scanf("%f",&h); if(id==2) { ph=(72.7*h)-58; printf("peso masculino:%.2f \n",ph); } else { pf=(62.1*h)-44.7; printf("peso feminino:%.2f\n"...