language large_stringclasses 1
value | text stringlengths 9 2.95M |
|---|---|
C | /**
* @file spi.h
* @brief Driver for interfacing with SPI.
*/
#ifndef SPI_H_
#define SPI_H_
#include <stdio.h>
/**
* @brief Sets up pins for MOSI, SCK, SS and MISO and specifies that the ATSam is master in of
* the SPI.
*/
void spi_init(void);
/**
* @brief Transmits @p data on the SPI.
*/
void spi_wr... |
C | #include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
int main(int argc, char* argv[]){
ssize_t rd, wr, wr1;
ssize_t numread, numread1;
char buffer[100];
char buffer1[50];
//check vaild input
if(argc != 4 || argv[1] == "--help")
{
printf("Invaild input!\nUsage... |
C | #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
struct tree {
int data;
struct tree *left;
struct tree *right;
};
struct tree *newNode(int data) {
struct tree *ptr = malloc(sizeof(struct tree));
ptr->data = data;
ptr->left = NULL;
ptr->right = NULL;
return ptr;
}
int max (int a,... |
C | /**
https://zhuethan.github.io/2020-08-03-MallocLab-In-CSAPP/. Implement a malloc strategy on empty heap space.
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdint.h>
#include "mm.h"
#include "memlib.h"
/* If you want debugging output, use the follo... |
C | #include "joystick.h"
s16 joystick[4]={0,0,0,0};
s16 joystick_reader_counter=0;
void joystick_setup() {
joystick[0]=0;
joystick[1]=0;
joystick[2]=0;
joystick[3]=0;
}
void joystick_capture()
{
static u8 n=0;
static u16 time_previous = 0;
static u16 joystick_[6] = {0,0,0,0,0,0};
u16 time, time_delta... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct list_s list_t;
struct list_s{
list_t *next;
char* word;
};
list_t *nodealloc(char *,list_t *);
list_t * stringsplit(char *);
int main()
{ list_t *ptr=NULL;
ptr=stringsplit("a.b.cccc.ddd.ccc.ddd.sss.sss");
while(p... |
C | #include "utilities.h"
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv) {
struct timespec start_time;
struct timespec wait_time;
struct timespec now;
uint64_t argv_start_time;
uint64_t argv_start_milliseconds;
char *argv_command;
if (argc != 4) {
printf("Usage: %s... |
C | #include<stdio.h>
int main()
{
char ch;
printf("빮 Է:");
scanf("%c",&ch);
//빮 'A' ƽŰڵ尪 65 B ƽŰڵ尪 66
//ҹ 'a' ƽŰڵ尪 97 ι ̴ 32
printf("%c ҹڴ %cԴϴ.",ch, ch+32);
return 0;
}
|
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 "List.h"
#include "List.c"
#include "queue.h"
#include "queue.c"
#include <stdio.h>
void main()
{
int choice;
queue *q1 = queue_new();
queue *q2 = queue_new();
int queueinuse = 1;
int ele, size;
printf("Press -1 to exit, 1 to push, 2 to pop, 3 to get size, 4 to print stack : ");
scanf("%d", &choi... |
C | #include <stdio.h>
//Function Prototypes
float checkBalance(int acctNum);
float getBalance(int acctNum);
/* checkBalance: return the balance of the specified account */
float checkBalance(int acctNum)
{
float bal;
bal = getBalance(acctNum);
return bal;
}
|
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
void * my_memmove(void *dst,const void * src,size_t num)
{
void * ret = dst;
if (src <= dst && dst < (char *)src + num)
{
dst = (char *)dst + num - 1;
src = (char *)src + num - 1;
while (num--)
{
*(char *)dst = *(char *)src;
... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* exec2.c :+: :+: :+: ... |
C | #ifndef MAIN_H
#define MAIN_H
// Program version (as reported by -v)
#define VERSION "1.2"
// Allowed ROM size limits
#define MIN_ROM_SIZE 0x200
#define MAX_ROM_SIZE 0x400000
// Location of relevant header fields
#define HEADER_COPYRIGHT 0x113 // Copyright code
#define HEADER_DATE 0x118 // Build... |
C | /////////////////////////////////////////////////////////////////////////////////
/// DS1307.C ///
/// ///
/// ds1307_init() -Habilita o relógio sem alterar o estado dos registrador... |
C | #define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<assert.h>
#include<stdlib.h>
#include<string.h>
//void qsort(void*base, num, width, int(*compare)(const void*, const void*));
// Ҫָ Ԫظ ԪشС ȽԪشСĺ
typedef struct STU
{
char name[20];
int age;
}STU;
void Swap(char*p1,char* p2,int width)
{
int i... |
C | /*CS1010 AY2019/20 Semester 1 Lab6 Ex2
* driver.c
* This program calculate the possible routes given an array of gas stations available within distance.
* <LIU YIFENG>
* <C06>
*/
#include <stdio.h>
#define MAX_STATIONS 20
//function prototypes
void readStations(int [], int [], int *, int *);
void printStations(int []... |
C | #include <stdio.h>
#include <stdlib.h>
void g(int x, int * y) {
printf("In g, x = %d, *y = %d\n", x, *y);
x++;
*y = *y - x;
y = &x;
}
void f(int * a, int b) {
printf("In f, *a = %d, b = %d\n", *a, b);
*a += b;
b *= 2;
g(*a, &b);
printf("Back in f, *a = %d, b = %d\n", *a, b);
}
int main(void) {
i... |
C | #include "common.h"
#include "log.h"
#include "branch_layer.h"
#include <memory.h>
static void branch_layer_prepare(layer_t *l)
{
LOG("branch_layer: in %d\n", l->in.size);
}
static void branch_layer_forward(layer_t *l)
{
int i = 0, b = 0;
branch_layer_t *me = (branch_layer_t *)l;
for (i = 0; i < me->... |
C | #include <stdio.h>
int main(void)
{
int n;
int p;
printf("Enter value for n and p followed by 'Enter': ");
scanf("%d %d", &n, &p);
printf("n value is: %d\np value is: %d\n", n, p);
return(0);
}
|
C | #include <stdlib.h>
#include <wordexp.h>
#include <dirent.h>
#include <errno.h>
#include <sys/stat.h>
#include "tc-directory.h"
#include "tc-task.h"
const char * _tc_getHomePath(){
const char * homePath;
/* Determine the home directory */
homePath = getenv("HOME");
if ( homePath == NULL ) {
/* Determine the h... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_path_add.c :+: :+: :+: ... |
C | #include "libft.h"
char *ft_strnew(size_t size)
{
char *res;
if ((res = malloc(sizeof(char) * (size + 1))) == NULL)
return (NULL);
res[size] = '\0';
while (size--)
res[size] = '\0';
return (res);
}
|
C | #include "multiboot.h"
#include "print.h"
void gdt_done();
void mem(struct multiboot_info* mbt)
{
char *clear_screen = " ";
int len = (int)mbt->mmap_length;
unsigned long x = 0, mem=0;
char *welcome = "Welcome to FIFOS: The System memory is: ";
char *mb=" MB";
memory_map_t* mmap = (memory_map_t*... |
C | #include <string.h>
#include <stdio.h>
int main(void) {
int a = 0b1111;
int b = 0b0011;
int status;
status = memcmp(&a, &b, 4);
if (status == 0) {
printf("Same bytes\n");
}
else if (status < 0) {
printf()
return 0;
}
|
C |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "../common/constants.h"
#include "../topology/topology.h"
#include "routingtable.h"
//makehash()是由路由表使用的哈希函数.
//它将输入的目的节点ID作为哈希键,并返回针对这个目的节点ID的槽号作为哈希值.
int makehash(int node)
{
return node % MAX_ROUTINGTABLE_SLOTS;
}
//这个函数动态创... |
C | /**
* This program demonstrates invocation of the rmdir
* system call (40) using the syscall function.
*/
#include <linux/types.h>
#include <linux/unistd.h>
#include <string.h>
int main(int argc, char *argv[]) {
// We demonstrate the use of command-line arguments here.
// But note the non-existent error handlin... |
C | //
// main.c
// 2-1
//
// Created by 下田将斉 on 2016/07/04.
// Copyright © 2016年 Masakiyo Shimoda. All rights reserved.
//
#include <stdio.h>
#include <time.h>
void printtime(long totalsec){
int sec, min, hour, day;
day = totalsec / (24 * 60 * 60);
hour = totalsec / (60 * 60) - (day * 24);
min = tota... |
C | #include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "svm.h"
#define Malloc(type,n) (type *)malloc((n)*sizeof(type))
// yes, this was not the best idea..
typedef signed char schar;
typedef float Qfloat;
#ifndef min
template <class T> static inli... |
C | //print all natural no. b/w n & 1 using while loop
#include<stdio.h>
int main()
{
int n,i=1;
printf("\nEnter no. till you want natural no. to be printed : ");
scanf("%d",&n);
i=n;
printf("\nNatural nos b/w %d and 1 are : ",n);
while(i>=1)
{
printf(" %d ",i);
i--;
}
printf("\n");
return 0;
}
|
C | #include<signal.h>
#include <stdio.h>
#include <stdlib.h>
#include<unistd.h>
void sigcb(int signo){
}
int mysleep(int nsec){
signal(SIGALRM,sigcb);
alarm(nsec);
pause();//永久阻塞但是被信号打断了
}
int main(){
mysleep(2);
printf("-----");
}
|
C | /*
* bit_manipulation.c
*
* Created on: Feb 4, 2020
* Author: Alex
*/
#include <stdio.h>
#include "bit_manipulation.h"
void check_bit(unsigned char x, unsigned char pos)
{
x &= 1U << pos;
if(x)
{
printf("Bit is SET\n");
}
else
{
printf("Bit is UNSET\n");
}
}
void set_bit(unsigned char * x, unsi... |
C | #include "my_misc.h"
#include "stdint.h"
long map(long x, long in_min, long in_max, long out_min, long out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
int intToString(char* str, int n,int radix) //将整数表达成字符形态
{
int i = 0, j = 0, remain = 0;
int len = 0;
char t... |
C | #include <stdio.h>
#include <inttypes.h>
#include <ctype.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <fcntl.h>
#include "../include/libfts.h"
#define TRUE 1
#define FALSE 0
#define DEBUG FALSE
#define FT_DEBUG(in_context, ...) \
do {... |
C | #ifndef CBUF_H
#define CBUF_H
#define CBUF_SIZE 1024
typedef struct cbuf {
int size;
char data[CBUF_SIZE];
int start;
int end;
} cbuf;
void cbuf_new(cbuf *buf);
void cbuf_push(cbuf *buf, char c);
char cbuf_pop(cbuf *buf);
char cbuf_peek(cbuf *buf);
void cbuf_unpop(cbuf *buf, char c);
char cbuf_unpush... |
C | #include "holberton.h"
/**
* _strstr - locate a substring
* @haystack: string to search
* @needle: substring to search for
*
* Description: Find the first occurrence of the substring needle in the
* string haystack. The terminating null bytes ('\0') are not compared.
*
* Return: a pointer to the beginning of t... |
C | //PEPIN Thibaut
//PAXENT Laurent
#include "cesar.h"
int nombre_ligne(char* path)
{
int fd = open(path,O_RDONLY);
int res=0;char c;
while(read(fd,&c,sizeof(char)) != 0)
{
if(c == '\n') res++;
}
close(fd);
return res;
}
instruction* recup_inst(char* nom_fic,int nbr_ligne)
{
int fd = open(nom_fic,O_RDONLY... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_graph_shortestpath.c :+: :+: :+: ... |
C | #include <string.h>
#include <stdlib.h>
#include "memory.h"
#include "parse.h"
#include "errors.h"
// Operators functions
int isAllowedAfter(const char *op)
{
if (
strcmp(op, "-o") == 0
|| strcmp(op, "-a") == 0
|| ((op[0] != '-' && op[0] != '!')
&& (op[0] != '-' && op[0] != '('))
... |
C | #ifdef CS333_P2
#include "types.h"
#include "user.h"
//Allows user interaction with the system calls that
//both set and get UIDs and GIDs
int
main(void)
{
uint ppid;
int validTest = 32768;
int invalidTest = -10;
//UID testing
printf(2, "\n\nreturn code for setuid(%d) is: %d\n",validTest, setuid(validTest));
... |
C | #include "stdio.h"
#include "math.h"
#define N 501
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) < (b) ? (a) : (b))
int n, r[N];
double x[N];
int main()
{
int i, j;
while (scanf (" %d", &n) != EOF){
for (i = 0; i < n; i++) scanf (" %d", r + i);
for (i = 0; i < n; i++){
... |
C | //8.4
#include <stdio.h>
#include <locale.h>
#include <math.h>
#include <stdlib.h>
int main()
{
setlocale(LC_ALL, "Rus");
int A,t;
printf("Введите двузначное число\n");
scanf("%d",&A);
t=A%10;
A=A/10;
printf("%d",t*10+A);
return 0;
}
|
C | /*
** key_shift.c for in /home/januar_m/delivery/PSU/PSU_2016_42sh
**
** Made by Martin Januario
** Login <martin.januario@epitech.eu>
**
** Started on Thu May 18 19:44:16 2017 Martin Januario
** Last update Fri May 19 14:53:11 2017 Martin Januario
*/
#include <curses.h>
#include <term.h>
#include "edit.h"
stat... |
C | /*
The header for robust i/o functions
The functions are analogous to the ones from the book "Computer Systems: A Programmer's Perspective"
by Randal Bryant and David O'Hallaron
*/
#ifndef ROBUST_IO_H
#define ROBUST_IO_H
#include <stdio.h>
#define RIO_BUFSIZE 8192
typedef struct
{
int rioFd; ... |
C | #include <stdlib.h>
#include <stdio.h>
typedef struct celula {
int dado;
struct celula *prox;
} celula;
celula *enfileira(celula *f, int x){
celula *novo = malloc(sizeof(celula));
if(novo == NULL)
return NULL;
else{
novo->prox = f->prox;
f->prox = novo;
f->dado = x;
return... |
C | #include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
int main ( int argc, char * argv[] )
{
pid_t pid;
int i=0;
pid = fork();
if ( pid > 0 ) {
printf("PARENT PROCESS %d\n",getpid());
printf("CHILD PROCESS IS EXITED \n");
//wait(NULL);
}
... |
C | #include <stdio.h>
#include <errno.h>
#if 0
void perror(const char *s);
#endif // 0
int main(int argc, char *argv[]) {
errno = 1;
perror("errno = 1");
errno = EAGAIN;
perror("errno = EAGAIN");
return 0;
}
|
C | #include <stdio.h>
//Escreva um algoritmo que leia um conjunto de 100 nmeros inteiros positivos e determine o maior deles.
int main(){
int n1=0, nf=0, i;
for (i=0;i<100; i++){
printf("Digite um numero: ");
scanf("%d", &n1);
if(nf<n1){
nf=n1;
}
}
printf("O... |
C | #ifndef __F1_HELPER_H__
#define __F1_HELPER_H__
#define _BSD_SOURCE
#define _XOPEN_SOURCE 500
#include <stdio.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <bsg_manycore_driver.h>
#include <bsg_manycore_loader.h>
#include <bsg_manycore_mem.h>
#includ... |
C | #include <stdlib.h>
#include <stdio.h>
#include "../__RVC_IsNull_Monitor.h"
int main(void) {
int* v[5], i, sum = 0;
fprintf(stdout, "Test 2\n");
fprintf(stderr, "Test 2\n");
v[0] = (int *)malloc(sizeof(int)); *(v[0]) = 1;
v[1] = (int *)malloc(sizeof(int)); *(v[1]) = 2;
v[2] = NULL;
v[3] = (int *)malloc(sizeof(... |
C | // chatClient.c
// the main function of your chatServer
#include <stdio.h>
#include <signal.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include "Socket.h"
#include "Thread.h"
#include "Packet.h"
#include "socketStruct.h"
const int MAX_MESSAGE = 1024;
// The function of the cha... |
C | /*
* index3.c
*
* Created on: Dec 12, 2019
* Author: isel
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "index.h"
static void tInsert(Tnode **rp, Word word);
static Word* tFind(Tnode **rp, Word word);
static Word* privateIndexFindWord(char *data);
static int cmpWordByValue(const voi... |
C | //#include "my_malloc.h"
//#include "my_pthread_t.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define SIZE (4096 * 4096)
#define PAGE_SIZE 4096
int main()
{
char *swap="swapper";
int fd = open(swap,O_CREAT | O_RDWR... |
C | #include"utils.h"
#include"maths.h"
static void tmp_mod_light(t_light_list *curr,
t_coords *base,
t_coords *decal,
int max)
{
int off;
int semi;
t_coords *cdecal;
off = curr->soft_val;
semi = off / 2;
cdecal = &(curr->rndm[(int)decal->y * max + (int)decal->x]);
curr->pos->x = base->x + cde... |
C | void init (LInt *l){
LInt current = *l;
if ((*l)->prox == NULL){
free(*l);
*l = NULL;
return;
}
LInt prev;
while (current -> prox != NULL){
prev = current;
current = current -> prox;
}
prev -> prox = NULL;
free(current);
}
|
C | #include <string.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include "../include/sstring.h"
bool string_valid(const char *str, const size_t length){
if(length==0) //check to make sure there is a valid length
return false;
if(str==NULL) //check for null string
return false;
int i;
for(i=0; i<... |
C | #include <stdio.h>
#define MAX 1000
void escape(char s[], char t[]);
void esc(char s[], char t[]);
int main()
{
int c;
char s[MAX];
char t[] = "li\nnu\tx";
char o[] = "li\\nnu\\tx";
escape(s, t);
printf("result: %s\n", s);
esc(s, o);
printf("result: %s\n", s);
c = getchar();
ret... |
C | /* , , EOF. . . , . ( ispunct() ctype.h.)*/
#include <stdio.h>
#include <ctype.h>
int main(void)
{
int letters=0;
int char_number=0;
int j,i=0;
int letters_count[1000];
int average=0;
int symbols_count=0;
char ch;
while(scanf("%c",&ch)!=EOF)
{
if(ch... |
C | #include <cs50.h>
#include <stdio.h>
#include <string.h>
int main(){
string num0 = get_string("");
string num1 = get_string("");
char temp;
int number1 = strlen(num0);
int number2 = strlen(num1);
for (int i=0; i < number1; i++){
for (int j=0; j < number1 - i - 1; j++ ){
... |
C | /***********************************************************************************************************
*执行用时:4 ms, 在所有 Go 提交中击败了84.73%的用户
*内存消耗:5.7 MB, 在所有 Go 提交中击败了79.74%的用户
************************************************************************************************************
*/
/*************************... |
C | /*
* Moisture_sensors.c
*
* Created: 11/9/2019 3:13:54 PM
* Author : steph
*/
#include <avr/io.h>
//#include <timer.h>
void ADC_init() {
ADCSRA |= (1 << ADEN) | (1 << ADSC) | (1 << ADATE);
// ADEN: setting this bit enables analog-to-digital conversion.
// ADSC: setting this bit starts the first c... |
C | /*
** initbcg1.c for initbcg1 in /home/marrie_h/rendu/PSU/PSU_2015_tetris
**
** Made by hugo marrien
** Login <marrie_h@epitech.net>
**
** Started on Tue Feb 23 10:33:36 2016 hugo marrien
** Last update Wed Mar 16 12:20:14 2016 nguyen kevin
*/
#include "header.h"
void init_colorbcg1()
{
init_pair... |
C | #ifndef INPUTS_H_
#define INPUTS_H_
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
/// @fn unsigned long long PedirCUIL_CUIT(char[], char[])
/// @brief
///
/// @param mensaje
/// @param mensajeError
double PedirCUIL_CUIT(char mensaje[], char mensajeError[]);
/// @fn void PedirCadena(ch... |
C | #include "MirrorInitiator.h"
void client_assistant(int sock, int argPos, char** argv)
{
int i = 0, size, end = true, filesTransferred, bytesTransferred;
char buffer[256];
char** StrTable;
content_num = 0; // Global variable
StrTable = analyze(argv[argPos], ",", strlen(argv[argPos]));
/* Send how much... |
C | #include "pebble.h"
Window *s_main_window;
TextLayer *s_data_layer;
int boundsShift = 0;
void setLayerBounds(TextLayer *subject, int16_t new_bounds)
{
APP_LOG(APP_LOG_LEVEL_INFO, "In setter with %d", new_bounds);
GRect bounds;
bounds = layer_get_bounds((Layer *)subject);
bounds.origin.x = new_bounds; // Move... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
static int compare(char *s1, char *s2)
{
for (int i = 0; i < 50; i += 1) {
if (s1[i] != s2[i]) {
return 0;
}
}
return 1;
}
int main(int ac, char **av)
{
const char charset[] = "IHaveNoIdeaWtfImDoingRightNow";
co... |
C | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "automatecellulaire.h"
//GENERATION
//PURPOSE : Iteration of a single generation of the game of life.
//INPUT : Buffer and number of generations
//OUTPUT : Edited text file with info on the current generation
void generation(enum cell buffer[SIZE][SIZE]... |
C | /*
*
* This code implements the sum of two vectors in parallel using a shared memory approach, implemented with OpenMP
* The parallelization is inplicit because the loop is autmatically divided among the threads by the OpenMP work scharing construct
* The pre-defined size of the vectors N is not expected to be a su... |
C | #include <string.h>
#include <stdlib.h>
#include "urgan.h"
int main(void){
char line[SIZE];
char *rssis;
const char *id;
int i,j;
int closest[4];
FILE *f=fopen("/dev/ttyUSB0","r+");
if(f == NULL){
printf("erreur ouverture fichier USB0\n");
exit(0);
}
Marker* dist=malloc(N_BALISES*sizeof(Marker));
i... |
C | #include <stdlib.h>
#include <string.h>
#include "hiredis/hiredis.h"
#include "player_state.h"
const char *KEY_STATE = "player-state";
const char *HKEY_ALBUM = "album";
const char *HKEY_TRACK = "track";
const char *HKEY_SONG_TIME_ELAPSED = "song-time-elapsed";
int player_state_store(const char *album, int track, dou... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf_width_1.c :+: :+: :+: ... |
C | #include <stdio.h>
#include <cs50.h>
int main(void){
int numStudents = get_int("Number of students: ");
int numAssignments = get_int("Number of Assignments for each student: ");
int gradebook[numStudents][numAssignments];
string students[numStudents];
int averages [numStudents];
for(int i=0; ... |
C | #pragma once
#include "Vector3f.h"
/**
* This structure defines a vertex data.
*/
struct Vertex {
float position[3];
float color[3];
float normal[3];
float texCoord[3];
Vertex() {}
Vertex(Vector3f pos, Vector3f c, Vector3f n, Vector3f tex) {
position[0]=pos.x();
position[1]=pos.y();
position[2]=pos.z(... |
C | #include <stdio.h>
#include <stdarg.h> //可变参数头文件
void change(int *num);
//可变参数函数
double avg(int num, ...);
int main()
{
int num = 9;
change(&num);
printf("%d\n", num);
printf("%.2lf", avg(4, 2,3,4,5));
return 0;
}
void change(int *num)
{
(*num)++;
}
double avg(int num, ...)
{
va_list va... |
C | import java.util.*;
import java.lang.*;
public class roman{
public static void main(String aa[]){
int sum=0;
String s;
int b=0;
int pp=0;
int count=0;
int c[]=new int[100];
Scanner ss=new Scanner(System.in);
s=ss.next();
cha... |
C | //Find duplicate letters in a string
#include<stdio.h>
int main()
{
char a[100];
int i,j,count;
printf("Enter a string=");
scanf("%s",&a);
for(i=0;a[i+1]!='\0';i++)
{
if(a[i]!=-1)
{
count=1;
for(j=i+1;a[j]!='\0';j++)
{
... |
C | #include <stdio.h>
#include <string.h>
int main()
{
char str[1002] = {'\0'};
while (fgets(str, 1000, stdin)){
char *p = "poi";
char *q = str;
int count = 0;
q = strstr(str, p);
for (int i = 0; i < 334; i++){
if (q == NULL){
break;
}else{
q = strstr(q + 1, p);
count++;
}
}
printf("... |
C | #include <Python.h>
#include <SDL/SDL.h>
#include <SDL/SDL_opengl.h>
#define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 600
#define SCREEN_BPP 32
#define NUM_QUADS 1
typedef struct point {
float x, y;
} point;
typedef struct rgb_color {
float r,g,b;
} rgb_color;
typedef struct quad {
point *center;
... |
C | //
#include <stdio.h>
int main (void)
{
int a,b;
printf ("input 2 whole numbers");
scanf("%d%d", &a,&b);
printf("a+b=%d+%d=",a,b,a+b);
printf("a+b=%d+%d=",a,b,a-b);
printf("a+b=%d+%d=",a,b,a*b);
}
|
C | #include <stdio.h>
/*
10. Um investidor está preocupado com o cambio
do dólar e necessita de um programa que o auxilie
a calcular a variação cambial entre dois dias consecutivos.
Implemente um programa que solicite dois valores de dólar
(preço) e informe a diferença absoluta e a diferença relativa ... |
C | /**
* \fn void strupr(char *cadena)
* \brief Reemplaza los caracteres minuscula por mayusculas.
* \author Pose, Fernando Ezequiel.
* \date 2010.06.11
* \param Entrada de la palabra.
* \return No retorna.
*/
void strupr(char *cadena){
int i, len;
len = my_strlen(cadena);
for(i=0; i< len; i++){
... |
C | /**
* \file Edge.h
*
* Contains all the instruction to operate with edges
*
* Created on: Dec 22, 2016
* Author: koldar
*/
#ifndef EDGE_H_
#define EDGE_H_
#include "hashtable.h"
#include "list.h"
#include <stdbool.h>
struct Node;
struct PredSuccGraph;
/**
* Represents a direct edge
*
* \dotfile edg... |
C | #include <fcntl.h>
#include <gpiod.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define COUNT 1000000
const char *NAME = "logger";
int main(int argc, char *argv[])
{
struct gpiod_chip *chip;
struct gpiod_line_bulk lines;
int dump_file;
unsigned int offsets[2] = {19, 20};
u... |
C | #include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include "IPCServer.h"
extern int ultra_val[3];
char motor_pin[4];
void delay(int tt){
char tmpbuf[4];
sprintf(tmpbuf,"%d",tt);
strcat(motor_pin,",");
strcat(motor_pin,tmpbuf);
char *p;
p = strtok(motor_pin, ",");
*motor_pin=*p;
IPCServer(motor_p... |
C | #include<stdio.h>
long int fatorial();
int main(int argc, char const *argv[]){
int num = 20;
long int fat = 0;
fat = fatorial(num);
printf("%ld\n", fat);
return 0;
}
long int fatorial(int n){
long int f;
if (n==0)
return 1;
else
f = n * fatorial(n-1);
return f;
} |
C | #ifndef _VEC3_H_
#define _VEC3_H_
typedef struct vec3 {
float x, y, z;
} vec3;
/**
* @brief Creates a new vec3 struct, populated with the given values. This
* function allocates space for the new vec3. If space cannot be allocated for
* this vec3, this function will immediately terminate the program.
*
* @p... |
C | #include <stdio.h>
int main(int argc, char** argv)
{
if (argc!=2) {
printf("Not 1 argument!");
return 0;
}
char* str=argv[1];
int length=0;
int x=0;
int a=1;
while(a==1)
{
if(str[x]=='\0')
a=2;
else{
length++;
}
x++;
}
int frequen... |
C | #include <stdio.h>
main()
{
int c, sp;
sp = 0;
while ((c = getchar()) != EOF ){
if (c != ' '){
putchar(c);
sp = 0;
}
if (c == ' '){
if (sp == 0)
putchar(c);
sp = 1;
}
}
return 0;
} |
C | #include <stdio.h>
int main(void)
{
char a[10] = "senthil";
char b[10] = "entslihk";
char ch;
unsigned int xor = 0;
int i = 0;
// Since XOR is cumulative. 2^3^2==3. So XOR the whole string and XOR it again to nullify then the remaining char is the extra one
while (ch = a[i++]) {
xor ^= ch;
}... |
C | #include <stdio.h>
#include <math.h>
#define s scanf
void p(){
unsigned char x=0;
float e;short c;signed char n,i; float u=0;
s("%f",&e);
if(e==0) return;
s("%hhu",&n);
for(i=0;i<n;i++){
s("%hi",&c);
u+=c;
}
printf("%.0f\n",ceil(u/e));
p();
}
int... |
C | /* pqueue.c
* Implementation of a priority queue.
* Homework assigned 2/8/17
*/
#include "pqueue.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#define INITIALCAPACITY 100
#define min(a, b) ((a < b) ? a : b)
Data makeData(Vertex *v, int weight) {
Data data = {v, weight};
return d... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <ctype.h>
#include <assert.h>
#include "linkedl.h"
#include "basecase.h"
#include "tokenize.h"
void helper_main(char cmd[]);
int
main(int argc, char** argv)
{
if (argc > 2) {
// return invalid inputs
printf("\... |
C | #include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#define BUF_SIZE 80
#define SLEEP_TIME 5000
#define BUFFER_SIZE 256
#define STANDART_OUTPUT 1
#define CHECK_ERROR(status, mes)\
if (status != 0) {\
char buf[BUF_SIZE] = { 0 };\
strerror_r(status, ... |
C | /*
ID: lizhita1
LANG: C
TASK: cowtour
*/
#include <stdio.h>
#include <string.h>
#include <math.h>
#define MAXN 150
#define sqr(a) ((a)*(a))
int n, adj[MAXN][MAXN];
double loca[MAXN][2];
double dist[MAXN][MAXN];
int main() {
FILE *fin = fopen("cowtour.in", "r");
fscanf(fin, "%d", &n);
for (int i=0; i<n... |
C | #include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <dirent.h>
#include "tiny-AES-c/aes.h"
#ifdef AES256
#define AESBYTES 32
#elif defined(AES192)
#define AESBYTES 24
#elif defined(AES128)
#define AESBYTES 16
#else
#error Must define AES SIZE MACRO
#endif
#de... |
C | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <glib.h>
#include "server/clients.h"
#include "proto/proto.h"
GSList *clients;
pthread_mutex_t clients_lock;
pthread_mutexattr_t lock_attr;
void _broadcast_m... |
C | #include "oled.h"
#include "s3c24xx.h"
#include "gpio_spi.h"
#include "oledfont.h"
static void OLED_Set_DC(unsigned char val)
{
if (val)
GPGDAT |= (1<<4);
else
GPGDAT &= ~(1<<4);
}
static void OLED_Set_CS(unsigned char val)
{
if (val)
GPFDAT |= (1<<1);
else
GPFDAT &= ~(1<<1);
}
static void OLED_Write... |
C | /*
Name: find-largest-word.c
Date: July 6, 2020
Description: Find the smallest and largest words
the way you'd find them in the dictionary
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h> // malloc
#include <stdbool.h> // bool
#include <ctype.h> // isalpha
#define MAX_WORD_L... |
C | /** @file demo.c
@author Ollie Chick (och26) and Leo Lloyd (lll28)
@brief Demo module - used to display information before the game starts.
*/
#include <stdbool.h>
#include "system.h"
#include "pio.h"
#include "pacer.h"
#include "tinygl.h"
#include "button.h"
#include "../fonts/font5x7_1.h"
#include "displa... |
C | #include<stdio.h>
int main(){
int arr[3][5];
int value = 0;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 5; j++) {
arr[i][j] = i * 10 + j;
}
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 5; j++) {
printf("arr[%d][%d] = %d\n", i, j, arr[i][j]);
}
}
return 0;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.