language large_stringclasses 1
value | text stringlengths 9 2.95M |
|---|---|
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdbool.h>
#include "../common/global.h"
#include "cpu.h"
#ifdef ARCH_X86
#include "../x86/uarch.h"
#include "../x86/apic.h"
#elif ARCH_PPC
#include "../ppc/uarch.h"
#elif ARCH_ARM
#include "../arm/uarch.h"
#endif
#defin... |
C | #include <stdio.h>
int main(void)
{
int p[] = {[5]=6};
printf("ֽڳΪ");
printf("%lu\n",sizeof p);
printf("ÿֽͳΪ");
printf("%lu\n",sizeof (int));
printf("Ϊ");
printf("%lu\n",sizeof (p) / sizeof (int));
}
|
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_expand.c :+: :+: :+: ... |
C | /*
<Reference>
Title : A High-speed Masking Method to protect ARIA against Side Channel Analysis
Written By : HeeSeok Kim, Tae Hyun Kim, Jeong-Choon Ryoo, Dong-Guk Han, SeokHie Hong
Graduate School of Information Management and Security, Korea University,
Electronics and Telecommunications Research Institute
*/
/*
<논문 ... |
C | #include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h> //bzero
#define bool int
#define true 1
#define false 0
typedef struct Trie{
bool isEnd;
struct Trie *children[26];
} Trie;
/** Initialize your data structure here. */
Trie* trieCreate() {
Trie *ret = malloc(sizeof(Trie));
... |
C | #include <stdio.h>
#include <string.h>
#define N 100000
char n[N + 1], bg[N + 5], eq[N + 5];
int cntb, cnte, st, flag, cntb4, cnte4, finallen, finallen, len;
void gogogo(char x)
{
if(x == '4' || x == '7') {
if(x == '4' && 2 * (cnte - cnte4) < len) {
finallen = len;
st = cnte;
bg[cntb = 0, cntb++] = '7';
... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <semaphore.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
struct persona{
char nombre[20];
char ocupacion[20];
int edad;
};
struct archivo{
struct persona registros[100];
int cant;
};
i... |
C | /*
** EPITECH PROJECT, 2019
** my_getnbr_v2.c
** File description:
** This file contains a function that do the same things
** that the normal my_getnbr but also verify if their is an error.
*/
#include <unistd.h>
#include "samson.h"
int my_getnbr_v2(char const *str, int *error)
{
int number = 0;
int index = ... |
C | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
time_t *timep = NULL;
char* gettime(){
if(timep == NULL){
timep = malloc(sizeof(time_t));
}
time(timep);
char *s = ctime(timep);
s[strlen(s)-1] = '\0';
return s;
}
#define __DEBUG__
//#undef __DEBUG__ //屏蔽此行 放开调试
#ifdef __DEBUG__
#defi... |
C | /*----------------------------------------*
* Random String Copy/Paste Speed tests *
*----------------------------------------*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include "../../Library/clipboard.h"
#define NTESTS 10
/*Defaults to 100MB*/
#define ... |
C | #include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
pid_t pid = vfork();
int num = 0;
switch(pid)
{
case -1:
printf("vfork fail\n");
break;
case 0:
printf("child:%d\n", getpid());
close(STDIN_FILENO);
printf("hase closed STDIN_FILENO\n");
_exit(EXIT_SUCCESS);
... |
C | #include <stdio.h>
#include <math.h>
#include <stdbool.h>
bool isPrime(int number)
{
for(int i = 2; i <= sqrt(number); ++i)
{
if(number % i == 0)
return false;
}
return true;
}
int main()
{
for(int i = 1; i <= 100; ++i)
{
if(isPrime(i))
printf("%d ", i);... |
C | #include "std.h"
int found;
reset(arg) {
if(!arg)
set_light(1);
found = 0;
}
object mimic;
int level, wc, ac;
string short, name, long;
init() {
if(!present("qstob", this_player())) {
write("You did not go by the right paths!\n");
move_object(this_player(), "/room/church");
return 1;
... |
C | #include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE *quelle;
int c;
char datei[20];
fpos_t pos;
printf("Welche Datei wollen Sie oeefnen : ");
scanf("%s", datei);
if((quelle=fopen(datei, "r")) == NULL){
fprintf(stderr, "Konnte %s nicht oeffnen !!\n", datei);
return EXIT_FAILURE;
}
// fseek(quel... |
C | #include <stdio.h>
int main()
{
float saA, saB, saC, temp;
char salesCode, buff;
saA = saB = saC = temp = 0;
do {
printf("Introducir el monto de la boleta (0 para finalizar): ");
scanf("%f", &temp);
// Fix to clean buffer
scanf("%c", &buff);
if (0 != temp) {
printf("Introduce el codigo del vendedor (A... |
C | #include<stdio.h>
int main()
{
int n;
printf("Enter a number :");
scanf("%d",&n);
int z;
z=0;
int y=2;
while(y<=n/2)
{
if(n%y==0)
{
z=1;
break;
}
y++;
}
if(z==1)
{
printf(" not prime number");
}
else
{
printf("prime number");
}
return 0;
}
|
C | #include <stdio.h>
#include <stdlib.h>
int main(void){
printf("int *i = malloc(sizeof(int)); //right\n");
int *i = malloc(sizeof(int));
printf("*i = 23; //right\n");
*i = 23;
printf("int *j = 23; //wrong\nwill give a complier warning\n");
printf("warning: incompatible integer to pointer conversion initializing\n... |
C | /**
* TCP Client
*
* @author Sebastian Menski (734272) <menski@uni-potsdam.de>
* @author Martin Ohmann (734801) <ohmann@uni-potsdam.de>
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <stdlib.h>
#include <sysexits.h>
... |
C | #include "pub/osl/inc/osl_timer.h"
#include "sdk_timer.h"
static int timerHandle = -1;
static int count = 0;
static unsigned int timerProc(void *p)
{
// This timer callback function will be executed every second, in the timer thread.
// You can do some short-term operations here,
// but don't block it all the tim... |
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: 0783170
*
* Created on 31 de Agosto de 2017, 09:32
*/
#include <stdio.h>
#include <stdlib.h>
/*
... |
C | #include "all.h"
void erase(LIST start, int a)
{ int result=0;
result=delete(start,a);//calling delete function to delete the numbe
if(result==0)//function will return 0 if it did not found the number in the list
{ printf("NODE NOT FOUND\n");
}
if(result==1)//function wil return 1 if it is ... |
C | #ifndef _BUFFER_H
#define _BUFFER_H
#include <stdint.h>
#define BUFFER_SIZE (1024)
/**
* Allocate a piece of the dynamic memory buffer.
*
* A buffer allocated this way is valid until all dynamic buffers are
* flushed using buffer_release_all().
*
* @param length amount of bytes to allocate. For aligment reason... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ftp.c :+: :+: :+: ... |
C | /*
* =====================================================================================
*
* Filename: http_download.h
*
* Description: HTTP下载器
*
* Version: 1.0
* Created: 2014年05月28日 12时09分14秒
* Revision: none
* Compiler: gcc
*
* Author: 聂汉子 (niehanzi), n... |
C | /*Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.
Note:
The length of both num1 and num2 is < 5100.
Both num1 and num2 contains only digits 0-9.
Both num1 and num2 does not contain any leading zero.
You must not use any built-in BigInteger library or convert the i... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "primality_test.h"
#define NUMERO_COMPOSTO 0
#define NUMERO_PRIMO 1
#define DEBUG 1
int main(int argc, char *argv[]) {
char *mode = argv[1];
if (!strcmp(mode, "deterministico")) {
int64 n = (int64) atoi(argv[2])... |
C | /// \file main.h
/// ESTC 5-th laboratory work (example).
#include "main.h"
/// \brief onboard help LEDs
u16 onboard_leds[3];
/// \brief current color
u8 color;
/// \brief colors
u8 red, green, blue;
/// \brief debounce params
u32 systime, timeout_color, timeout_brightness;
/// \brief Entry point
int main(void)
{
... |
C | #include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <functional>
int main()
{
std::vector<int> v{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int sum = std::accumulate(v.begin(), v.end(), 0);
int product = std::accumulate(v.begin(), v.end(), 1, std::multiplies<int>());
auto da... |
C | /*************************************************************************
> File Name: commom.c
> Author:yangkun
> Mail:yangkungetit@163.com
> Created Time: Wed 20 Dec 2017 02:27:34 PM CST
************************************************************************/
#include"commom.h"
key_t getkey()
{
key_t k... |
C | #include<stdio.h>
void computeArray1(int a[], int b[], int n)
{
int i, j, product=1;
for (i = 0; i < n; i++){
for (j = 0; j < n; j++)
{
if(i!=j && a[j]!=0) product *= a[j];
}
b[i] = product;
}
}
void computeArray2(int a[], int b[], int n)
{
int product = 1, i;
for (i = 0; i < n; i++)
if(a[i] !=0)... |
C | #include <stdio.h>
int main()
{
int numero;
char resposta;
scanf("%d", &numero);
if (numero % 5 == 0)
{
resposta = 'S';
}
else
{
resposta = 'N';
}
printf("%c\n", resposta);
return 0;
} |
C | /*
** EPITECH PROJECT, 2021
** bsqRematered
** File description:
** step_checking
*/
#include "../../../includes/bsq_func.h"
static ksize_t get_curr_max_size(bsq_manager_t *manager, ksize_t x, ksize_t y)
{
ksize_t max_x = length(manager->square[0]) - x;
ksize_t max_y = length_text(manager->square) - y;
i... |
C | #ifndef SEM_H
#define SEM_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/sem.h>
#include <unistd.h>
struct semun
{
int val;
struct semid_ds *buf;
ushort *array;
};
static int semid = 0;
void initsem(key_t key,int nsems)
{
semid = semget(key,nsems,IPC_CREAT | IPC_EXCL| 060... |
C | #include<stdio.h>
int main(void) {
int i;
for(i=1; i<101; i++) {
//print num if not divisible by 3 or 5
if ( i%3 != 0 && i%5 != 0 ) printf("%i",i);
//print fizz if divisible by 3 and buzz if divisible by 5
else {
if ( i%3 == 0 ) printf("fizz");
if ( i%5 == 0 ) printf("buzz");
}
//new line for ea... |
C | #include "bmp.h"
#include <stdio.h>
#include <stdlib.h>
size_t getGap1Size(BMP* image) {
return image->bmpFileHeader->bfOffBits - sizeof(BITMAPFILEHEADER) - sizeof(BITMAPINFO);
}
size_t getPadding(BMP* image) {
return ((4 - image->bmpInfo->biWidth % 4) % 4);
}
size_t getPixelDataSize(BMP* image) {
return... |
C | #include<stdio.h>
#include<stdlib.h>
#include<argz.h>
#include<string.h>
#include<regex.h>
#include"gen_cmd.h"
/* Private functions prototypes */
static int match_command_parse(const struct commands_t*, const char*, int*, size_t, regmatch_t*);
static void show_match(const char* cmd, size_t nmatch, regmatch_t* pmatch);... |
C | #include <cs50.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(int argc, string argv[])
{
string girilecek_metin;
string key = (argv[1]);
if (argc != 2)
{
printf("Usage: ./vigenere keyword\n");
return 1;
}
int donusturulmus[strlen(key)];
//BIRINCI DONG... |
C | /* inimgrSave.c */
#include "inimgr_types.h"
int inimgrSave( InimgrUID uid, const char *path, const char *sig, InimgrVersion version )
{
struct inimgr_entry *entry;
struct inimgr_context ctx = {
(struct inimgr_params *)uid,
NULL,
INIMGR_OP_SAVE,
};
int ret = CG_ERROR_OK;
//if( CG_IS_VALID_UID( ctx.para... |
C | // User-defined function line v2
#include <stdio.h>
void line(int length, char ch)
{
int i;
for(i = 1; i <= length; i ++)
putch(ch);
}
void main()
{
starline(25);
printf("\nSrikanth Technologies\n");
line(10,'-');
printf("\nWhere Quality Matters\n");
line(50,'=');
}
void s... |
C | /*
* Student name: Minh Ha, UCSD student ID U07470714
* Email address: hahongminh@gmail.com
* Course: C/C++ Programming I, Section ID 118011, instructor: Raymond Mitchell.
* Date: 11/07/2016.
* Name of this file: C1A6E1_main.c
* Operating system: Windows 7.
* Compiler & version: Visual C++ 2010.
*
* This progr... |
C | #include "gs.h"
#include "sistLinear.h"
#include <math.h>
#include <stdio.h> //RETIRAR DEPOIS
#include <sys/time.h>
// Retorna tempo em milisegundos
double timestamp(void)
{
struct timeval tp;
gettimeofday(&tp, NULL);
return((double)(tp.tv_sec*1000.0 + tp.tv_usec/1000.0));
}
double normaAprox(double *Xold, dou... |
C | // Used sample codes from October 12th discussion section.
// Lawrence Lim
// Perm: 4560892
/* Creates a datagram server. The port
number is passed as an argument. This
server runs forever */
#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <... |
C | #include<stdio.h>
#include<stdlib.h>
int main (void)
{
float n1, quadrado;
printf ("Digite um numero: \n");
scanf ("%f", &n1);
quadrado= n1*n1;
printf ("O resultado do quadrado do numero eh = %.f\n", quadrado);
system ("pause");
return (0);
}
|
C | /*
* file main.c
* brief programme d'analyse des mcanismes de gestion de la pile
* author
*/
/*
* program entry point
*/
int main(void){
/* pushl %ebp : sauvegarde le contexte de la fonction appelante
movl %esp, %ebp : prparation l'allocation de ressources mmoire
pour le contexte de la fonction courante ... |
C | #include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main(int argc, char** argv){
char *path;
DIR* dp;
struct dirent* dentry;
struct stat buf;
char *ptr;
if(argc==1) path = ".";
else if(argc==2){ path = argv[1]; chdir... |
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<stdio.h>
int main()
{
char str[100],rev[100];
int i=0,len=0,pal=0;
scanf("%s",str);
while(str[i]!='\0')
{
len++;
i++;
}
i=0;
if(str[i]!=str[len-1])
printf("-1");
else
{
while(str[i]!='\0')
{
if(str[i]=='.')
{
if(str[i+1]!='a')
str[i]=str[i+1]-1;
else
str[i]=st... |
C | /*
** left_key.c for 42sh in /home/hurlu/PSU_2015_42sh/src/line_edit
**
** Made by Hugo Willaume
** Login <willau_h@epitech.net>
**
** Started on Sat Jun 4 14:16:54 2016 Hugo Willaume
** Last update Sun Jun 5 23:05:57 2016 Hugo Willaume
*/
#include <curses.h>
#include <string.h>
#include <unistd.h>
#include <std... |
C | #include "multitask.h"
#include "memory.h"
#include "vga.h"
#include "interrupt.h"
#define STACK_SIZE 2*1024*1024
struct Process *curr_proc, *next_proc;
struct Process dummy_process = { .nextProc=&dummy_process, .prevProc=&dummy_process };
struct Process *all_procs = &dummy_process;
struct ProcessQueue readyQueue = ... |
C | #include <stdlib.h>
#include <stdio.h>
#include "node.c"
#define INF 2147483647 //Maior valor que um inteiro pode assumir.
int main() {
int count = 0;
int total = 0;
int largest = -1*(INF-1);
int i;
Node *nodes = NULL;
while( (scanf("%d",&i) == 1 )) {
nodes = makeNode(i, nodes);
if( i > largest) largest = ... |
C | // Copyright 2017.||
// author||
// ָ
#include <stdio.h>
void func(float** p);
void func1(float** p);
void func2(float** p);
int main(int argc, char* argv[])
{
int i;
int j;
float* p[3];
float score[3][4] = {{65, 67, 70, 60}, {80, 87, 90, 81}, {90, 99, 100, 98}};
for (i = 0; i != 3; ++i)
{
... |
C | #include <stdio.h>
int
main(void){
int a=10;
int *p;
/*int *p=(int *)0xDEADBEEF;//PASSING AN ADDRESS MANUALLY TO THE POINTER*/
printf("adress1 of p is : %p\n",p);
/*printf("value of a is : %i\n",*p);// will fail since we try to acess that mem which we are not supposed to access*/
p=&a;
printf("adress2 of p is... |
C | #include <stdio.h>
#include <stdlib.h>
#define NELEMS(a) ((int)(sizeof(a) / sizeof(a[0])))
#define DUMP(n) printf(#n " has %d elements\n", NELEMS(n))
int main(void) {
int i[42], *p = i;
DUMP(i);
DUMP(p);
return 0;
}
|
C | /*
* SIGNALS
* HUP - SIGHUP - handing the process
* INT - SIGINT (ctrl-c) - interruption the process
* TERM - SIGTERM - finish
* USR1, USR2
*
* int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
* */
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h> /... |
C | /* ************************************************************************** */
/* LE - / */
/* / */
/* get_next_line.c .:: .:/ . .:: ... |
C | #include <stdio.h>
enum operaciones { SUMAR = 1, RESTAR, DIVIDIR, MULTIPLICAR };
void menu();
int main(int argc, char const *argv[]) {
enum operaciones operacion;
float operador1, operador2;
do {
menu();
printf("Seleccione una operación 1-4: ");
scanf("%d", &operacion);
... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
FILE *pfile;
char cDate[5], cTel[20], cBuf[80];
if((pfile=fopen("message.txt","r+"))==NULL) {
printf("message.txt ɮLk}");
system("pause"); return(0);
} //}ҧsɮ
while( !feof(pfile) ) { // ɮתe
fgets(cBuf,80,pfile);
printf("%s",cBuf... |
C | #include<p24Fxxxx.h>
#include"i2c.h"
#include"delay.h"
#define STA311B_ADDR_WR 0x40
#define STA311B_ADDR_RD 0x41
void I2C_Init()
{
//I2C1CONbits.I2CEN=1;//
//I2C1BRG=0x4f;//100KHZ
I2C3CONbits.I2CEN = 1;
I2C3CONbits.ACKEN = 1;
I2C3BRG = 0x9D;//100KHZ Fcy=16Mhz
}
void I2C_Start()
{
I2C3CONbits.SEN=1... |
C | //
// main.c
// d1
//
// Created by Slava Gubar on 01.02.2021.
//
#include <stdio.h>
#include "math.h"
//#include <string.h>
//#include <memory.h>
#include <stdlib.h>
int main(int argc, const char * argv[]) {
int y = 0;
int a = 5;
int *b = &a;
int *k = NULL;
if (k != NULL) {
int bk = *k;
}
int c = *b;
... |
C | #include "variadic_functions.h"
#include <stdio.h>
/**
* print_numbers - prints numbers, followed by a new line
* @separator: pointer to char
* @n: unsigned int
* Return: 0
*/
void print_numbers(const char *separator, const unsigned int n, ...)
{
va_list num;
unsigned int i;
va_start(num, n);
for (i = 0; i <... |
C | // Rattle Sort
//
// Altering Bubble Sort to be O(n log n) time complexity for the best, worst, and average cases.
//
// Author: Stew Forster (stew675@gmail.com) Date: 19th July 2021
//
// Essentially a bi-directional comb-sort but with an algorithmically optimal step progression.
// Comb-sort tops out at a 1.3x ra... |
C | #include <stdio.h>
#include <string.h>
main(){
int n, test,i,j, cont=0;
char pomekon[1000][1000];
scanf("%d",&n);
getchar();
for(i = 0; i < n; i++){
gets(pomekon[i]);
test = 1;
for(j = 0; j < i;j++){
if(strcmp(pomekon[j],pomekon[i]) == 0){
test = 0;
break;
}
}
if(test == 1... |
C | #include "sys/mem_allocator.h"
#include "sys/ref_count.h"
#include "sys/sys.h"
#include "window_manager/glfw/wm_glfw_device_c.h"
#include "window_manager/wm.h"
#include "window_manager/wm_device.h"
#include "window_manager/wm_window.h"
#include <GL/glfw.h>
#include <assert.h>
#include <limits.h>
#include <stdlib.h>
st... |
C | #include<stdio.h>
#define cat(x,y) x##y
int main(){
//cat(cat(1,2),3);
printf("Output :%d", cat(2,3));
printf("Output2 :%d", cat(1,cat(2,3)));
}
|
C | /* -----------------------------------------------------
* ALF Backend testsuite
* Author: Benedikt Huber <benedikt@vmars.tuwien.ac.at>
*
* pointer1: Pointer Initialization
* -----------------------------------------------------
*/
struct s1_sub {
short lo;
short hi;
};
struct s1 {
char a;
short b;
... |
C | #include <stdio.h>
#include <winsock2.h>
#define BUFFSIZE 1024 // TCP仺С
#define TCPQUEUECOUNT 2 // TCPŶӵ
#pragma comment(lib, "ws2_32.lib")
//ϢreturnԷصϢ
char *TPC_Client_Send_and_Recv(char *buf1, int bufLen1, const char *ip, const int port) {
WSADATA wsadata;
if (WSAStartup(MAKEWORD(2, 2), &wsadata) != 0)
... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include "node.h"
final_node * next_level(final_node *node);
int main() {
arr_elem root = {.filename = "/", .is_dir = 1, .size = 0};
final_node root_fs = {.child_count = 1, .fs_elements = &root, .next_sibling = &root_fs, .parent... |
C | #include <stdio.h>
#include <math.h>
float squareroot (float a, float b, float c);
float mian(){
float a,b,c,d;
printf("\n\t ************* ************* ************* ************* *************\n");
printf("\t Type in 3 values foe a,b and c. Type Enter after each input.\n");
printf("\t The square root ... |
C | /*
reads data from a given collection of pages in collection.txt
and generates an "inverted index" that provides a list (set) of
urls for every word in a given collection of pages.
You need to "normalise" words by removing leading and trailing spaces
and converting all characters to lowercases before inserting words ... |
C | #include <stdio.h>
#include <stdlib.h>
int main(void) {
char character[] = "ٶٻīŸ";
int inputnum;
int ch;
FILE* f;
f = fopen("character.txt", "wt");
/*for (int i = 0; i < strlen(character);) {
fputc(character[i++], f);
fputc(character[i++], f);
}
puts("Է ϷǾϴ.\n");
fclose(f);
FILE * f = fopen("character... |
C | #include "stdio.h"
// binary search
int search(int a[], int l, int r, int val) {
if(l > r) return -1;
if(r - l < 2) return a[l] == val ? l : a[r] == val ? r : -1;
int mid2 = (l + 2*r)/3, mid1 = (2*l + r)/3;
if(a[mid1] >= val) return search(a, l, mid1, val);
if(a[mid2] <= val) return search(a, mid2,... |
C | //The second solution for the problem passes the 2 second barrier easily.
//This solutions gets TLE for the last test case
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#define li long int
#define lli long long int
#define setZ(x) memset(x, 0, sizeof(x));
#define givemem(t, n) (t*)malloc(sizeof(t) * (n))
#... |
C | // ENCONTRAR EL MAYOR NUMERO DE UN VECTOR/ARRAY
/* Realizar un algoritmo que permita la carga de 5 numeros en un vector. Una vez cargados debe determinar cual es el mayor
de ellos. */
#include <stdio.h>
main()
{
// SET UP VARIABLES
int nums[5] = {12, 50, 73, 84, 16};
int mayor = -192000;
int ctr;
... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf_x_utils.c :+: :+: :+: ... |
C | #include <stdio.h>
#include <time.h>
int recursFib(int n)
{
if (n > 25)
{
return -1;
}
if (n < 2)
{
return n;
}
return recursFib(n - 1) + recursFib(n - 2);
}
int iterateFib(int n)
{
if (n > 46)
{
return -1;
}
int a = 0, b = 1, c;
for (int i = 0; i < n; i++)
{
c = a;
a = a + b;
b = c;
}
retur... |
C | #include <unistd.h>
#include <stdio.h>
#include <sqlite3.h>
#include "macro.h"
#include "db.h"
void print_sql_error(sqlite3* db, int rc) {
DEBUG("SQL Code: %i, %s\n", rc, sqlite3_errmsg(db));
}
int create_table(sqlite3* db, const char* sql_stmt) {
sqlite3_stmt* stmt = NULL;
int rc = sqlite3_prepare_v2(db, sql_st... |
C | /*
write a c program that takes 4 numbers from user and
swap it between num1 & num2, num3 and num4.
*/
#include<stdio.h>
void main()
{
float num1, num2, num3, num4, temp1, temp2;
printf("Enter number1: ");
scanf("%f", &num1);
printf("Enter number2: ");
scanf("%f", &num2);
p... |
C | /*--------------------------------------------------------------------------
* headers à inclure afin de pouvoir utiliser divers appels systèmes
* -----------------------------------------------------------------------*/
#include <stdio.h> /* pour printf() and co */
#include <stdlib.h> /* pour exit() */
#include <err... |
C | #include <stdio.h>
// Method 1
typedef struct _Location {
int x;
int y;
} Location; // <- ALWAYS remember to put a semicolon here.
// Over here, i combined the struct declaration and typedef statement. This is probably the way of declaration you will be using the most, but practice caution when you do so. In ... |
C | //Definicao da estrutura aluno
typedef struct aluno {
int id;
char nome[20];
char email[40];
int idade;
char status;
} aluno;
//Definicao dos prototipos das funcoes
aluno * recebeInfoAluno(int id);
node * cadastrarAluno(node *raiz, int *id);
node * removerAluno(node *raiz);
void exibirListaAlunos(nod... |
C | #include <stdio.h>
#include <stdlib.h>
char Reverse_String(char string[]) {
int ret = sizeof(string) / sizeof(string[0]);
for (int i = 1; i <= ret; i++) {
return Reverse_String;
}
}
int main() {
int i;
char string[] = "abcd";
printf("%c\t", string[i]);
system("pause");
return 0;
} |
C | // Header for platform independant serial communications
//
// senseitg@gmail.com 2012-Nov-26
#include <stdint.h>
#include <stdbool.h>
// enumerate serial devices
// fp_enum is callback to receive each device
void senum(void (*fp_enum)(char *name,char *device));
// open serial port
// device has system dependant for... |
C | #include "led.h"
#include "delay.h"
#include "sys.h"
#include "usart.h"
#include "oled.h"
#include "csb.h"
u32 Distance;
float m1,m2;
void Display(void);
int main(void)
{
delay_init(72); //ʱʼ
uart_init(72,9600); //ڳʼΪ9600
LED_Init(); //ʼLEDӵӲӿ
OLED_Init();
OLED_Clear();
TIM3_Cap_Init(0X... |
C | /*
** peephole optimizer
**
** basically a simple text replacement processor
*/
char nooptimize = 0; /* this flag disables optimization if set (by debug) */
peephole(ptr) char *ptr; {
while(*ptr) {
char *ptr1;
ptr1 = ptr; /* save for later compare */
/*
** if optimization is disabled,... |
C | #include <zephyr.h>
#include <device.h>
#include <drivers/gpio.h>
#include "log.h"
#include "backlight.h"
#define LED_PORT DT_ALIAS_LED1_GPIOS_CONTROLLER
#define LED DT_ALIAS_LED1_GPIOS_PIN
struct device* backlight_dev;
static bool backlight_enabled = false;
void backlight_init(void)
{
LOG_DB... |
C | /*
-------------------------------------
Author: Anshul Khatri
ID: 193313680
Email: khat3680@mylaurier.ca
Version 2020-07-29
-------------------------------------
*/
#ifndef GRAPH_H_
#define GRAPH_H_
#include "graph_components.h"
#define BLOCK 5
#define True 1
#define False 0
typedef struct {
int **matrix... |
C | #include <stdio.h>
#include<stdlib.h>
int verifica(int vetA[], int tamA, int vetB[], int tamB){
int i, j;
for (i = 0 ; i < tamA ; i ++)
for(j = 0; j < tamB ; j++)
if (vetA[i] == vetB[j])
printf("%d, ", vetA[i]);
}
int main(){
int A[] = {1, 3, 5, 7, 9, 11, 13, 15... |
C | #include "fix_p_num.h"
const fix_p_num fix_max = {
FIXMAX,
IWL_LIMIT
};
const fix_p_num fix_min = {
FIXMIN,
IWL_LIMIT
};
const fix_p_num one = {
0x40000000,
1
};
const fix_p_num zero = {
0,
1
};
void fix_p_num_min_int_len(fix_p_num* x) {
unsigned int mask = 0x40000000;
if (x... |
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 "ping.h"
struct proto proto_v4 = { proc_v4, send_v4, NULL, NULL, 0, IPPROTO_ICMP };
#ifdef IPV6
struct proto proto_v6 = { proc_v6, send_v6, NULL, NULL, 0, IPPROTO_ICMPV6 };
#endif
int datalen = 56; /* data that goes with ICMP echo request */
int maxdatalen = 65507;
int main(int argc, char **ar... |
C | /**
@file interrupt.c
@brief This file contains all interrupts.
*/
/*
* interrupt.c
*
* Created on: May 24, 2018
* Author: ga76jid
*/
#include <util/delay.h>
#include "interrupt.h"
#include "io.h"
#include "timer.h"
/**
This function activates interrupts on the provided pin.
*/
void config_rx_int(vo... |
C | #include "polynomialRegression.h"
#include "stdio.h"
#include "stdlib.h"
#include "assert.h"
#include "math.h"
void multiplyMatrices(int n, int y, int z, double firstInput[n][y], double secondInput[y][z], double output[n][z]){
for(int i = 0; i < n; i++){
for(int j = 0; j < z; j++){
double dotProduct = 0;
... |
C | /*
Give the 3rd dimension (N) of the array: 5
The matrix is :
a b c d e
f g h i j
k l m n o
p q r s t
b c d e f
g h i j k
l m n o p
q r s t u
c d e f g
h i j k l
m n o p q
r s t u v
*/
#include <stdio.h>
#include <stdlib.h>
int main(){
char *array[3][4];
int i, j, k, N;
char input[12];
char gramma = 'a';
pr... |
C | #include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include "trabajo.h"
#include "servicio.h"
#include "marca.h"
#include "color.h"
#include "fecha.h"
#include "auto.h"
int inicializarTrabajos(eTrabajo trabajo[], int tamT)
{
int error = 1;
if(trabajo != NULL && tamT > 0)
{
... |
C | /* SPDX-License-Identifier: GPL-2.0 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
int main(void)
{
char *const target = realpath("./signal", NULL);
const struct test {
const c... |
C | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include "mpi.h"
#include "functions.h"
int main (int argc, char **argv) {
MPI_Init(&argc,&argv);
int rank, size;
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
MPI_Comm_size(MPI_COMM_WORLD,&size);
//seed value for the randomizer
double ... |
C | #include<stdio.h>
#include<conio.h>
void main()
{
int a;
printf("enter the number");
scanf("%d",&a);
if(a>0)
{
printf("%d is positive",a);
}
else if(a==0)
{
printf("%d is zero",a);
}
else
{
printf("%d is negative",a);
}
getch();
}
|
C | #include <stdio.h>
#include <math.h>
int main(){
int entrada;
long int lado = 2 ;
scanf("%d",&entrada);
while(entrada>0){
lado = (lado + lado) - 1;
entrada--;
}
printf("%ld\n",lado*lado);
return 0;
}
|
C | int a[5] = {2,3,6,8,9}, b[5] = {3,4,6,9,11}, c[5];
int i;
void main()
{
for (i=0; i<5; i++)
{
c[i] = a[i] + b[i];
}
assert(c[0] == 5, "c[0] must be 5");
assert(c[1] == 7, "c[1] must be 7");
assert(c[2] == 12, "c[2] must be 12");
assert(c[3] == 17, "c[3] must be 17");
assert(c[4] ... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_view_plane.c :+: :+: :+: ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.