language large_stringclasses 1
value | text stringlengths 9 2.95M |
|---|---|
C |
//* Problem: 1134 (Type of Fuel)
#include <stdio.h>
int main(void)
{
int n;
int alcohol = 0, gasoline = 0, diesel = 0;
while (1)
{
scanf("%d", &n);
if (n > 0 && n <= 4)
{
if (n == 1)
{
alcohol++;
}
... |
C | #include<stdio.h>
/*int main()
{
int aa[2][5] = { 10,9,8,7,6,5,4,3,2,1 };
int* ptr1 = (int*)(&aa + 1);
int* ptr2 = (int*)(*(aa + 1));
printf("%d,%d", *(ptr1 - 1), *(ptr2 - 1));
return 0;
}
int main()
{
int a[5] = { 5, 4, 3, 2, 1 };
int* ptr = (int*)(&a + 1);
printf("%d,%d", *(a + 1), *(ptr - 1));
return 0;
}*/ |
C | #include "stdafx.h"
#include <stdio.h>
#define SIZE 100
int main(void) {
FILE *realNos, *realNosSorted;
int i = 0, j;
double realNumbers[SIZE];
double current;
double total = 0.0;
fopen_s(&realNos, "realNos.txt", "r");
if (realNos == NULL) { // Test if the file was able to open properly
puts("Error opening ... |
C | /**
* This file is part of the Rig project.
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code.
*
* @copyright (c) the Rig project
* @author Luca Longinotti <chtekk@longitekk.com>
* @license BSD 2-clause
* @version $Id: rig_c... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* replace_quote_path.c :+: :+: :+: ... |
C | /* ************************************************************************** */
/* */
/* :::::::: */
/* visualizer.c :+: :+: ... |
C | #include "simple_shell.h"
/**
* freeDoublePointer - free a double pointer
* @pointer: pointer to free
*
* Return: is a void
*/
void freeDoublePointer(char **pointer)
{
int cnt = 0;
if (pointer != NULL)
{
while (pointer[cnt] != NULL)
{
free(pointer[cnt]);
cnt++;
}
free(pointer[cnt]);
free(pointe... |
C | #include "YsThreadWorker.h"
#include <stdio.h>
CThread::CThread():m_Detach(false),m_CreateSuspended(false)
{
m_ThreadName = new char[32];
}
CThread::CThread(bool createsuspended,bool detach):m_Detach(detach),m_CreateSuspended(createsuspended)
{
m_ThreadName = new char[32];
}
CThread::~CThread()
{
delete [] m... |
C | #include <stdio.h>
int main(void)
{
char name[30];
int number;
printf("What's your name? \n");
//scanf("%s", name);
fgets(name, sizeof(name), stdin);
//removes new line putted by fgets
for(int i= 0; i < 29; i++){
if(name[i] == '\n')
name[i] = ' ';
}
... |
C | #include <linux/init.h> // Macros used to mark up functions e.g. __init __exit
#include <linux/module.h> // Core header for loading LKMs into the kernel
#include <linux/device.h> // Header to support the kernel Driver Model
#include <linux/kernel.h> // Contains types, macros, functions... |
C | #include <stdio.h>
#include <stdlib.h>
#include "k.h"
bool is_game_won(const struct game game);
void add_random_tile(struct game *game);
bool is_move_possible(const struct game game);
bool update(struct game *game, int dy, int dx);
void add_random_tile(struct game *game){
int row, col;
// find random, but... |
C | #include <stdio.h>
#include <stdlib.h>
const int MAX_ELEMENT = 10;
void swap(int *x, int *y){
int temp;
temp = *x;
*x = *y;
*y = temp;
}
void selectionsort(int list[], int n){
int i, j , posisi;
for (i = 0; i < (n-1); i++){
posisi = i;
for (j = i; j < n; j++){
if ... |
C | #include <unistd.h>
int main(int ac, char **av)
{
int i = 0;
int k = 0;
int e = 1;
int b = 0;
if (ac > 1)
{
ac--;
while (ac > 0)
{
while (av[ac][i])
{
if (av[ac][i] == 'K')
k = 1;
if (av[ac][i] == 'B')
b = 1;
if (av[ac][i] == 'T' || av[ac][i] == 'P')
e = 0;
i++;
}
... |
C | /**
*
* \file dque_util.c
* \name dque_util
* \author Dale Anderson
* \date 07/30/2019
* \brief Return pointer to user's data from the last qnode of a queue.
* \version
* Version Date Author Comment
* 1.1 07/30/2019 D.Anderson original
*
* These routines form wrappers around som... |
C | #include "lemipc.h"
int main(int argc, char **argv)
{
t_map *map;
int mem_id;
key_t key;
t_player player;
int sem_id;
struct sembuf sb[1];
argc += 0;
/* synopsis final :
allocation de l'ipc;
test de la zone memoire, si elle n'existe pas creation avec ipc_creat;
nb++ pour savoir le nom... |
C |
#include<string.h>
int main()
{
char str[25];
int listen_fd, comm_fd;
int i = 0;
struct sockaddr_in servaddr;
listen_fd = socket(AF_INET, SOCK_STREAM, 0);
bzero( &servaddr, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htons(INADDR_ANY);
servaddr.sin_port = htons(... |
C | //--------------------curent time-------------
#include<stdio.h>
#include<time.h>
void main()
{
char *time_now;
time_t t =time(NULL);
time_now=ctime(&t);
printf("data and date now:%s",time_now);
}
|
C | #include <stdio.h>
#include <string.h>
#include "../crypto.h"
#include "../assert.h"
/*
Convert hex to base64
http://cryptopals.com/sets/1/challenges/1
The string:
49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d
Should produce:
SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGE... |
C | /* ctsw.c : context switcher
Called from outside:
ctsw_init_evec() - initializes irq handlers to enter the context switcher
ctsw_contextswitch() - context switch from kernel to user process
Further details can be found in the documentation above the function headers.
*/
#include <xeroskernel.h>
#include... |
C | //Autor: Leszek Baca. Program do zliczania liter w kolumnach tablicy dwuwymiarowej
#include <stdio.h>
#define WIERSZE 20
#define KOLUMNY 20
int dlugosc (char tab[]);
void wpisz(char tab[][KOLUMNY], char string[]);
void drukuj( char tab[][KOLUMNY]);
void zliczajZnaki( char tab[][KOLUMNY]);
int main()
{
ch... |
C | #include <stdio.h>
int main() {
int initial_minute, initial_hour;
int final_minute, final_hour;
scanf("%d %d %d %d", &initial_hour, &initial_minute, &final_hour, &final_minute);
int hour = final_hour - initial_hour;
int minute = final_minute - initial_minute;
if (hour <= 0 && minute <= 0) {
hour += 24;
}... |
C | #include <stdio.h>
int main()
{
int n,t,flag;
printf("enter an integer");
scanf("%d",&n);
t=n;
flag=0;
while(t!=1);
{
if(t%2!=1)
{
flag=1;
break;
}
t=t/2;
}
if(flag==0)
printf("%d is a number that is a power of 2",n);
e... |
C | #define MAX 100
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
int age;
char name[20];
}DataType;
typedef struct node
{
DataType data;
struct node *lchild, *rchild;
}BTree;
FILE *fp;
int TotalAge, TotalNumber;
BTree *CreateTree();
void Traversing(BTree *t);
void PreOrder(BTree *t);
void NodeLevel(BTree... |
C | #include<stdio.h>
void main()
{
char ch;
printf("Enter a character\n");
scanf("%c",&ch);
if(ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch == 'o' || ch == 'O' || ch == 'u' || ch == 'U')
{
printf(" %c is a vowel.\n",ch);
}
else
{
printf("%c is'nt a vowel.\n",ch);
}
}
|
C | #include "buffer.h"
#include "sciTinyTimber.h"
int put(Buffer *self, int data) {
if(self->count < Bsize) {
self->A[self->I] = data;
self->I = (self->I + 1) % Bsize;
self->count = self->count + 1;
return 0;
}
else {
return -1;
}
}
int get(Buffer *self, int unused... |
C | #include <stdio.h>
#define N 5
int main(void)
{
int a[N];
int temp = 0;
int counter = 1;
printf("Base massive - ");
for (int i = 0; i < N; i++)
{
a[i] = counter++;
printf("%d ", a[i]);
}
printf("\n");
for (int i = 0; i < N / 2; i++)
{
temp = a[i];
... |
C | #include "wifi_config.h"
#include "string.h"
#include "stdio.h"
//#include "stm32f10x.h"
/***ⲿҪesp8266ֳʼATָ***/
//ڻѰջ
//mesջ壬str
//ҵַλãnull
char* find_str_from_mes_buf(char *str)
{
char* res = strstr(mes_buf,str);
return res;
}
//ݵ
void add_mes_buf(char ch)
{
mes_buf[num++]=ch;
if(num==ME... |
C | #define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stddef.h>
#include<string.h>
#include<errno.h>
/*
ļ ʹ ļ
.c .obj .exe
ļ ASCII 浽 ıļ
ļһ롣 Ʊ༭
ļ·+ļ+ļ
wb ԶƵķʽдļ
write д දʱ ļʱԶļ
ļϢ һ ļṹ͵ıԶļ Ϣ
ýṹָάϢϢάļݡ 磺FILE* pf
ļϵͳڴдʱиڴˣһϡ
ڴӴ϶ȡʱиڴ뻺ˣһ뵽ڴС
ϵͳԶڴΪÿһʹõļһ顰ļ
ĴСCϵͳ
ʹļʱȴ... |
C | #include <stdio.h>
void main()
{
int arr[10];
int i = 0;
int *p = arr;
for(; i < 10; ++i) arr[i] = i + 1;
for(i = 0; i < 10; ++i) printf("%d ", *(p+i) = *(p+i) + 2);
}
|
C | /*
** EPITECH PROJECT, 2020
** cpp_d03_2019
** File description:
** Ex01
*/
#include <criterion/criterion.h>
#include "../string.h"
Test(assign_s, good_assign)
{
string_t s;
string_t s2;
char* expected = "Hello World";
string_init(&s, expected);
string_init(&s2, NULL);
cr_assert_str_eq(s.str,... |
C | // This program is a part of NT MudLIB
// luoying-shenfa Ӣ
#include <combat.h>
#include <ansi.h>
inherit SKILL;
mapping *action = ({
([ "action" : "$nͷһͣ˫䣬ǰƼ$NȥһС$N֮£ͳͳ$nա\n",
"dodge" : 10,
"skill_name" : ""
]),
([ "action" : "$nμʹһСڿաͬΪƮһܹ࣬$N\n",
"dodge" : 20,
"skill_na... |
C | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: main.c
* Author: cihan
*
* Created on April 4, 2019, 12:11 AM
*/
#include <stdio.h>
#include <stdlib.h>
/*
*
*... |
C | #define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
void merge(int* nums1, int nums1Size, int m, int* nums2, int nums2Size, int n)
{
int i;
int start1 = 0, start2 = 0;
int* res = (int*)malloc((m + n) * sizeof(int));
memset(res, 0, (m + n) * sizeof(int));
for (i = 0; i < nums1Size; ... |
C | /*******************************************/
/* BUSQUEDA.C */
/* */
/* Asignatura: Inteligencia Artificial */
/* Grado en Ingenieria Informatica - UCA */
/*******************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#i... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define PORT 29177
#define BACKLOG 10
static FILE *fp_ls;
static int listenfd, connfd;
static char buffer[BUFSIZ];
static struct sockaddr_in server, client;
void erro... |
C | #define _GNU_SOURCE
#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <syscall.h>
#include <unistd.h>
#include <sys/wait.h>
// execute program
// flag:
// - AT_EMPTY_PATH 如果路径名是空字符串,请对该文件进行操作由dirfd引用(可能已使用的开放(2) O_PATH标志)。
// - AT_SYMLINK_NOFOLLOW 如果由dirfd标识的文件和非空路径名是符号链接,则调用失败,错误为ELOOP
int ... |
C | /* This is a program in the book "The C Programming Language" by
* Brian W. Kernighan and Dennis M. Ritchie. Verify that the expression
* getchar() != EOF is 0 or 1.
*/
#include <stdio.h>
int main(void)
{
int c = getchar() != EOF; // This is apparently a valid expression
printf("%i\n", c);
return 0;
}
|
C | /*
* long lseek(int fd, long posn, int whence)
*
* 0 SEEK_SET from start of file
* 1 SEEK_CUR from current position
* 2 SEEK_END from end of file (always -ve)
*
* $Id: lseek.c,v 1.6 2013-06-06 08:58:32 stefano Exp $
*/
#include <fcntl.h>
#include <stdio.h>
#include <cpm.h>
long lseek(int fd,long posn, int when... |
C | /* Author: Vivek Prakash
* Date: Aug 3, 2011
*/
#include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <netdb.h>
#include <err.h>
#include <signal.h>
#define HTML 1
void catcher(int );
const c... |
C | #include "monty.h"
/**
* add_dnodeint - add a node at the initial of the linked list
*
* @head: pointer to pointer to the first node of the double linked list
* @n: value of the new_node
* Return: Always EXIT_SUCCESS.
*/
stack_t *add_dnodeint(stack_t **head, const int n)
{
stack_t *new_node;
if (!head)
retu... |
C | main()
{ int expr=2,j=1;
switch(expr)
{
case j://USE SINGLE QUOTES IN j='j'
printf("This is case 1");
case 2:
printf("This is case 2");
default:
printf("This is default case");
}
}
|
C | int main()
{
char a[201][30]={0},b='0';
int c[201]={0},i=0,j=0,n,p=0,q=100,x=0,y=0;
while((b=getchar())!='\n')
{
if(b!=' '&&b!=',')
a[i][j++]=b;
else {i++;j=0;}
}
n=i;
for(j=0;j<=n;j++)
c[j]=strlen(a[j]);
for(j=0;j<=n;j++)
{
if(c[j]>p)
{p=c[j];x=j;}
if(c[j]<q&&c[j]>0)
{q=c[j]... |
C | /*
* Ex_3.c
*
* Created on: Jul 31, 2021
* Author: Sarah
*/
#include <stdio.h>
int main(){
float num, max;
printf("Enter three numbers: ");
fflush(stdout);
scanf("%f", &num);
max = num;
for(int i = 1; i < 3; i++){
scanf("%f", &num);
if(num > max)
max = num;
}
printf("Largest number = %f", ma... |
C | /****************************************************************************
Copyright (C), 2013, Mingv150, All rights reserved
FileName: Drv_Shell.c
Description:
Author:
Version:
Changelog:
*****************************************************************************/
#define _Drv_Shell_C_
/*common header ... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* block_helpers.c :+: :+: :+: ... |
C | //
// test_vofb.c
// TP2-FileSystem-Malapel&Dhersin
//
// Created by jerome on 15/11/2015.
// Copyright © 2015 Malapel&Dhersin. All rights reserved.
//
#include <stdio.h>
#include "../header/alloc.h"
#include "../header/volume.h"
#include "../header/mbr.h"
#include "../header/inode.h"
int main(int argc, char **ar... |
C | #include "Pedido.h"
#include "Item.h"
#include "Cliente.h"
void inicializar_lista_pedido(lista_pedido *l){
l->inicio = NULL;
}
void adcionar_pedido_inicio(lista_pedido *l, pedido p){
no_pedido *novo = (no_pedido *) malloc (sizeof(no_pedido));
novo->proximo = l->inicio;
novo->dado = p;
l->inicio = novo;
}
... |
C | /**
* \file lwmem_init.c
* \brief lwmem init file
*/
/*
* Copyright (c) 2019 Tilen MAJERLE
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without restrictio... |
C | /*********************************************
Mega48
Version : 1.10
Date : 18.08.2006
LP : 08.06.2010
Author : ..
Company :
Chip type : ATmega48
Program type : Application
Clock frequency : 7.3728 MHz
*********************************************/
#include <Delay.h>
#include <stdlib.h>
#inc... |
C | #include "raycaster.h"
#include "texture_atlas.h"
#include <math.h>
#include <stdlib.h>
typedef struct ray {
LALGBR_Vec2d origin;
LALGBR_Vec2d direction;
} Ray;
typedef struct ray_hit {
LALGBR_Vec2d point;
LALGBR_Vec2d tile_pos;
char textureId;
float dist;
float uv;
char hit_fac... |
C | #include <stdio.h>
#include <string.h>
int main(int argc, char const *argv[])
{
char daftarNama[16][100] = {"muhammad", "rizal", "rifky", "sri"};
int i,j;
for(i=0; i<4; i++){
for(j=0; j<strlen(daftarNama[i]); j++){
printf("%c",daftarNama[i][j] );
}
printf("\n");
}
return 0;
} |
C | #include<stdio.h>
int main()
{
float r=0.09,p=1.0,n;
for(n=1;n<=10;n++)
p=p*(1+r);
printf("%f\n",p);
return 0;
} |
C | //
// TetrisBattlePlatform.c V1.10
// Main Management Module
//
// Created on 2014. 08. 21.
// Last Modified on 2014. 11.24.
//
// - debugging in correctError()
// - displaying the block stage in ending.
// Copyright(c) 2014 Nerrtica and STKim in CAUCSE. All rights reserved.
//
#include "tetrisbattle.h"
int main (... |
C | /* User LED is on PA0 */
/* This example generates a PWM waveform using TC0 in 16 bit mode.
* The PWM frequency is set to 1kHz and the duty cycle ramps from 0 to 100% (and straight back to zero again)
*
* It does not use timer interrupts.
*/
#include <stdint.h>
#include "../samd20e16.h"
#include "serial.h"
/*
How... |
C | // Physics.c
// Module for physics, collision, resolution of arbitrary physical objects.
// Created 5/10/05 by Nick Oakley.
#include <windows.h>
#include <math.h>
#include "Constants.h"
#include "ErrMsg.h"
#include "Vector.h"
#include "Physics.h"
#include "Collision.h"
// Globals
PHYSICS aPhysicsObjects[ MAX_NUM_PHYS... |
C | #include "holberton.h"
/**
* print_int - prints an integer
* @n: number to be printed
*
* Return: count of numbers printed
*/
int print_int(int n)
{
int count = 1;
unsigned int num = 0;
if (n < 0)
{
_putchar('-');
count++;
num = n * -1;
}
else
{
num = n;
}
if (num / 10)
{
count += print_int... |
C | #include "libmx.h"
unsigned long mx_retalp(char c) {
if (c == 'a' || c == 'A') {
return 10;
}
if (c == 'b' || c == 'B') {
return 11;
}
if (c == 'c' || c == 'C') {
return 12;
}
if (c == 'd' || c == 'D') {
return 13;
}
if (c == 'e' || c == 'E') {
return 14;
}
if (c == 'f' || c == 'F') {
return ... |
C | void enqueue(PROC **queue, PROC *p){
PROC *past;
PROC *temp;
past = *queue;
if (past == NULL || p->pri > past->pri){
p->next = past;
*queue = p;
return;
}
temp = past->next;
while (temp != NULL && temp->pri >= p->pri ){
past = past->next;
temp = temp->next;
}
past->next = p;
p->next = temp;
}
PROC... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* double_flags.c :+: :+: :+: ... |
C | #include <stdio.h>
int main()
{
printf("ð 5 30 Լ ð...\n");
printf(" . ֳϸ ڰ ұ ̴.\n");
printf(" 츮 б ֽ Ǯ Ͱ ϴ.\n");
printf("");
} |
C | /* Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License. */
#include <stdbool.h>
#include <errno.h>
#include <stddef.h>
#include <stdint.h>
#include "mt3620-gpio.h"
// The location of the DIN register depends on the type of block.
typedef enum {
GpioRegAdcDin = 0x04, // PAD... |
C | #include "km0/base/bitOperations.h"
#include "km0/device/boardIo.h"
#include "km0/device/debugUart.h"
#include "km0/device/digitalIo.h"
#include "km0/device/system.h"
#include <avr/io.h>
#include <stdio.h>
#include <util/twi.h>
//board pro micro
//PD1 I2C1_SDA <--> OLED SDA
//PD0 I2C2_SCL ---> OLED SCL
void __i2c_ini... |
C | /*
Travelling Salesman Problem.
Dynamic programming strategy:
1. Given vertices set = {1, 2, 3, 4,…,n} and assume starting point is 1.
(cost(i) = minimum cost for the path from 1 to i. The corrsponding cycle is cost(i) + dist(i, 1))
2. C(S, i) be the cost of the minimum cost path visiti... |
C | /* EDA_TPn1
Grupo n°4
Integrantes:
FRANCO LEON MORICONI
FRANCISCO MUSICH
GUIDO MARTIN PANAGGIO VENERANDI
FRANCISCO MARTIN TOLABA
En este programa se solicitó hacer un parseo de datos ingresados con un banco de pruebas
se prueba la función parsecmdl simulando mediante una matriz los datos que se ingresarían... |
C | #include <stdio.h>
int gcd(int a, int b)
{
while(a != b) {
if(a > b)
a = a - b;
else
b = b - a;
}
return b;
}
int main(void)
{
int a, b;
printf("Give me two numbers: ");
scanf("%d %d", &a, &b);
printf("GCD of %d and %d is: %d \n... |
C | /** @file mainGame.c
@author Hayley Krippner & Nitish Singh
@date 12 October 2020
@brief The main game module for 'Rock, Paper, Scissors' where the
players can play for the first to 3 games.
*/
#include "system.h"
#include "pacer.h"
#include "tinygl.h"
#include "ir_uart.h"
#include "../fo... |
C | /*
** EPITECH PROJECT, 2018
** PSU_42sh_2017
** File description:
** Unset one variable on the local env
*/
#include <stdlib.h>
#include <unistd.h>
#include "shell.h"
#include "instruction.h"
#include "execution.h"
static int display_unset_error(shell_t *shell, int fd)
{
char str[] = "unset: Too few arguments.\n";
... |
C | #include <stdio.h>
void pyramid( int n );
int main()
{
int n;
scanf("%d", &n);
pyramid(n);
return 0;
}
/* 你的代码将被嵌在这里 */
void pyramid(int N){
for (register int i = 1; i <= N; i++){
for (register int j = 0; j < N - i; j++) putchar(' ');
for (register int j = 0; j < i; j ++) printf("... |
C | #include<stdio.h>
int main()
{
int a,b,c,area,side;
while(2)
{
scanf("%d",&a);
if(a==0)
break;
scanf("%d %d",&b,&c);
area=(a*b*100)/c;
side=sqrt(area);
printf("%d\n",side);
}
}
|
C | #include <stdio.h>
#define size 50//50
void shift_element(int* arr, int i){
for(int j=0;j<i;j++){
*(arr+j) = *(arr+j+1);
}
}//
void swap(int* a, int* b){
int c = *a;
*a = *b;
*b = c;
}//
void insertion_sort(int* arr,int len){
int *min;
for(int i=0; i < len-1; i++){
min = arr+i;
for(int j=i; j < len; j++ ){
i... |
C | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
char *table[8][4] = {
{ "0", "4", "8", "12"},
{ "1", "5", "9", "13"},
{ "2", "6", "10", "14"},
{ "3", "7", "11", "15"},
{ "0", "5", "10", "15"},
{ "1", "6", "11", "12"},
{ "2", "7", "8", "13"},
{ "3", "4", "9", "14"},
};
const char ma... |
C | #include "container.h"
#include <stdio.h>
#include <stdlib.h>
Container* createContainer (int id, float peso){ // 2 Complexidade Espacial
Container* novoC = (Container*) malloc (sizeof (Container)); // 1 Complexidade Espacial, 1 Complexidade Temporal
if (novoC != NULL){ // 1 Complexidade Temporal
novoC->id = id; /... |
C | #include<stdio.h>
int add(int n, int *p);
int main(){
int n,i,a;
scanf("%d",&n);
int list[n];
for(i=0;i<n;i++)
scanf("%d",&list[i]);
a=add(n,list);
printf("%d",a);
}
int add(int n, int *p){
int a=0,i;
for(i=0;i<n;i++)
a+=p[i];
return a;
}
|
C | /*
Header: Library for getting 4-digit passcode input from the 4x4 keypad using an ATmega32a
Pins to be used:
Column pins: Column 1..4 -> pin C4..7 (pins 26..29)
Row pins: Row 1..4 -> pin D4..7 (pins 18..21)
The "validate_password()" and "detected_new_press()" functions will need to be
defined in the code ... |
C | #include<stdio.h>
int main()
{
int num,temp,sum,r;
for(num==1;num<=500;num++)
{
temp=num;
sum=0;
while(temp>0)
{
r=temp%10;
temp=temp/10;
sum=sum+(r*r*r);
}
if(sum==num)
printf("\nThe armstrong num... |
C |
#include <stdio.h>
/*function prototypes*/
int conj(int x, int y);
int disj(int x, int y);
int not(int x);
int mate(int x, int y);
int excl(int x, int y);
void testMonotone();
int main()
{
int part;
int t1,t2;
printf(" MENU OF BOOLEAN ALGEBRA \n");
printf("1.Conjunction\n2.Disjunction\n3... |
C | #define List_Linked
typedef int ListEntry;
#ifdef List_Linked
typedef struct listnode
{
ListEntry Entry;
struct listnode *next;
}ListNode;
typedef struct ListEntry
{
ListNode *head;
int size1;
}List;
#else
#define MAXSIZE 100
typedef int ListEntry;
typedef struct list1{
ListEntry entry[MAXSIZE];
int... |
C | #include "astroalgo.h"
#include "astromath.h"
#include "astrolabels.h"
/* C Headers */
#include <math.h>
#include <stdlib.h>
/*******************************************************************************
* AstroAlgo
*
* Universal Time (UT) -> Julian Day (JD)
* UT is also Greenwich Civil Time based on the rotation o... |
C | #include <stdlib.h>
#include <stdio.h>
int fseekf(void)
{
FILE *source, *error;
int c=0;
char file[20];
long pos = 0;
printf("Which file to open? > ");
scanf("%s", file);
fflush(stdin);
if( (source=fopen(file, "a+")) == NULL)
{
if( (error=fopen("testdata/error.log","a+")) != NULL )
{
fprintf(error, "... |
C | // 具体的多项式相乘,可参考polynomial.c.
// 但是这里需要进行修改.
// 还要多额外参考求幂的运算.
// 所以f ^ n,在n为偶数情况下,变为(f ^ (n / 2))^2,奇数情况下,(f ^ ((n - 1) / 2)) * f
|
C | #include <stdlib.h>
#include "quadface.h"
FaceList fl_newList()
{
FaceList list = malloc(sizeof(struct __FaceList));
list->head = NULL;
list->tail = NULL;
return list;
}
FaceNode fl_newNode()
{
FaceNode node = malloc(sizeof(struct __FaceNode));
node->next = NULL;
node->face = NULL;
return node;
}
Face* fl_ne... |
C | #pragma once
uint8_t translateKeyNumToLedNum(uint8_t btnGp, uint8_t keyNum)
{
// bounds
assert(btnGp < 3);
assert(keyNum < 22);
// overlap
if (keyNum > 10)
keyNum = keyNum - 11;
switch (btnGp)
{
case 2:
{
if (keyNum < 8)
return 92 + keyNum;
else
return 107 + keyNum; // 115 -> 118
}
case 1:
{
... |
C | #ifndef LIST_H
#define LIST_H
#include "container.h"
struct list
{
struct list* next;
struct list* prev;
};
static inline void list_init(struct list* list)
{
list->next = list;
list->prev = list;
}
static inline struct list* list_head(struct list const* list) { return list->next == list ? NULL : lis... |
C | #include "graphs.h"
/**
* depth_first_traverse - goes through graph using depth-first algorithm
* @graph: pointer to graph to traverse
* @action: pointer to function to be called for each visited vertex
* Return: biggest vertex depth or 0 on failure
*/
size_t depth_first_traverse(const graph_t *graph, void (*acti... |
C | /*----------------------------------------------------------------------/
/ Test if the file is contiguous /
/----------------------------------------------------------------------*/
FRESULT test_contiguous_file (
FIL* fp, /* [IN] Open file object to be checked */
... |
C | #include <stdio.h>
#include "count.h"
int main() {
int v[]={1,1,2,3,4,1};
int c=count(v,6,1);
printf("Contagem: %d\n",c);
return 0;
}
|
C | #include "EditDistance.h"
#include <stdlib.h>
int minDistance(char *word1, char *word2)
{
if (word1 == NULL || word2 == NULL) return -1;
int len1 = 0, len2 = 0;
int i = 0, j = 0, tempmin;
while (word1[len1++] != 0);
while (word2[len2++] != 0);
int (*mindis)[503] = (int (*)[503])m... |
C | /**************************************************************
1563번
jongtae0509
C
정확한 풀이코드 길이:437 byte(s)
수행 시간:0 ms
메모리 :1120 kb
****************************************************************/
#include <stdio.h>
int n, m, x;
int max(int p, int q){ return p>=q?p:q;}
int min(int p, int q){ return p<q?p:q;}
int ... |
C | #include<stdio.h>
#include<stdlib.h>
int c;
int minm(int m,int n)
{
return (m<n ? m : n);
}
int gcd(int m,int n)
{
int r,x,y;
y=minm(m,n);
x=m+n-x;
m=x;
n=y;
while(m%n)
{
r=m%n;
m=n;
n=r;
}
return n;
}
int main()
{
int t,a,b,x,y;
scanf("%d",&t)... |
C | #include "seahorn/seahorn.h"
extern int nd();
typedef struct T {
int val;
} T;
int main() {
T x = {11};
T y = {22};
T *z = nd() ? &x : &y;
z->val += 33;
// here `z` dies and the permission should "go back" to `x` or `y`
x.val += 44;
y.val += 44;
sassert(x.val == 88 || x.val == 55);
sassert(y.va... |
C | #include<stdio.h>
#include<conio.h>
void main()
{
int a[4][4]={{4,2,0,1},{3,1,2,5},{3,2,1,4},{5,2,6,7}};
int b[4][4]={{2,1,3,2},{5,4,2,3},{1,4,0,2},{3,2,4,1}};
int mul[4][4],add[4][4],atrans[4][4];
int i,j,k,ii,jj,sum1[2][2],sum2[2][2];
clrscr();
printf("Matrix Operation\n");
printf("Matrix Addition is:-\n");
f... |
C | #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
int main() {
char *cmd[] = {"who", "ls", "date"};
int i;
while( 1 ) {
printf("0=who 1=ls 2=date : ");
scanf("%d", &i);
if(fork() == 0) {
/* child */
execlp( cmd[i], cmd[i], (char *)0 );
printf("exe... |
C | #include<stdio.h>
#include<stdlib.h>
int fact(int n)
{
if(n==1)
return n;
n=n*fact(n-1);
return n;
}
int fibo(int n)
{
if(n==0)
return 0;
else if(n==1||n==2)
return 1;
else
n=fibo(n-1)+fibo(n-2);
return n;
// or
//return (fibo(n-1)+fibo(n-2));
}
int pw(int b,int p)
{
}
int main()
{
int n,arr[4];
p... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include "ip_query.h"
static void iq_split_name_value(char *line, char **name, char **value);
static char *iq_get_addr(char **pvalue);
static void iq_pton_addr(char *pres, unsigned int *addr, unsigned int *bits);
iq_database_t *
iq_da... |
C | #include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "KeyExpansion.h"
#include "ShiftRows2.h"
#include "AddRoundKey3.h"
#include "SubBytes2.h"
#include "MixColumns.h"
#include "cipher.h"
/*
void cipher32b(const uint32_t *in, uint32_t *out, const struct expKey32 *ekey){
struct state2 s;
for(int i=0; i... |
C | /* Copyright 2016 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include "cras_alsa_ucm_section.h"
#include "cras_alsa_mixer_name.h"
#include "utlist.... |
C | #include <stdio.h>
int power(int x, int n);
int main(void) {
int x, n;
printf("Print the values of x and n seperated by commas: ");
scanf("%d,%d", &x, &n);
printf("your value is %d\n", power(x, n));
}
int power(int x, int n) {
int value = 0;
int x1 = x;
int n1 = n;
if (n1 == 0) {
return 1;
}
i... |
C | #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int globvar = 10;
int main() {
int var = 100;
pid_t pid;
printf("before fork buffer ");
pid = fork();
if (pid == 0) {
//子进程修改变量
++globvar;
++var;
} else if (pid > 0) {
//父进程 sleep 保证子进程先输出
sleep... |
C | /*
输入一个单向链表,输出该链表中倒数第k个结点,链表的倒数第1个结点为链表的尾指针。
链表结点定义如下:
struct ListNode
{
int m_nKey;
ListNode* m_pNext;
};
正常返回倒数第k个结点指针,异常返回空指针
本题有多组样例输入。
输入描述:
输入说明
1 输入链表结点个数
2 输入链表的值
3 输入k的值
输出描述:
输出一个整数
示例1
输入
复制
8
1 2 3 4 5 6 7 8
4
输出
复制
5
*/
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n = ... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/time.h>
#include "stack.h"
#define MAX_CHARS 100
#define WORKERS 4
extern char *strtok_r(char *, const char *, char **);
struct ReaderArgs
{
Stack *string_stack;
pthread_mutex_t *string_stack_mu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.