language large_stringclasses 1
value | text stringlengths 9 2.95M |
|---|---|
C | #ifndef DEF_UNIV_TYPE_OPS
#define DEF_UNIV_TYPE_OPS
// UnivType operations
#include "UnivType.h"
// C++ operator overload
UnivType operator+(const UnivType& x, const UnivType& y);
UnivType operator-(const UnivType& x, const UnivType& y);
UnivType operator*(const UnivType& x, const UnivType& y);
UnivType operator/(c... |
C | #include "my_malloc.h"
/* You *MUST* use this macro when calling my_sbrk to allocate the
* appropriate size. Failure to do so may result in an incorrect
* grading!
*/
#define SBRK_SIZE 2048
/* Please use this value as your canary! */
#define CANARY 0x2110CAFE
/* If you want to use debugging printouts, it is HIGHL... |
C | #include<stdio.h>
struct vivek
{
int n1;
int n2;
int ans;
};
int main()
{
int t,i;
printf("enter the total test cases:\n");
scanf("%d",&t);
struct vivek a[t];
for(i=0;i<t;i++)
{
scanf("%d %d",&a[i].n1,&a[i].n2);
a[i].ans=a[i].n1+a[i].n2;
}
printf("\n\n");
... |
C | #include<stdio.h>
int parent(int i);
int left(int i);
int right(int i);
void max_heapify(int A[],int i, int n);//maintain max heap property => parentvalue > childvalue
void build_max_heap(int A[],int n);
void heapsort(int A[],int n);
int main(void){
int i;
int A[10] = {4, 1, 3, 2, 16, 9, 10, 14, 8, 7 };
for(i = 0... |
C | #include <sys/mman.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/types.h>
#define SC_LENGTH 1024*1024
int debug_enabled = 0;
void debug(char *fmt, ...) {
va_list ap;
if (!debug_enable... |
C | /**
* @file main.c
* @author Shreya Chakraborty
* @brief Main task which spawns the other threads
* @version 0.1
* @date 2019-03-16
*
* @copyright Copyright (c) 2019
*
*/
#include "includes.h"
#include "main.h"
#include "logger.h"
#include "temp.h"
#include "socket.h"
#include "light.h"
#include "bist.h"
#i... |
C | /*
* udptunnel : Lightweight TCP over UDP Tunneling
*
* Copyright (C) 2014 Jingyu jingyu.niu@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... |
C | /**
Read Stata version 6.0 and 5.0 .dta files, write version 6.0.
(c) 1999, 2000 Thomas Lumley.
The format of Stata files is documented under 'file formats'
in the Stata manual.
This code currently does not make use of the print format or value
label information in a .dta file. It cannot handle file... |
C | /*
Filename: heapSort.c
Author: Tony Zeng
Mail: laoweiyeah@gmail.com
Function: implement of heap sorting algorithm
Time: 2013-6-23 22:57:54
*/
#include <stdio.h>
#include "array.h"
void heapSort(int* array, int count)
{
int temp;
for (int j = count - 1; j > 0; --j)
{
for (int i = j; i > 0; --i)
{
if (ar... |
C | /*Botworx VR - A Virtual Reality Framework
Copyright (C) 2005 Kurtis Fields. See BotworxVR_License.txt for details.
*/
#ifndef _BwMath_H
#define _BwMath_H
//namespace bwmath {
inline bwDegree makeDegree(const bwRadian& r) {
return (r * bwReal(180.0f)) / bwRealTraits::Pi ;
}
inline bwRadian makeRadian(con... |
C | #include<stdio.h>
int main()
{
float sp,pr,tcp,cp;
printf("enter the selling price of 15 item - " );
scanf("%f",&sp);
printf("enter the profit - ");
scanf("%f",&pr);
tcp=sp-pr;
cp=tcp/15;
printf("Cost price of each item = %05.000f\n",cp);
return 0;
}
|
C | #include <stdio.h>
#include <stdlib.h>
// gcc -DFLAG_1 -DFLAG_2 -E test.c > test_E.c
// All FLAG wil be compiler
// gcc -DFLAG_1=0 -DFLAG_2=0 -E test.c > test_E.c
// FLAG_2 still be compiler....
// gcc -E test.c > test_E.c
// FLAG_3 can compiler sucess even if we don't add -DFLAG_3
// FLAG_3 can compiler sucess
... |
C | #include "flash.h"
#include "debug_usart.h"
uint8_t CopyMemory( uint32_t src_addr
, uint32_t dst_addr
, size_t size
)
{
HAL_FLASH_Unlock();
for( size_t written = 0; written < size; written += 4 ){
// erase sector if we just reached one
for( int32_t i=0; i <... |
C | #include <stdio.h>
#include <stdlib.h>
/*Recursividad: Es una funcion que se llama a si misma
1. Caso Base
2. Caso Recursiva
*/
long factorial(int n);
int main()
{
int numero;
printf("Ingrese un numero: ");
scanf("%d", &numero);
printf("\nEl factorial es: %d\n", factorial(numero));
return 0;
}
long... |
C | #include<stdio.h>
#include<conio.h>
#define MAX 10 // Changing this value will change length of array
int kuyruk[MAX];
int on = -1, son = -1;
void ekle(void);
int delete_element(void);
int peek(void);
void display(void);
void TersCevir(void);
int val;
int main()
{
int option, val;
do
{
printf("\n\n ***** Ana MENU *****... |
C | #include <stdio.h>
void info() { //easier way than repeatedly typing the info in different places.
printf("*************COMMANDS*************\n"); //yes it could be done in one line, it's easier on the eyes to format this way.
printf("d NUMBER deletes the given number from the list of numbers\n"); //The delete f... |
C | #include <stdio.h>
void *SumarConPunteros(int *a);//declaro funcion como puntero
int main(){
int a =1;
int b =0;
int *p, *x;
p=&a;
printf("Muestro p=&a : %d\n",*p);
b=*p+10;
printf("Muestro b=*p+10 : %d\n", b);
*p=*p+1;
printf("Muestro *p=*p+1: %d\n",*p);
a=Suma... |
C | //
// Created by liushan on 18-7-25.
//
#include <stdio.h>
#include <sys/utsname.h>
#include <unistd.h>
void myuname(void)
{
struct utsname name_ptr;
char name[64];
uname(&name_ptr);
gethostname(name, 64);
printf("%s %s %s %s %s\n",
name_ptr.sysname, name_ptr.nodename, na... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* type_dec.c :+: :+: :+: ... |
C | #include <unistd.h>
int is_in_list(char printed[127], int nb_printed, char c)
{
int i;
i = 0;
while (i <= nb_printed)
{
if (c == printed[i])
return (1);
i++;
}
return (0);
}
void inter(char *first, char *second)
{
char printed[127];
int i;
int j;
int nb_printed;
nb_printed = 0;
i = 0;
while... |
C | #include <stdio.h>
#include "lk_debug.h"
#include "1.5.2_keyword_sizeof.h"
//int b[2][3];
static void sizeof_func(int b[2][3])
{
int **p = NULL;
lk_print("=== int **p = NULL;\n");
p = (void *)&b;
lk_print("sizeof(**b):%ld, **b:%d\n", sizeof(**b), **b /**(*(b + 1) + 2)*/); /* **b: b[0], int type is 4 Bytes. */
... |
C | /**
* Return an array of size *returnSize.
* Note: The returned array must be malloced, assume caller calls free().
*/
char** findRepeatedDnaSequences(char*s, int* returnSize)
{
int size = strlen(s);
if(size < 11) return NULL; //at least 11 letters;
int hashTable[1 << 20] = {0}; //allocate a hash map arr... |
C | #include<stdio.h>
int main()
{
int a[10]={1,2,3,4,5,6,7,8,9,10};
int n,m,x,i,j,q;
printf("开始位置与个数:");
scanf("%d%d",&n,&m);
i=n-1;
j=m+n-2;
do
{
x=a[i];
a[i]=a[j];
a[j]=x;
++i;
--j;
}while(i<j);
for(q=0;q<10;q++)
{
printf("%d",a[q]);
}
printf("\n");
return 0;
}
|
C | // C# program to Sort square
// of the numbers of the array
using System;
class GFG
{
// Function to sort
// an square array
public static void sortSquares(int []arr)
{
int n = arr.Length;
// First convert each array
// elements into its square
for (int i = 0 ; i < n ; i++)
arr[i] = ar... |
C | /*
* NAME: PARTHO SARTHI
* ID: 2015A7PS0088P
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "lexer.h"
#include "langDef.h"
TokenInfo setTokenValue(int state,char * name,int line){
TokenInfo token;
memset(token.name,'\0',MAX_LENGTH+1);
strcpy(token.name,name);
token.id... |
C | #include<math.h>
#include<stdio.h>
int main() {
for(double x = -3.5; x<=3.5; x+=1) {
printf("%g %g\n", x, tgamma(x));
}
return 0;
}
|
C | #include<iostream>
#include<stdio.h>
#include<algorithm>
struct point
{
int x;
int y;
};
int cmp(point a,point b)
{
if(a.x!=b.x)return a.x<b.x;
return a.y<b.y;
}
main()
{
int n,i,count;
point a[400];
while(scanf("%d",&n)!=EOF)
{
count=0;
for(i=0;i<n;i+... |
C | #include<stdio.h>
int main()
{
char a[1000];
while(gets(a)!=EOF)
{
printf("%s",a);
}
return 0;
}
|
C | #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "sequence.h"
#include "distance.h"
#include "famille.h"
LISTE * initialiser_liste()
{
LISTE * l = malloc(sizeof(LISTE*)); ... |
C | /*
* dpend_mpfr.c - Arbitrary precision solution to double pendulum ODEs
* using fourth order Runge-Kutta.
*
* Parameters are passed in at the command line:
*
* $./dpend_mpfr.c TH10 W10 TH20 W20 NSTEP
*
* TH10, TH20 - initial angles of the pendulums (degrees)
* W10, W20 - initial angular velocities of t... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <process.h>
#define NEW (struct node *)malloc(sizeof(struct node))
struct node
{
char name[100],tel[20];
struct node *next;
};
output(struct node *h)//ļֲᣩ
{
struct node *p;
p=h;
if(h==N... |
C | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <mpi.h>
#include <sys/time.h>
#include <time.h>
#define MIN 0
#define MAX 5
//Citing Sources: https://www.geeksforgeeks.org/generating-random-number-range-c/
// http://homepages.math.uic.edu/~jan/mcs572/using_mpi.pdf
// ... |
C | #include "../../src/http/http_headers.h"
#include <stdio.h>
#include "../mocks/mock_socket_connector.h"
#include <criterion/criterion.h>
Test(str2int, happy) {
char str[] = "3451";
int res = str2int(str, strlen(str));
cr_assert(3451 == res, "expected value of 3451, not:%d", res);
}
Test(str2int, empty) {... |
C |
/* ***************************************************************** */
/* */
/* */
/* ***************************************************************** */
/* The code to read a memory t... |
C | #include <stdio.h>
#include <stdlib.h>
#define USER_NUM 5128
typedef struct node_ {
int val ;
struct node_* next ;
} node ;
typedef struct queue_ {
node *front;
node *rear;
int count;
} queue ;
typedef struct mutual_ {
int user1 ;
int user2 ;
int check ;
} mutual ;
int *id_set ;
... |
C | //
// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
// file was obtained (LICENSE.txt). A copy of the license may... |
C | /* Test program for <next-at-end> and
* <leaves-core-file-on-quit> bugs.
*/
#include <stdio.h>
#include <stdlib.h>
#include "../lib/unbuffer_output.c"
int callee (int x)
{
int y = x * x; /* -break1- */
return (y - 2);
}
int main()
{
int *p;
int i;
gdb_unbuffer_output ();
p = (int *) mal... |
C | #include "pustaka.h"
// NAMA : MOCHAMAD SAIFULLAH
// NIM : A11.2018.11511
// KELP : A11.4218
int main()
{
int a1[10] = {NULL}, a2[10] = {NULL};
int a3[10] = {NULL}, a4[10] = {NULL};
a1[0]=1; a1[1]=2; a1[2]=3; a1[3]=4; a1[4]=5; a1[5]=6;
a2[0]=1; a2[1]=2; a2[2]=3; a2[3]=4;
a3[0]=2; a3[1... |
C | #include <stdio.h>
/*
Функция sscanf работает похоже на scanf, но только считывает данные
не из стандартного входа, а из строки.
С её помощью можно конвертировать числа из строки в числа
*/
int main() {
char str[20] = "5-10-1872";
int day, month, year;
// Считываем числа из строки
sscan... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_epur_str.c :+: :+: :+: ... |
C | #include <stdio.h>
#include <stdlib.h>
int main()
{
printf("\t\t1 - \tClientes\n\t\t2 - \tFornecedores\n\t\t3 - \tFaturas\n\n\t\t0 - \tSair\n ");
return 0;
}
|
C |
// Compare two strings for quick sort
static int cmpfunc(const void* a,const void* b){
const char **ia = (const char **) a;
const char **ib = (const char **) b;
return strcmp(*ia, *ib);
}
// create BWT and SA
struct SA_BWT create_bwt(char* seq){
int length = strlen(seq)+1;
char* appended_seq = ... |
C | /*** p08ex01.c ***/
/*** s12083 2J18 ܖS ***/
#include <stdio.h>
#include <math.h>
#define PAI 3.14159265358979
typedef struct{
int x;
int y;
}point_t;
point_t rotatePoint(point_t point,double theta)
{
point_t npoint;
npoint.x=point.x*cos(theta)-point.y*sin(theta);
npoint.y=point.x*sin(th... |
C | #ifndef __TYPES_H
#define __TYPES_H
#include <stddef.h>
typedef char i8;
typedef short i16;
typedef int i32;
typedef long long i64;
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned long long u64;
typedef float f32;
typedef double f64;
#endif /* end ... |
C | #include<stdio.h>
// This can help swap two elements using pointers to make code easier.
void swap_double( double *a, double *b ); //For some reason, functions needs to be mentioned here though placed at bottom.
//Sorting method for array
void sort_numeric( double *a, char input )
{
... |
C | #include <stdio.h>
int main (){
int c1, c2, c3, c4, nullvote, whitevote, cont, totalvotes, vote;
cont = 0;
totalvotes = 10;
c1 = 0;
c2 = 0;
c3 = 0;
c4 = 0;
nullvote = 0;
whitevote = 0;
while (cont < totalvotes){
printf("Vote for which candidate you want to vote:\n");
... |
C | #include <stdio.h>
int main() {
int i;
printf("SSD1331Begin\n");
SSD1331Begin();
printf("Clear\n");
SSD1331Clear(0x00);
//for(i=0; i<64; i++) SSD1331DrawPixel(i, i, 0xF800);
printf("String\n");
SSD1331String(0,0,"Hello World!", 0xF800);
printf("Display\n");
SSD1331Display();
return 0;
}
|
C | /*
cause_fear.h
*/
#include "defs.h"
/* -------- Fear ---------- */
cause_fear(str) {
object target_obj;
if (!str) {
write("You must specify who you want to frighten.\n");
write("Use: fear <who>\n");
return 1;
}
if (MY_LEVEL < 7 || MY_GUILD_EXP < 669) {
write("You can't use that abilitiy yet... |
C | #include "parser.h"
static char getsymbol() {
char c;
while (isspace(c = getchar()));
if (c == COMMENT_SYMBOL) {
while (getchar() != '\n');
return getsymbol();
}
return c;
}
static const Expr* getExprList(const Expr *vars[], int * const parenLevel) {
int currentLevel = *parenLe... |
C | #include "bsp_watch.h"
void watch_background(void)
{
TFT_INIT();
lcdFillScreen(&dev, BLACK);
lcdDrawCircle(&dev, CONFIG_WIDTH/2, CONFIG_HEIGHT/2, 100, RED);
}
void watch_pointer(void)
{
float hour_pointer = 0;
float second_pointer = 0;
float minute_pointer = 0;
while(1)
{
// * ... |
C | #include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/shm.h>
#include<sys/sem.h>
#include<errno.h>
#define Key1 1234
#define Key2 7654
#define MaxCount 50
struct shmarea{
unsigned int read;
unsigned int write;
unsigned int userCount;
int buf[50];
};
union semun{
int val;
struct semid *_buf;
str... |
C | #include<stdio.h>
#include<math.h>
int main(int argc, char *argv[]) {
int n, i, f = 0, x = 1, y = 1, l1, l2, j = 0, k = 0;
long long int a1[200000] = {0}, sum = 0,a2[200000], a;
scanf("%d", &n);
for(i = 0 ; i < n ; i++) {
scanf("%lld", &a);
if(a > 0)
a1[j++] = a;
else
a... |
C | #include <stdio.h>
int n;
char S[17];
void gen(int len, int prev)
{
if(len == n)
{
printf("%s\n", S);
return;
}
S[len] = '0';
gen(len + 1, 0);
if(prev != 1)
{
S[len] = '1';
gen(len + 1, 1);
}
}
int main()
{
int i, f1 = 1, f2 = 2;
freopen("vector... |
C | // This is good for max to be a value greater than 0
int maxVal(int num1, int num2)
{
return ((num1 < num2)?num2:num1);
}
int maxSubArray(int* nums, int numsSize)
{
int len = numsSize - 1;
int max = nums[0];
int max_end = nums[0];
int itr = 1;
while(itr <= len)
{
max_end = maxVal(n... |
C | #include <stdio.h>
#include "minunit.h"
// https://leetcode-cn.com/problems/liang-ge-lian-biao-de-di-yi-ge-gong-gong-jie-dian-lcof/
/**
* Definition for singly-linked list.
*/
struct ListNode
{
int val;
struct ListNode *next;
};
struct ListNode *getIntersectionNode(struct ListNode *headA, struct ListNode *headB... |
C | #include "linked_list.h"
t_list *list_create(void *_content)
{
t_list *new;
new = (t_list *)malloc(sizeof(t_list));
if (!new)
return (NULL);
new->content = content;
new->next = NULL;
return (new);
}
void list_add_front(t_list **_list_first, t_list *_to_add)
{
*_list_first =
}
|
C | /*
*
*
* project: hw3
* name:
* user??
* date:
* file: hw3.c
*/
#include "hw3.h"
void sorting_angle(Points points)
{
/*
* Code
*/
}
//
Points convex(Points points)
{
/*
* Code
*/
}
void write2csv(Points points, char *file)
{
FILE *f = fopen(file, "w");
TEST_FILE(f,"write2csv",file)... |
C | #define max 5
#include<stdio.h>
void display(int *,int);
int main(){
int a[max],i;
printf("enter values:");
for(i=0;i<max;i++)
scanf("%d",(a+i));
display(a,max);
return 0;
}
void display(int *b,int s){
int i;
printf("\nvalues:\n");
for(i=0;i<s;i++)
printf(" %d ",*(b+i));
}
|
C | /* *************************************************
DESCRIPTION:
Implemets of:
Swap functions:
Int by poiners.
Values by size_t pointers.
Pointers by size_t **.
Athor: Gal Dahan
***************************************************/
#include <stdlib.h> /* for size_t */
void SwapSizeT (size_t *a, size... |
C | #include <vector.h>
#include <stdio.h>
#include <stdlib.h>
#include <test.h>
static void display(struct vector_node *element)
{
switch(TYPE(element)) {
case CHAR:
printf("%c ", VALUE(element));
break;
case SHORT:
printf("%hd ", VALUE(element));
break;
case INT:
printf("%d ", VALUE(element));
brea... |
C | #include "holberton.h"
/**
* print_most_numbers - prints from 0 to 9 and a new line
*
*
* Return: 0 Success
*/
void print_most_numbers(void)
{
int n;
for (n = '0'; n <= '9'; n++)
if (n != '2' && n != '4')
_putchar (n);
_putchar('\n');
}
|
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* check_arg1.c :+: :+: :+: ... |
C | /////////////////////jLIB//////////////////////////////////////////
#define _GNU_SOURCE
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <time.h>
#include <errno.h>
#include <string.h>
/////////////////////MACROS////////////////////////////////////////
//Print error info and... |
C | #include <stdio.h>
#include <stdlib.h>
#include "hashtag.h"
#include "mergesort.h"
/* Aplica a funcao MERGE auxiliar do mergesort
Versao estavel (usa vetor auxiliar b)
INPUT : Item para ordenar, limite inferior(low), medio(mid)
e limite superior (high) */
void merge(ItemToSort a, int low, int mid, int hi... |
C | // gcc -O3 -o fib-c fib-c.c
#include <stdio.h>
int fib(int n) {
if (n <= 1) return n;
return fib(n-1)+fib(n-2);
}
int main() {
for (int x = 0; x <= 45; x++) {
printf("fib(%d)=%d\n", x, fib(x));
}
}
|
C | /*
* Faça um programa para mostrar o valor total a pagar por um produto em promoção.
* O valor básico do produto e percentual de desconto são obtidos do código do produto
* que possui 4 algarismos de acordo com a seguinte regra:
* Código do produto: xxyy
* Preço básico: XX*15,00 + YY
* Percentual de desconto: Y... |
C | /*2 – Implement a function void fill_vec(int *vec, int n)
* that, through the use of pointers,
* stores a set of 20 integers (read from the keyboard) into a vector.*/
#include <stdio.h>
#include "input_vec.h"
int main( ) {
//initialize the variables
int vector[20];
int n = 20;
//call the funtion
fill_vec(&ve... |
C | #include <stdio.h>
#include <stdlib.h>
typedef struct _list_node
{
int key;
struct _list_node *next;
}list_node;
void *list_insert(list_node *head, int key)
{
list_node *p = head;
while(p->next != NULL)
p = p->next;
list_node *node = calloc(1, sizeof(list_node));
node->key = key;
node->next = NULL;
... |
C | #include<stdio.h>
int main()
{
double n;
scanf("%lf",&n);
if(n<0||n>100)
printf("Fora de intervalo\n");
else if(0<=n&&n<=25.0)
printf("Intervalo [0,25]\n");
else if(25.0<n&&n<=50.0)
printf("Intervalo (25,50]\n");
else if(50<n&&n<=75)
printf("Intervalo (50,75]\n");
else if(75<n&&n<=100)
printf("Inter... |
C | /**
@file ficheiros.c
Funções relacionadas com ficheiros.
*/
#include "ficheiros.h"
/** Caminho para guardar o ficheiro dos utilizadores. */
#define PATH_UTILIZADORES "/var/www/html/users/"
/**Função que importa um tabuleiro do ficheiro. */
ESTADO puzzle_reader(ESTADO e, FILE *fp){
int l,c;
int i,j,m=0;
... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* instructions_update.c :+: :+: :+: ... |
C | #include "lists.h"
#include <stdlib.h>
/**
* delete_nodeint_at_index - delete a node form the list.
* @head : list
* @index : int
* Return: 1.
*/
int delete_nodeint_at_index(listint_t **head, unsigned int index)
{
unsigned int x = 0, count = 0;
listint_t *temp = *head;
listint_t *new;
if (temp == NULL)
return (-1);
... |
C | #include <stdio.h>
#include <stdlib.h>
int sacarFactoreo(int numero);
float sacarDivision(int numeroUno, int numeroDos);
int sacarProducto(int numeroUno, int numeroDos);
int sacarResta(int numeroUno, int numeroDos);
int sacarSuma(int numeroUno, int numeroDos);
int pedirMenu(char texto[]);
int main()
{
i... |
C | /******************************************************************************/
/* */
/* motord.c - motor daemon for controlling boat motors connected to the */
/* Raspberry Pi. ... |
C | #include "synth_wind.h"
double *cdf_v(double **param, double v, int i){
int j , n, prog;
double vn, *res;
n = ceil(v/DV);
res = malloc(n*sizeof(double));
vn = 0;
*res = DV*mgd_f(param, vn);
// printf(" Generating CDF for State \033[31;1m%d\033[0m\n", i);
// fflush(stdout);
for(j=1; j<=n; j++){
//print p... |
C | #include "landCellState.h"
void landCellCheckState(landCell *lc,
MPI_Request *request,
MPI_Status status,
int message[2],
MPI_Request *request1)
{
int ierr;
// Another squirrel was here
lc->populationInflux[lc->populationInfluxIndex]++;
if (message[0] == INFECTED)
//Another infected squirrel was... |
C | /*
若文件已经打开,可以用fstat获取文件信息(效率高,直接从内存获取)
如文件未打开,用stat
对于符号链接,stat和fstat可以获取符号链接指向文件的属性,而lstat获取的是
符号链接文件本身的属性
*/
# include <sys/types.h>
# include <sys/stat.h>
# include <unistd.h>
# include <stdio.h>
# include <string.h>
# include <error.h>
int main()
{
int ret = -1;
struct stat buf;
mem... |
C | #include <stdio.h>
#include <stdlib.h>
int main() {
return 0;
}
void fillRand(int mat[4][4]){
int i, j;
for(i=0; i<4; i++){
for(j=0; j<4; j++){
mat[i][j]=(rand()%2000)-1000;
}
}
}
void rotateCCW270(int mat[4][4]){
int mat2[4][4], i, j;
for(i=0; i<4; i++){
for(... |
C | #include<unistd.h>
void ft_putchar(char c)
{
write(1, &c, 1);
}
int is_letter(char c)
{
return (('a'<= c && c <= 'z')||('A'<= c && c <= 'Z'));
}
void alpha_mirror(char *str)
{
int i;
i = 0;
while (str[i])
{
if('a'<= str[i] && str[i]<= 'z')
ft_putchar('a' + 'z' - str[i]);
else if('A'<= str[i] && str[i]<... |
C | /*
Author: Aryaman Kejriwal
Course: Introduction to Programming in C
instructor: Gilbert Pajela
Assignment: Lab 7.1
This program defines a type long_lat_t that stores latitude and longitude and methods to scan, print and check
their equality.
*/
#include <stdio.h>
typedef struct {
int degrees;
int minutes;
cha... |
C | /*
* Crypt Kicker
* PC/UVa IDs: 110204/843
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_WORDS_IN_DICTIONARY 1000
#define MAX_WORD_LENGTH 16
#define MAX_LINE_LENGTH 160
/* 字典,不同长度的词分组存储 */
char dict[MAX_WORD_LENGTH + 1][MAX_WORDS_IN_DICTIONARY][MAX_WORD_LENGTH + 1];
/* 字典中单词的个数,按长度分组 *... |
C | #include <stdio.h>
#include <stdlib.h>
typedef struct element{
int value;
struct element *prev, *next;
} element;
typedef struct linked_list{
element *start;
int count;
} ll;
ll* create_ll(){
element *head = (element*)malloc(sizeof(element));
head->value=0;
head->prev=NULL;
head->next=NUL... |
C | /*
* Write a pointer version of the function strcat that we showed
* in Chapter 2: strcat(s,t) copies the string t to the end of s
*/
#include <stdio.h>
#define BUFFER 1000
void strcat2(char *s, char *t) {
while (*++s); //iterate pointer to end of string s
while (*s++ = *t++);
}
int main() {
char s[] = "hel... |
C | #include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#ifndef NO_PROTECT
#define LEFT_DATA_CAN_ *(can_type*)stk->data_canary
#define RIGHT_DATA_CAN_ *(can_type*)(stk->data_canary + stk->capacity * sizeof(data_type) + sizeof(can_type))
#endif
#define CHECK_STK_ check_stk_err... |
C | #include "holberton.h"
/**
* print_last_digit - function that prints the last digit of a number.
* @NumberIntg: Variable type int.
* Return: Return the last digit of a number.
*/
int print_last_digit(int NumberIntg)
{
NumberIntg %= 10;
NumberIntg = (NumberIntg < 0) ? (-1) * NumberIntg : NumberIntg;
_putchar... |
C | /*----------------------------------------------------------------------------*\
| link.c |
| |
| Copyright 2002-2007, Team Brainix, original authors. |
| All rights reserved. |
\*----------------------------------------------------------------------------*/
/*
| This... |
C | #include "holberton.h"
#include <stdlib.h>
/**
* malloc_checked - allocates memory using malloc
*
* @b: size of the memory allocated
* Return: pointer to the allocated memory
*/
void *malloc_checked(unsigned int b)
{
void *memory;
memory = malloc(b);
if (memory == NULL)
{
exit(98);
}
return (memory);
}
|
C | #include <stdio.h> /* for printf() and fprintf() */
#include <sys/socket.h> /* for recv() and send() */
#include <unistd.h> /* for close() */
#include <string.h>
#include "ClientInfo.h"
#define BUFSIZE 200 /* Size of receive buffer */
#define USERNUM 2 /* Number of users */
#define USERBUF 100 /* Size of userlist buff... |
C | int main()
{
int n, year, a, b, k, i, t, sum;
int x[12]={3,1,3,2,3,2,3,3,2,3,2,3};
int y[12]={3,0,3,2,3,2,3,3,2,3,2,3};
cin >> n;
for(i=0;i<n;i++)
{
cin >> year >> a >> b;
sum = 0;
if(a>b)
{
k = a;
a = b;
b = k;
}
if((year%4==0&&year%100!=0)||(year%400==0))
{
for(t=a-1;... |
C | /*
1.Sa se scrie un program care calculeaza suma elementelor unui
vector folosindu-ne doar de variabile de tip pointer.
*/
#include <stdio.h>
#include <stdlib.h>
int main()
{
int nr, suma = 0, * adr, * i, * n;
printf("Cate elemente sunt in vector?\n ");
scanf("%d", &nr);
adr = (int*)malloc(nr * sizeof(int));
n = a... |
C | #include <GL/glew.h>
#include <GL/glut.h>
//#include <GL/gl.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <stdarg.h>
#include <math.h>
#include "./lib.h"
#define DEBUG
//Triangle indices for the bunny
int * bunny_indices;
GLuint vertex_ID;
GLuint texture_ID[2];
int * ver... |
C | /******************************************************************************
** Coypright(C) 2016-2026 Qiware technology Co., Ltd
**
** 文件名: mem_ref.c
** 版本号: 1.0
** 描 述: 内存引用计数管理
** 作 者: # Qifeng.zou # 2016年06月27日 星期一 21时19分37秒 #
*****************************************************************************... |
C | //The buble sort gets its name because as array elements are sorted they gradually "bubbles" to their proper position.
//A bubble sort will compare two adjacent element of ana array and will swap them they are not in order.
//The compare starts with the first and second element.After that it will compare the second wit... |
C | #define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward d... |
C | #include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
#define STR_LEN 1000
unsigned int N = 1000;
int number, position;
char* readLine() {
char* inputLine = malloc(sizeof(char[STR_LEN]));
fgets(inputLine, STR_LEN, stdin);
if (inputLine == N... |
C | #include "lists.h"
/**
* delete_dnodeint_at_index - deletes a node at a given postion
* @head: pointer to a pointer of a linked list.
* @index: position of the node to delete.
*
* Return: 1 on Sucess else -1 on failure.
*/
int delete_dnodeint_at_index(dlistint_t **head, unsigned int index)
{
dlistint_t *node;
... |
C | #include<stdio.h>
#define MAX 100
int bbi_recursivo (int x, int * v, int ini, int tam)
{
if (x==v[(ini+tam)/2])
return (ini+tam)/2+1;
if (ini>=tam)
return 0;
if (x>v[(ini+tam)/2])
return bbi_recursivo (x,v,ini=(ini+tam)/2 +1,tam);
else
return bbi_recursivo (x,v,ini,tam=(ini+tam)/2 -1);
}
void ler_vetor (i... |
C | /*
* started: 28jan15
* finished:
* written by: Damon Getsman
*
* This project is a simple test to make sure that the different functions
* available in my-nc_flashcard.h are working properly; a predecessor to the
* flashcard program that I am writing for my son, so that he can be able
* to practice his multipl... |
C | #include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <elf.h>
typedef struct {
char debug_mode;
char file_name[128];
int unit_size;
unsigned char mem_buf[10000];
size_t... |
C | #include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
void sighup_handler()
{
printf("Receive SIGHUP signal.\n");
}
int main()
{
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_handler = &sighup_handler;
sigaction(SIGHUP, &sa, NULL);
while (1);
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.