language large_stringclasses 1
value | text stringlengths 9 2.95M |
|---|---|
C | /**
******************************************************************************
* @file main.c
* @author Ac6
* @version V1.0
* @date 01-December-2013
* @brief Default main function.
******************************************************************************
*/
#define IS_BUT1_PUSH (GPIO_Rea... |
C | /**
* Checks that `idx_type` will correctly identify a structure containing a
* single double.
*/
#include "idx.h"
#include "idx_test.h"
int main(void) {
const uint8_t data[] = {
0x00, 0x00, 0x0e, 0x00,
0x40, 0x09, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18,
};
idx_assert(idx_type(data) == IDX... |
C | #include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <sys/types.h>
#include <semaphore.h>
#include <stdbool.h>
#include <time.h>
#include <unistd.h>
#include "thread.h"
int main(void)
{
pthread_t cust0,cust1,cust2,chef;
sem_init (&kitchen, 0, 1);
printf("Customer 0 has infinite Hamburger... |
C | #include <stdio.h>
int main(int argc, const char *argv[])
{
int a = 0
, b = 0
, c = 0;
printf("please input two number:\n");
scanf("%d%d", &a, &b);
c = a%10 * 1000 + b%10 * 100 + b/10%10 * 10 + a/10%10 * 1;
printf("a = %d, b = %d,c = %d\n", a, b, c);
return 0;
}
|
C | #include "main.h"
/**
* leet - For printing letters into digits
*@s: Parameter used
*
*Return: Value of s
*/
char *leet(char *s)
{
int i;
char a[5] = {'A', 'E', 'O', 'T', 'L'};
char b[5] = {'4', '3', '0', '7', '1'};
int c;
for (i = 0; s[i] != '\0'; i++)
{
for (c = 0; c < 5; c++)
{
if (s[i] == a[c] ||... |
C | /*
You are given a non-negative number less than or equal to 100000000 (1
followed by 8 zeroes). You have to divide the number into the
following components, and print them in the following order.
1. The part of the number which is less than a thousand.
2. The part of the number which is between a thousand and a lakh
... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_move_ant.c :+: :+: :+: ... |
C | #include <stdio.h>
int main(){
int a, b, c;
scanf(" %d %d %d", &a, &b, &c);
if(a+b<c || a+c<b || b+c<a){
printf("Isso não é um triângulo!");
}else if(a==b && b==c){
printf("Equilatero");
}else if(a!=b && b!=c && a!=c){
printf("Escaleno");
}else if((a==b)!=c ||... |
C | // Key.c
// This software configures the off-board piano keys
// Lab 6 requires a minimum of 3 keys, but you could have more
// Runs on TM4C123
// Program written by: Anuj Jain and George Koussa
// Date Created: 3/6/17
// Last Modified: 3/22/21
// Lab number: 6
// Hardware connections
// PE4-PE0 : piano keys
// Cod... |
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 | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_sqrt.c :+: :+: :+: ... |
C | #include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
pthread_key_t key;
void *tid1_func(void *arg)
{
int i=10;
printf("set key:%d in tid1\n",i);
pthread_setspecific(key,&i);
sleep(2);
printf("in tid1,after tid2 ends,key:%d\n",*(int *)pthread_getspecific(key));
}
void *t... |
C | #include "image.h"
#include <math.h>
#include <stdlib.h>
main(int ac,char *av[])
{
ImageData *img,*outimg;
int res;
double ang,dis;
int x,y,mx,my;
if(ac<3) {
printf("p[^܂");
return;
}
// t@C摜f[^̓ǂݍ
res=readBMPfile(av[1],&img);
if(res<0) {
printf("摜ǂ߂܂");
return;
}
hough(img... |
C | #include "main.h"
int main(int argc, char **argv) {
/*
long long unsigned int N = 10;
array * workingArray = createArray(12, N);
readFile("chicago.txt", workingArray, N*10);
displayArray(workingArray);
*/
menu(initialization());
return 0;
}
array * initialization() {
printf("\tINIT... |
C | //
// main.c
// Linked Lists
//
// Created by Jacob Cho on 2014-10-08.
// Copyright (c) 2014 Jacob Cho. All rights reserved.
//
#include <stdio.h>
struct Node {
int value;
struct Node * next;
};
typedef struct Node Node;
void printNodes(Node *head);
Node * nodeSearch(int value, Node *head);
void i... |
C | /*******************************
* Date Layer
*******************************/
#include "main.h"
#include "appinfo.h"
#include "date-layer.h"
static TextLayer *s_date_layer;
void date_update(struct tm *tick_time) {
static char date_buffer[] = "MON 00";
strftime(date_buffer, sizeof("MON 00"), "%a %e", tick_time... |
C | #include <stdio.h>
#include <stdbool.h>
bool solveMaze(char** maze, const int HT, const int WD, int x, int y); // draws a path to the exit on the maze string
void printMaze(char** maze, const int HT, const int WD); // prints the maze
int main(){
char mazeStr[] =
" ##############"
"# ... |
C | #include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h> //wtf
#include <sys/param.h> //wtf
#include <dirent.h> //wtf
#include <string.h>
static void countEntries(char *dirname, int *nFiles, int *nDirs)
{
char fullpath[MAXPATHLEN];
DIR * dirp;
struct dirent * dp;
dirp = opendir(dirname);
if (dirp == NUL... |
C | #include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define BUF_SIZE 255
void error_macro(const char *error)
{
perror(error);
exit(1);
}
int main(void)
{
char *ptr =... |
C | #include "binary_trees.h"
/**
* recursive_height - height measure
* @tree: tree
* Return: height
*
*
**/
size_t recursive_height(const binary_tree_t *tree)
{
size_t x1 = 0;
size_t x2 = 0;
if (tree == NULL)
return (0);
x1 = recursive_height(tree->left);
x2 = recursive_height(tree->right);
if (x1 > x... |
C | /**@file unity_log_helper.c
* @author Austin Glaser <austin@boulderes.com>
* @brief UnityLogHelper Source
*
* @addtogroup UNITY_LOG_HELPER
* @{
*/
/* --- PRIVATE DEPENDENCIES ------------------------------------------------- */
#include "unity_log_helper.h"
#include "log.h"
#include "unity.h"
#include "u... |
C | #include<stdio.h>
#include"Arthematic.h"
typedef struct complex_t{
int real;
int imaginary;
} complex_t;
int main(){
complex_t strr;
strr.real = 1;
strr.imaginary = 1;
int num3 = sum(strr.real , strr.imaginary);
printf("sum of 2 numbers are = %d\n",num3);
int num4 = Difference(strr.real , st... |
C | /*
* File Name: Chorros_Agua
* Author: Grupo 1
* description: Sistema show de luces y agua
* el usuario ingresa un archivo txt
**/
#include<stdio.h>
#include<conio.h>
#include<string.h>
char input[200]; // Almacena la cadena de entrada
char token[5]; // Almacena la cadena que forma el smbolo de la palabra
ch... |
C | // C Programming - Project II
#include <stdio.h>
int main() {
// variable initializations
char firstName[256];
char lastName[256];
int courseNumber;
char courseTitle[] = "Introduction to Computing and Problem Solving";
int projectNumber, currentDay, currentYear;
// Input First Name
pri... |
C | //Given an array with n unique integers, produce a Reverse BST.Here,the left child is always larger and the right child is always smaller (opposite of a normal BST). Then, print the elements in prefix order (root, left child, right child).
#include <stdio.h>
#include <stdlib.h>
//defining a tree node
typedef struct N... |
C | #include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"
//testing the adventurer card
int main(int argc, char** argv) {
printf("/*********************** Testing Adventurer Card **************************/\n");
//declare variables
str... |
C | /*
* Universidad Simón Bolívar
* Departamento de Computación y Tecnología de la Información
* CI-3825 -- Sistemas Operativos I
* Prof.: Yudith Cardinale
* Proyecto 2: Comunicación entre procesos
* Grupo 26
* Autores: Victor De Ponte, 05-38087
* Isaac Lopez, 07-41120
*
* Archivo: almacenamiento.h
* Desc... |
C | #include "./Lib/Grafo.h"
const int print_ele = 0;
void create_graph(int number_componentes, int per_connectivity, int number_vertices, Graph *graph){
per_connectivity = per_connectivity%101;
int newVert = (per_connectivity * (number_vertices - 1))/100;
if(newVert < 1)
return;
graph->number_vertices = number_ver... |
C | /*
* pFS API
*
* Copyright (C) 2008 Stanislas Polu <spolu@stanford.edu>.
* All Rights Reserved.
*/
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/errno.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <time.h>
#include... |
C | #include <stdio.h>
#include "my_list.h"
list_t *my_params_in_list(int argc, char **argv);
int main(int nb_args, char** args)
{
list_t *params = NULL;
params = my_params_in_list(nb_args, args);
if (params != NULL) {
do {
printf("%s \n", ((char *)params->data));
params = par... |
C | int findMiddleIndex(int *nums, int numsSize) {
if (numsSize == 1)
return 0;
for (int i = 0; i < numsSize; i++) {
int sum_left = 0;
int sum_right = 0;
if (i == 0) {
for (int j = 1; j < numsSize; j++)
sum_right += nums[j];
}
else if (i ==... |
C | #include"stdio.h"
void RightShift( int arr[],int N, int k)
{
while(k--)
{
char t = arr[N-1];
for(int i = N-1; i > 0; i--)
arr[i] = arr[i-1];
arr[0] = t;
}
for(int i=0;i<N-1;i++)
{ printf("%d ",arr[i]);
}
printf("%d",arr[N-1]);
}
int main()
{
i... |
C | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
// Deifning macro Q_MONTHS to be valued as 12
#define Q_MONTHS 12
// Creating a new type boolean_t to work with boolean values true and false
typedef enum{
false, true
}boolean_t;
// Creating a pointer to function type __function_compare__, that receies two... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* print_list_sort_a.c :+: :+: :+: ... |
C | /*
ITS240-01
Lab 01
Ch3p119pe3
01/18/2017
Daniel Kuckuck
Heron's formula is based on a triangle with sides a, b, and c: area = sqrt(s*(s-a)*(s-b)*(s-c)), where s=(a+b+c)/2.
Using Heron’s formula, make a program that calculates and displays the area of a trianlge having sides of 3, 4, and 5.
*/
#include... |
C | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <CL/cl.h>
#include "simple.h"
#define DATA_SIZE 1024
const char *KernelSource = "\n"
// FILL IN HERE!
"\n";
struct timespec start, stop;
void printTimeElapsed( char *text)
{
double elapsed = (stop.tv_sec -start.tv_sec)*1000.0
... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <zmq.h>
// Receive 0MQ string from socket and convert into C string
// Caller must free returned string. Returns NULL if the context
// is being terminated.
char * s_recv (void *socket)
{
char buffer [256];
int size = zmq_recv (socket, buffer... |
C | #include <linux/kernel.h>
#include <linux/module.h>
struct met_api_tbl {
int (*met_tag_start) (unsigned int class_id, const char *name);
int (*met_tag_end) (unsigned int class_id, const char *name);
int (*met_tag_oneshot) (unsigned int class_id, const char *name, unsigned int value);
int (*met_tag_dump) (unsigned... |
C | /*************************************************************************
> File Name: 0707打印月份.c
> Author:
> Mail:
> Created Time: 2017年05月20日 星期六 13时06分56秒
************************************************************************/
//打入月份号,输出该月的英文月名
//例如输入“3”,则输出“March”
#include<stdio.h>
int main()
{
char ... |
C | /**
*project:父子进程给共享内存区的一个计数器加1
*author:Xigang Wang
*email:wangxigang2014@gmail.com
*/
#include "unpipc.h"
#define SEM_NAME "mysem"
int main(int argc, char *argv[])
{
int fd, i, nloop, zero = 0;
int *ptr;
sem_t *mutex;
if(argc != 3)
err_quit("usage: incr2 <pathname> <#loops>");
fd = Open(argv... |
C | #include "graphics.h"
#include <SDL2/SDL.h>
#include <stdbool.h>
int mainLoop();
int initSDL();
int main(int argc, char *argv[])
{
initSDL();
mainLoop();
return 0;
}
int initSDL()
{
int status = SDL_Init(SDL_INIT_VIDEO);
return status;
}
int mainLoop()
{
// set up render
RenderTarget t... |
C | #define M61_DISABLE 1
#include "m61.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <inttypes.h>
// Constant for heavy hitters size
#define HEAVY_HITTERS_MAX_SIZE 6
struct m61_metadata {
unsigned long long size; // number of bytes in allocation
unsigned long long active_code;... |
C | #include <stdio.h>
int factorial(int n)
{
printf("Entra a la función factorial, n vale: %i\n", n);
if (n > 1)
{
printf("La función se llamara a si misma otra vez \n");
return n * factorial(n - 1);
}
else
{
printf("n es igual a 1, termina la recursividad\n");
retur... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* global_utils.c :+: :+: :+: ... |
C | //UDP Server
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<sys/socket.h>
#include<sys/types.h>
#include<error.h>
#include<netinet/in.h>
#include<unistd.h>
#include<arpa/inet.h>
#define PORT 7899
#define MAX_DATA 1024
void showError(const char* msg){
printf("Error: %s\n",msg);
exit(0);
}
void rev... |
C | #include <stdio.h>
void playground() {
static int x = 0;
x = x + 1;
printf("x = %i\n",x);
}
int main() {
playground();
playground();
playground();
printf("x = %i\n",x);
}
|
C | /*
* Group 08
* Shubham Lather 2016A7PS0006P
* Devyash Parihar 2016A7PS0066P
* Rahul Khandelwal 2016A7PS0128P
* Aniruddha Karve 2016A7PS0042P
*/
# include "parserDef.h"
#include "utils.h"
# include <stdlib.h>
# include <stdio.h>
void nodeCount(parseTree root,int* ans)
{
if(!root)
return ;
*ans=*ans+root-... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "utils.h"
#include "parser.h"
#define strdup _strdup
static word_t* word_t_copy(word_t* word)
{
word_t* new_word;
if (word == NULL)
return NULL;
new_word = calloc(sizeof(word_t), 1);
if (word->string)
new_word->string = s... |
C | #include "game.h"
bool gameTurn(User *start, User *other, int boardSize) {
system("clear");
char ch_x, ch_y;
int x, y = 0;
bool shotCan = false;
void *structureOther = USERSTRUCTURE(other);
bool gamePlayed = false;
printUsers(start, other, boardSize);
printBothBoard(start, other, boardSize);
... |
C | #include "cislo.h"
Cislo* VytvorCislo(void)
{
Cislo* pCislo = NULL;
pCislo = (Cislo*) malloc(sizeof(Cislo));
(*pCislo).mantisa = VytvorGumu(10);
VlozDoGumy((&(*pCislo).mantisa), 0, '0');
(*pCislo).exponent = VytvorGumu(10);
VlozDoGumy(&((*pCislo).exponent), 0, '0');
(*pCislo).znamenkoMan = '+';
(*... |
C | #include "stdio.h"
#include "stdlib.h"
#include "stdbool.h"
#include "windows.h"
void menu();
void print();
void ArrayInput();
void randArray();
void BubbleSort();
void InsertionSort();
void MergeSort();
void Merge();
void QuickSort();
void ShakerSort();
void main()
{
int t = 1, n = 0;
bool wasInput = false;
... |
C | #include<stdio.h>
#include<windows.h>
void gotoxy(int x, int y)
{
COORD Cur;
Cur.X = x;
Cur.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), Cur);
}
char answer;
void loby() //κ
{
int temp;
gotoxy(30,17);
printf("-------------------------------------------------... |
C | #include <stdio.h>
void towers(int num, char frompeg, char topeg, char auxpeg)
{
if (num == 1)
{
printf("\n Move disk 1 from peg %c to peg %c", frompeg, topeg);
return;
}
towers(num - 1, frompeg, auxpeg, topeg);
printf("\n Move disk %d from peg %c to peg %c", num, frompeg, topeg);
... |
C | #include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "tme3.h"
#define STACK_INIT_COUNT 32
#define TRUE 1
#define FALSE 0
#ifdef DEBUG
#define debug(i) fprintf(stderr, "%s\n", i);
#else
#define debug(i) ;
#endif
stack * make_stack(){
debug("make stack");
stack * res = malloc(sizeof(stack));
res->no... |
C | /* 51.
Scrivere un programma che carichi una matrice bidimensionale di caratteri e successivamente ricerchi al suo
interno un valore passato in ingresso dall’utente. Il programma restituisce quindi il numero di linea e di colonna relativo
all’elemento cercato se questo è presente nella matrice, il messaggio... |
C |
int main()
{
int i,j,k,m,n,sum=0;
int a[20][20],b[20];
for(i=0;;i++)
{
for(j=0;;j++)
{
scanf("%d",&a[i][j]);
if(a[i][j]==-1)
{
m=i;
break;
}
if(a[i][j]==0)
{
b[i]=j;
break;
}
}
if(a[i][j]==-1)
{
break;
}
}
for(i... |
C | #include <stdlib.h>
#include <stdio.h>
#include "Node.h"
#include "List.h"
int main()
{
Node *head = initializeList();
int answer;
int number;
do {
printf("1) Add back to list\n");
printf("2) Change min and max elements\n");
printf("3) Remove element with specified value\n");
printf("4) Sort\n");
printf(... |
C | #include <stdio.h>
#include <string.h>
int main(void)
{
char buf[] = "asdf@gccfree@spelld";
char *p = strtok(buf, "@");
while(p)
{
printf("%s\n", p);
p = strtok(NULL, "@");
}
return(0);
}
|
C | /*
* spi.c
*
* Created: 12/22/2011 9:44:15 AM
* Author: Administrator
*/
#include "spi.h"
void spi_init()
{
// Initial the AVR ATMega328 SPI Peripheral
// Set MOSI (PORTB3),SCK (PORTB5) and PORTB2 (SS) as output, others as input
SPI_DDR = (1<<PORTB3)|(1<<PORTB5)|(1<<PORTB2);
// CS pin is not active
SPI_PO... |
C | #include<stdio.h>
#define max 30
//typedef const int cint;
int main(){
int arr[max]={1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30};
int *ptr[max];
int i,j,*tmp;
for(i=0;i<max;i++){
ptr[i] = &arr[i];
}
for(i=0;i<max;i++){
for(j=i;j<max;j++){
if( *ptr[i] > *ptr[j]){
... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lesderniersserontlespremiers.c :+: :+: :+: ... |
C | #include<stdio.h>
void main()
{
int a[20],min,max,i,n;
printf("\nHow many elements:");
scanf("%d",&n);
printf("\nEnter array elements:");
for(i=0; i<n; i++)
{
scanf("%d",&a[i]);
}
max=a[0]; //0th index element will get stored in max variable
min=a[0]; //0th index element will get sto... |
C | /*************************************************
* Deitel - C Programming
* Chapter 3 -- Exercise 3.33
* "Hollow Square of Asterisks"
*************************************************/
/*
-------------------------------------------------------------------------------
:: Program Description ::
--------------... |
C | #include <stdio.h>
void slownie(int kwota){
printf("%d= ",kwota);
if(kwota>=1000){
int szescset = kwota /1000;
printf(" tysiąc");
kwota -= szescset *1000;
}
if(kwota>=900){
int szescset = kwota /900;
printf(" dziewięćset");
kwota -= szescset *900;
}
... |
C | /* hmm_adjustb.c -- ECOZ System
*/
#include "utl.h"
#include "hmm.h"
#include <math.h>
#include <stdlib.h>
#include <assert.h>
// to verify stochastic requirement
//#define VERIFY
prob_t hmm_epsilon = 1.e-5;
void hmm_adjust_B_epsilon(Hmm *hmm, const char* logMsg) {
if (hmm_epsilon <= (prob_t) 0.) {
ret... |
C | #include "client.h"
#include <unistd.h>
#include <string.h>
#include <malloc.h>
int main(int argc,char **argv) {
//variables we need
char *config = NULL, op;
ns_t *nameserver;
cmd_t *command;
char output[BUFFER];
//command line arguments
while( (op = getopt(argc,argv,"f:")) != -1) {
switch(op) {
... |
C | #include <cs50.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
int main(int argc, string argv[2])
{
//check for argument count
if (argc != 2)
{
printf("Usage: ./vigenere k\n");
return 1;
}
//this is a little redundant but works to check for letter... |
C | #define NO_FREE_FRAME -1
#define ERR_INVALID_PAGE -2
// Definition for a page table entry. Each hold a frame number, a count for LRU, and a an int (used like a bool) for
// validity.
typedef struct pte {
unsigned long frame;
unsigned long count;
int valid;
} pte_t;
// Functions defined in pagetable.c
// ... |
C | #include<stdio.h>
#include<string.h>
void swap(char a[],int i,int j)
{
char temp = a[i];
a[i] = a[j];
a[j] = temp;
}
void permute(char a[], int l, int r)
{
if(l==r)
{
printf("\n%s",a);
}
else
{
for(int i=l;i<=r;i++)
{
swap(a,i,l);
permute... |
C | /*
*
*from 《数据结构》
*循环队列,顺序存储结构
* */
#include <stdio.h>
#include <stdlib.h>
// 预定义常量和类型
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define OVERFLOW -2
typedef int Status;
typedef int QElemType;
// 循环队列,队列的顺序存储结构
#define MAXQSIZE 100 // 最大队列长度
typedef struct{
QElemType *base; ... |
C | /*
* C - Basics
* Fibonacci series up to a given number of elements
* (fibonacci_recursive.c) v20190727
*
* Gonzsou
*
*/
#include <stdio.h>
#include <stdlib.h>
void fib(int *previous, int *current, int n ){
/*swaps value stored on 'previous' by value stored in 'current', and calculates... |
C | /*
* Standard Dependable Vehicle Operating System
*
* Copyright (C) 2015 Ye Li (liye@sdvos.org)
*
* 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 3 of
* the Licens... |
C | #include <stdio.h>
#define IN 0
#define OUT 1
int main() {
int input, nl, nw, nc, state;
state = OUT;
nl = nw = nc = 0;
while (EOF != (input = getchar())) {
if ('\n' == input) {
++nl;
state = OUT;
} else if (' ' == input || '\t' == input) {
state = ... |
C | #include <stdio.h>
#include <stdlib.h>
int main() {
long nit, it, in;
double pi, x, y;
fprintf(stderr, "Please eneter number of MC steps = ");
scanf("%ld", &nit);
in = 0;
for (it = 0; it < nit; it++) {
x = (double)random()/RAND_MAX;
y = (double)random()/RAND_MAX;
if (x*x + y*y <= 1.0f) {
... |
C | #include <stdio.h>
int main() {
int v[10],i,n;
scanf("%d", &n);
v[0] = n;
for(i=0; i<10; i++) {
printf("N[%d] = %d\n",i,v[i]);
v[i+1] = v[i]*2;
}
}
|
C | #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "struct_file.h"
int load_from_file(struct Chest *chest, char *file_name);
int main(int arc, char **argv)
{
printf("Enter name of file to load Chest struct from.\n");
char file_name[256];
scanf("%s", file_name);
... |
C | #include"process.h"
#include"init.h"
#include"draw.h"
/*------生成地雷-------*/
void produceBom()
{
srand((unsigned)time(0)); //生成随机因子
int i,j,k;
for(k=0;k<iBoom_Num;k++)
{
i = rand() % iHigh;
j= rand() % iWidth ;
if(Mine[i][j].iBoom==1) ... |
C | #include<stdio.h>
#include<stdlib.h>
int c(const void *a, const void *b){
if(*(long long int*)a - *(long long int*)b > 0) return 1;
else if(*(long long int*)a - *(long long int*)b < 0) return -1;
else return 0;
}
int main(){
int N, M;
scanf("%d %d", &N, &M);
long long int a[N];
int i;
long A, B;
... |
C | /*
* Exercise_1-10.c
*
* Created on: 28 Jan 2021
* Author: Al
*/
#include <stdio.h>
typedef unsigned char bool;
#define TRUE (bool)1u
#define FALSE (bool)0u
int main()
{
int c;
for ( c = getchar(); c != EOF; c = getchar() ) {
bool flag = 0;
if ( c == '\t' ) {
flag = 1;
(void)putchar('\\');
... |
C | #include "holberton.h"
#include <stdio.h>
/**
*binary_to_uint - converts a binary number to an unsigned int
*@b: poiter to a string
*Return: conv
**/
unsigned int binary_to_uint(const char *b)
{
unsigned int conv = 0;
int cont = 0, pow;
if (b == NULL)
{
return (0);
}
while (b[cont + 1] != '\0')
cont++;
... |
C | #include <stdio.h>
#include "list.h"
struct list
{
int info;
struct list *next;
};
/* init */
List *lst_init(void)
{
return NULL;
}
/* insert */
List *lst_insert(List *l, int i)
{
List *new = (List *)malloc(sizeof(List));
new->info = i;
new->next = l;
return new;
}
/* print */
void lst... |
C | //
// LCBChapterSevenMachineExperimentOne.c
// DataStructurePractice
//
// Created by ly on 2018/6/18.
// Copyright © 2018年 LY. All rights reserved.
//
#include "LCBChapterSevenMachineExperimentOne.h"
int breadthOfBinaryTree(BinaryTree *tree) {
BinaryTreeCSqQueue *queue = initBinaryTreeCSqQueue() ;
int la... |
C | #include<stdio.h>
#include<ctype.h>
void main()
{
char a[10];
int flag,i=1;
printf("\nEnter an Identifier");
scanf("%s",a);
if(isalpha(a[0]) || a[0]=='_')
flag=1;
else
{
flag=0;
}
while(a[i]!='\0')
{
if(!isdigit(a[i])&&!isalpha(a[i])&&a[i]!='_')
{
flag=0;
break;
}
i++;
}
if(flag==1)
printf("\nValid Identifier\n");
else... |
C | /*********************************
* Class: MAGSHIMIM C2 *
* openCV template *
**********************************/
#include <stdio.h>
#include <opencv2\highgui\highgui_c.h>
int main(void)
{
int i;
cvNamedWindow("Display window", CV_WINDOW_AUTOSIZE); //create a window
//create an image
IplImage* image ... |
C | #include "addauthor.h"
void checkArgs(int argc)
{
if (argc == 1)
{
printf("Error: Please provide a author and a stream\n");
printf("</body>\n");
printf("</html>");
exit(1);
}
}
void getStreams(char * streams)
{
printf("list streams: ");
fgets(streams, 100, stdin);
... |
C | #include<stdio.h>
int main()
{
int t;
scanf("%d", &t);
getchar();
while(t--) {
int n, i, x = 0;
scanf("%d", &n);
int move[n+1];
getchar();
char ins[20];
for(i=0; i<n; i++) {
fgets(ins, 20, stdin);
if(ins[0]==... |
C | #include<stdio.h>
#include<assert.h>
float calculateSeries(int);
int fact(int);
void main()
{
int n;
float res;
printf("Enter N value for the series: ");
scanf("%d",&n);
res = calculateSeries(n);
printf("\nSeries sum is : %f\n\n\n", res);
assert(calculateSeries(1) == 1.000000);
assert(calculateSeries(2) == ... |
C | #include<stdio.h>
#include<stdlib.h>
int main(){
char name[7][20],temp[20];
int i,j;
for(i=0;i<7;i++){
printf("\nPlease enter name %d: ", i+1);
scanf("%s",&name[i]);
}
for(i=1;i<7;i++){
for(j=1;j<7;j++){
if(strcmp(name[j-1],name[j]) > 0){
strcpy(temp,name[j-1]);
strcpy(name[j-1],name[j]);
strc... |
C | #include <stdio.h>
#include <stdlib.h>
#include "way_finder.h"
/*
// List to take first
*/
typedef struct list list;
struct list {
list *next;
char c;
};
genom * take_first_solution(int max_size) {
list *l = NULL;
list *tail = NULL;
char c = (char)fgetc(stdin);
int size = 0;
while (c != ... |
C | // INT STACK (HEADER FILE)
#include <stdbool.h>
#define MAX_SIZE 100
struct Stack{
int stk[MAX_SIZE];
int size;
int top;
};
typedef struct Stack Stack;
// Create Stack
Stack* createStack(int size){
Stack* stack = (Stack *)malloc(sizeof(Stack));
stack->size = size;
stack->top = -1;
return stack;... |
C | /*
* Test program for color_conversion library
*
* Author: Dennis Koslowski <dennis.koslowski@gmx.de>
* Date: 2020-01-14
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "color_conversion.h"
/*
* Get the first character from stdin
*/
static char get_char() {
char ch = 0;
const si... |
C | // client.c - Example of TCP/IP Client using sockets
// COEN 4840
// 05-Feb-2020 - terminate client on message “exit” from server
// 15-Apr-2023 - terminate client after receiving any message from server
//
// See: https://www.geeksforgeeks.org/tcp-server-client-implementation-in-c/
//... |
C | /*
** Silberschatz Figure 3.27, modified 9/2010 by MCM to implement a simple pipe read process
** Compile/execute using the Windows Command Line C Compiler (cl)
**
*/
#include <stdio.h>
#include <windows.h>
#define BUFFER_SIZE 25
int main(VOID)
{
HANDLE ReadHandle,WriteHandle;
CHAR buffer[BUFFER_SIZE];
DWORD rea... |
C | #include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
/* lib */
#include <avl.h>
#include <debug.h>
#include <timer.h>
#define ULONG_MAX (~0UL)
static void
avl_dump(avl_node *n, FILE *fp)
{
if (n) {
if (n->link[0])
fprintf(fp, "\t%ld -> %ld\n... |
C | #ifndef __SPACE_H__
#define __SPACE_H__
#include "gf2d_shape.h"
#include "gf2d_body.h"
typedef struct
{
List *dynamicBodyList; /**<list of bodies in the space*/
List *staticShapes; /**<list of shapes that will collide that do not move*/
int precision; /**<number of backoff... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* errors.c :+: :+: :+: ... |
C | /*
* json_tools.c
*
* Created on: Oct 19, 2018
* Author: zzz
*/
#include "cJSON.h"
#include "libov/ov_macros.h"
#include "libov/ov_ov.h"
#include "string.h"
#include "ovunity_helper.h"
OV_DLLFNCEXPORT cJSON* cJSON_ParseFromFile(OV_STRING path) {
OV_STRING jsonStr = ovunity_helper_data2str(path);
cJSON... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* tools.c :+: :+: :+: ... |
C | /* #include
*
* L.ECC - FEUP / PRO - L.EEC004
*
* Exemplo da utilização de apontadores com registos
*
* Compilar: clang ponto.c -o ponto
* Executar: ./ponto
*/
#include <stdio.h>
typedef struct {
float x, y;
} ponto;
void lerPonto( ponto *p);
void escreverPonto( ponto p);
main(){
ponto p;
while (1){... |
C | #include "stm32f4xx.h"
static uint32_t fam_nus = 0;
static uint32_t fam_nms = 0;
/*******************************
ܣʱʼ
ֵ
*******************************/
void Delay_Init(void)
{
//رռʱжϡʱΪAHB/8
SysTick->CTRL = 0x0;
fam_nus = SystemCoreClock/8000000;
fam_nms = fam_nus * 1000;
SysTick->VAL = 0;
}... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.