language large_stringclasses 1
value | text stringlengths 9 2.95M |
|---|---|
C | #include "circularList.h"
//Node *last = NULL;
Node *create(int data)
{
Node *temp = (Node *)calloc(1,sizeof(*temp));
temp->data = data;
temp->next = NULL;
return temp;
}
Node *addAtBeginning(Node *last, int data)
{
Node *new;
//Node *temp = last->next;
if(last == NULL)
{
printf("List is empty\n"... |
C | #include <math.h>
#include "config.h"
#include <stdio.h>
extern double Temperature[ROWS+2][COLUMNS+2];
extern double Temperature_last[ROWS+2][COLUMNS+2];
double jacobi_loop( int row, double* Temp, double* Temp_last ) {
double dt = 0.0;
if ( row == 1000 ) printf( "Temperature[%d][1000] = %5.2f, Temperature_las... |
C | /* http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html */
/* conditional variable example */
/*
* A condition variable is a variable of type pthread_cond_t and is
* used with the appropriate functions for waiting and later, process
* continuation.
*
* The condition variable mechanism allows thr... |
C | #include<stdio.h>
int Multip_Rec();
int main(int argc, char const *argv[]){
int n1 = 7, n2 = 7, p = 0, valor = 0;
valor = Multip_Rec(n1,n2,p);
printf("\n");
printf("%d\n", valor);
return 0;
}
int Multip_Rec(int a, int b, int p){
int v;
if (p==b)
return 0;
else{
p++;
v = a + Multip_Rec(... |
C | // Contactor.h
/**
* Sets Contactor on or off
* Checks if flag is high or low. If high, return 1, if low, return 0.
* @author Manolo Alvarez
* @lastRevised 11/21/2018
*/
#ifndef CONTACTOR_H__
#define CONTACTOR_H__
// Initiliazes GPIOA_Pin_6
void Contactor_Init(void);
// Closes contactor, GPIO_Pin_6 = 1
void Co... |
C | #include<stdio.h>
#include<stdlib.h>
#include<omp.h>
#include<time.h>
#include<math.h>
#include<float.h>
#define K 4
int num_threads;
long num_points,cluster_count[K];
long datapoints[100][2];
int cluster[K][2]={{75,25},{25,25},{25,75},{75,75}};
void populate_points(){
long i;
#pragma omp parallel
for(i=... |
C | /* This is Floyd Algorithm with time complexity of O(N log_2 P / sqrt(P))
This parallel Algorithm breaks the bigger adjacency matrix into smaller grids.
The grids are of size n/sqrt(p)*n/sqrt(p) .
Where n*n is the size of the bigger adjacency matrix and p is the total number of processes.
And finally , the computation... |
C | #include <memory.h>
#include <printk.h>
#include <string.h>
#include <x86.h>
#define PHYSICAL_POOL_PAGES 64
#define PHYSICAL_POOL_BYTES (PHYSICAL_POOL_PAGES << 12)
#define BITSET_SIZE (PHYSICAL_POOL_PAGES >> 6)
#define ADDRMASK 0xFFF0000000000FFF
#define OFFSMASK 0x1FF
#define PAGESIZE 4096
#define PAGE_SI... |
C | #include <stdio.h>
#define BUFFER_SIZE 100
int main()
{
char * words[100];
int n = 0;
int slice = 0;
char buffer[BUFFER_SIZE];
while (scanf("%s", buffer) != EOF)
{
words[n] = buffer;
n++;
}
} |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
//去除字符串前后的空格, 中间的不管
int trimSpace(char *str, char *newstr){
char *p = str;
int i, j, count;
j = strlen(p)-1;
if(str == NULL || newstr == NULL){
return -1;
}
while(isspace(p[i]) && *(p+i) != '\0'){
i++;
}
... |
C | #include <stdio.h>
#include <string.h>
int mystrstr(char *haystack, char *needle) {
if(*needle == 0) {
return 0;
}
for(unsigned q=0; *(haystack+q) != 0; q++) {
for(unsigned w=0; *(needle+w) != 0; w++) {
if(*(haystack+q+w) != *(needle+w)) {
break;
}
if(w == strlen(needle)-1) {
return q;
}
}... |
C | #include <stdio.h>
#include <sys/types.h> /* See NOTES */
#include <sys/socket.h>
#include <netinet/in.h>
#include <errno.h>
void s_debug()
{
printf("debug: %s \r\n", strerror(errno));
exit(1);
}
int main(int argc, char **argv)
{
int socknd;
struct sockaddr_in servx;
char buf[255];
... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rotate_push.c :+: :+: :+: ... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_arg_format.c :+: :+: :+: ... |
C | /* This applies to square matices n x n
1 0 0
0 1 0
0 0 1
we may allocate an array of size n only to save space
instead of n * n size to store zeros
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
typedef struct {
int *matrix;
int deminsions;
} diagonal_t;
void set(diagonal_t *matrix_ptr, int... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define VELICINA (11)
#define VEL_DAT (1024)
struct _stablo;
typedef struct _stablo *StabloPozicija;
typedef struct _stablo {
char data[VELICINA];
StabloPozicija lijevo;
StabloPozicija desno;
}Stablo;
struct _lista;
typedef struct _lista *ListaPozicija;
ty... |
C | #include <stdio.h>
#include <ctype.h>
#include <string.h>
#define MAX 80
float odnosGolemiMali(char *p)
{
int golemi=0;
int mali=0;
while(*p)
{
if(isalpha(*p)) {
if(isupper(*p)) {
golemi++;
} else if(islower(*p)) {
mali++;
}
}... |
C | #include "minicrt.h"
#include <stdarg.h>
int fputc(char c, FILE *stream)
{
if (fwrite(&c, 1, 1, stream) != 1)
return EOF;
else
return c;
}
int fputs(const char *str, FILE *stream)
{
int len = strlen(str);
if (fwrite(str, 1, len, stream) != len)
return EOF;
else
ret... |
C | #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
#include <string.h>
#include <fcntl.h>
# define LINK_LENGTH 100
void get_proc(char* str)
{
int len = strlen(str);
int count = 0, i = 0;
while (1)
{
if (str[i] == '\n')
break;
i... |
C |
/***********************************************************************
*
* xvlrboundary.h
*
* left & right state boundary condition in x
*
*
* j, k : loop index of x, y, z
* m : Vl, Vr vector component index
*
*
* 2013 Apr. 15 : add XLeftVlAxisBoundary.
* 2012 Dec. 06 : coded by Sho Nakamura (Tohoku ... |
C | #define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
//һûظֵУпܵȫС
void swap(int* nums, int a, int b) {
int temp = nums[a];
nums[a] = nums[b];
nums[b] = temp;
}
void backtrack(int* nums, int numsSize, int** ret, int first, int* returnSize, int** returnColumnSizes) {
if (first == numsSize) {
returnColumnSizes[0][*re... |
C | double median(double x, double y, double z) {
double result;
if (x <= y) {
if (y <= z) result = y;
else if (x <= z) result = z;
else result = x;
}
if (z <= y) result = y;
if (x <= z) result = x;
result = z;
return result;
}
|
C | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#define GIGA pow(2, 30)
#define NANO 1e9
float dp(long, float *, float *);
int main(int argc, char * argv[])
{
// Declare and initialize vars.
long i;
float res = 0.;
// Parse command line args.
if (a... |
C | ////Includes //////////////////////////////////////////////////////
#include "BUTTON_IN.h"
#include "Button.h"
#include "Clock.h"
////Typedefs /////////////////////////////////////////////////////
typedef enum
{
BUTTON_EVENT_PRESS,
BUTTON_EVENT_HOLD,
BUTTON_EVENT_RELEASE,
BUTTON_EVENT_TYPE_MAX
} Button_Ev... |
C |
#include "std_testcase.h"
#include <wchar.h>
void CWE476_NULL_Pointer_Dereference__char_54c_badSink(char * data);
void CWE476_NULL_Pointer_Dereference__char_54b_badSink(char * data)
{
CWE476_NULL_Pointer_Dereference__char_54c_badSink(data);
}
void CWE476_NULL_Pointer_Dereference__char_54c_cwe_fooSink(c... |
C | #include<iostream>
#include<conio.h>
#define T 8
using namespace std;
using namespace System;
#define Ancho_Tablero 8
#define Alto_Tablero 8
#define Ficha_Blanca 'X'
#define Ficha_Negra 'O'
#define LIBRE ' '
#define Ancho_Caracter 3
struct Ficha {
int posC;
int posF;
char direccion;
char tipo; // (... |
C | /*
* Copyright (c) 2007 - 2014 Joseph Gaeddert
*
* This file is part of liquid.
*
* liquid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any lat... |
C | /**
* https://www.hackerrank.com/challenges/runningtime
*/
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
int n;
int aux;
int shift = 0;
int arraySize = 0;
int array[1001];
// Read de size of array
scanf("%d", &n);
// Iterate N times
... |
C | #include <Foundation/FoundationInternal.h>
EZ_FOUNDATION_INTERNAL_HEADER
#if EZ_ENABLED(EZ_PLATFORM_64BIT)
// On 64-bit android platforms we can just use the posix implementation.
# include <Foundation/Time/Implementation/Posix/Timestamp_posix.h>
#else
// On 32-bit android platforms time.h uses 32bit time stamps. So ... |
C | #include<stdio.h>
int main()
{
int a[4] = {1, 2, 3, 4};
int *p, (*P)[4];
P = a;
p = a;
printf("%d\n", a);
printf("%d\n", P);
printf("%d\n", *P);
printf("%d\n", **P);
printf("%d\n", P[1]);
printf("%d\n\n", &P);
printf("%d\n", p);
printf("%d\n", *p);
printf("%d\n", &p)... |
C | /*-------------------------------------------------------------------------*/
/* jstickc.c Joy Stick Interface routines */
/* */
/* Author:Peter Savage Created:02-Jan-1992 */
/* j... |
C | #include "render_line.h"
#include "line.h"
#include "angle.h"
Render_Line create_render_line(Line *line)
{
Render_Line ret;
ret.line = line;
if (line->start.x != line->end.x)
{
double a = (line->end.y - line->start.y) / (line->end.x - line->start.x);
double b = line->start.y - a * line-... |
C | // Copyright (c) 2017 , yogurt.yyj.
// All rights reserved.
//
// Filename: DFS.c
//
// Description:
//
// Version: 1.0
// Created: 2017/11/23 10时30分27秒
// Compiler: g++
//
// Author: yogurt (yyj), yyjhit@sina.com
//
#include <string.h>
#include <stdio.h>
#define maxn 111
int vis[maxn][maxn]; // 用于标记一个位置是否被访问过
... |
C | /*
* tclUnixEvent.c --
*
* This file implements Unix specific event related routines.
*
* Copyright (c) 1997 by Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* RCS: @(#) $Id: tclUnixEvent.c,v 1.1.1... |
C | #define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
int i = 1;
do
{
if (i == 5)
continue;
//break;
printf("%d ", i);
i++;
}
while (i < 10);
return 0;
}
//int main() {
// int i = 0;
// int k = 0;
// for (i = 0, k = 0;k = 0;i++, k++)
// {
// k++;
// }
//
// /*int x, y;
// for (x = 0... |
C | /**
* Author: Daniel Coughran
* Date: 27/10/2017
* Purpose: encapsulate cd function, could be extended
* with related functionality if needed
* Param: Target Directory
**/
#include <stdlib.h>
#include <stdio.h>
void DoCd(char* dir){
printf("hit cd\n");
//system("cd %s", "Fuck this part doesnt wo... |
C | // En una matriz de N x M enteros entre 1 y 10, contar numero de 3's
// Procesar por FILAS
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <sys/time.h>
main (int argc, char *argv[]) {
struct timeval ts, tf;
int i, j, N, M;
int **a;
int c = 0;
if (argc != 3) {printf ("USO: %s <dimX> <di... |
C | void error(int index)
{
switch(index)
{
case 0:
fprintf(error_txt, "第%d行:字符常量的字符非法;\n",line_count);
break;
case 1:
fprintf(error_txt, "第%d行:字符常量缺少右\' ;\n",line_count);
break;
case 2:
fprintf(error_txt, "第%d行:字符串过长;\n",line_count... |
C | #include <stdio.h>
int main(void)
{
int nombres[] = {
1,
12,
123,
1234,
12345,
123456
};
printf("%6d%d\n", nombres[0], nombres[0]);
printf("%6d%d\n", nombres[1], nombres[1]);
printf("%6d%d\n", nombres[2], nombres[2]);
printf("%6d%d\n", nombres[3], nombres[3]);
printf("%6d%d\n", no... |
C | /* Author: Beat Hirsbrunner, University of Fribourg, July 2007 */
#include <stdio.h>
#include <ctype.h>
int getch(void);
void ungetch(int);
/* getint: get next integer from input into *pn --- kr97 */
/* and return -1 on EOF, 0 if the readed input is not a number, and a positive number otherwise */
int getint(int *... |
C | #include <stdio.h>
#include <stdlib.h>
#include "colour.h"
#include "grade.h"
#include "ttt.h"
#include "employee.h"
int main(void)
{
/* Ex 15.1: Colour description */
/*
int n;
int i;
int r, g, b;
Colour c[N], average;
printf("Evaluating brightness of colours from their RGB values.\n");
printf("Enter the... |
C | /***************************************************************************
*
* Programmers and Purdue Email Addresses:
* 1. ozubi@purdue.edu
* 2. mtolkacz@purdue.edu
* 3. elkins15@purdue.edu (delete line if no third partner)
*
* Lab #: Lab 05
*
* Academic Integrity Statement:
*
* We have not used source code o... |
C | char *substr_c(char *s1, char *s2) {
char *p1, *p2, *rv;
rv = 0;
while (*s1 != '\0') {
/* Loop over all characters in s1 */
p1 = s1;
p2 = s2;
while (*p1 != '\0' && *p2 != '\0' && (*p1 == *p2)) {
/* See if s2 is a substring here */
p1 += 1;
... |
C | #include <stdlib.h>
#include<stdio.h>
#include<stdbool.h>
#include "../inc/SetAssociative.h"
#include "../inc/HexToBin.h"
#include "../inc/BinToDec.h"
//Reads the data from the file and reports the hit and miss ratio (4 way set associative Cache)
void SetAssociative()
{
//Initialize the necessary parameters for c... |
C | #include <stdio.h>
#include <stdlib.h>
#define CANT 5
int iniciarArray(int *pArray[], int limite, int valor);
int MostrarArray (int * pArray[], int limite);
int CargarEdad(int * pArray [], int limite);
int CargarNota1(int * pArray [], int limite);
int CargarNota2(int * pArray [], int limite);
int sumaArrays... |
C | /*
* seqsearch.c˳ʾ˳ҡ
* ߣCԼ(www.freecplus.net) ڣ20210325
*/
#include <stdio.h>
#include <string.h>
// IJұ˳ҡ
// sstableвkeyʧܷ-1ɹkeysstableе±ꡣ
int Seq_Search1(int *sstable,unsigned int len,int key)
{
int ii;
for (ii=0;ii<len;ii++) // ǰӺǰҶС
if (sstable[ii]==key) break; // ҵ˾break
if (ii==len) return -1; //... |
C | #include <stdio.h>
#include <stdlib.h>
#include <conio.h>
main(){
float num1, num2, num3, mediaA, mediaH;
printf("Digite o primeiro valor \n");
scanf("%f", &num1);
printf("Digite o segundo valor \n");
scanf("%f", &num2);
printf("Digite ... |
C | #include <stdio.h>
int main()
{
int num;
int sum = 0;
int count = 0;
while(scanf("%d", &num) && num != -1)//һֱֱ-1
{
sum += num;
++count;
}
printf("%f", (double)sum / count);
system("pause");
return 0;
} |
C | #ifndef __LIST_STACK_H__
#define __LIST_STACK_H__
#include "interfaces.h"
#include <stdio.h>
#include <stdlib.h>
struct list_char
{
char ch;
struct list_char *prev;
};
struct list_int
{
int num;
struct list_int *prev;
};
void push(struct list_int **s, int x);
void pop(struct list_int **s, ... |
C | #include <iostream>
using namespace std;
// 1+2+3+...+nʵַʽݹ顢ѭ
int AddFrom1ToN_Recursive(int n)
{
return n<=0 ? 0 : n + AddFrom1ToN_Recursive(n-1);
}
int AddFrom1ToN_Iterative(int n)
{
int result = 0;
for (int i = 0; i <= n ; ++i) {
result += i;
}
return result;
}
int main()
{
cout<... |
C | /*************************************************************************
*
* File: main.c
* Author: Jing Huang & Liang Wu
*
*
* Description: example compressors trying to compress files with
* adaptive Huffman coding.
*
************************************************************************/
#include ... |
C | /* check the person is adult or not */
#include<stdio.h>
void main()
{
int a;
printf ("enter the Age ");
scanf("%d",&a);
if(a>=18)
{
printf("the person is adult");
}
else
{
printf("the person is miner");
}
} |
C | #include<stdio.h>
#include<conio.h>
void main()
{
float sum=0,a;
clrscr();
while(1)
{
printf("\n\nEnter the number and press 1000 to exit");
scanf("%f",&a);
if(a==1000)
goto bottom;
sum=sum+a;
printf("Sum=%f",sum);
}
bottom:getch();
}
|
C | #include <unistd.h>
int main(void)
{
//a função write pede três parâmetros = no caso usei 1 ali, pq quero um std-output. "a", escreverá a vogal a
//que pesa 1 byte. 1 depois é o número de bytes a serem usados. no caso, usa só 1, pra 1 letra.
write(1, "a", 1);
return (0);
}
|
C | #include <stdio.h>
#include <stdarg.h>
#include <time.h>
#include <string.h>
#include "irc_logger.h"
static void __get_time_str(char *buf);
void log_error(const char *fmt, ...)
{
char time_as_str[26];
va_list args;
va_start(args, fmt);
__get_time_str(time_as_str);
fprintf(stderr, "[%s error] ", time_as_s... |
C | /**
* \file main.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "stream.h"
int ejpgl_main(stream_t *data_in, stream_t *data_out);
int main(int argc, char* argv[]) {
int ret;
FILE *infile, *outfile;
stream_t data_in, data_out;
struct stat fi... |
C | #include <stdio.h>
#define SIZE 10 /* Size of the array */
void printArray(int arr[]);
void rotateByOne(int arr[]);
int main()
{
int i, N;
int arr[SIZE];
printf("Enter 10 elements array: ");
for(i=0; i<SIZE; i++)
{
scanf("%d", &arr[i]);
}
printf("Enter number of times to left rot... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <ctype.h>
#include "struct.h"
#include "main_player.h"
// Display error message for the error
ExitStatusPlayer exit_program(ExitStatusPlayer status)
{
const char *message = "";
switch (status) {
case Normal:
... |
C | //открытие файла
#include "stdafx.h"
#include <windows.h>
#define MAX 10
struct person {
char *fname;
char *sname;
};
struct job {
struct person names;
char *jobs;
int id;
};
struct company {
struct job employer;
} IKEA[MAX];
int save_file();
int load_file();
int main(void... |
C | /**
* @file searchOrdered.c Task to perform searches in ordered array
* @brief
* Load up an array of strings and perform number of ordered
* searches. No check for NULL is used.
*
* @author George Heineman
* @date 6/15/08
*/
#include <stdlib.h>
#include <string.h>
#include "report.h"
/**
* Proble... |
C | #include <stdio.h>
inline unsigned int test1(unsigned int a, unsigned int b)
{
unsigned int ret;
ret = a + b;
return ret;
}
static inline unsigned int test2(unsigned int a, unsigned int b)
{
unsigned int ret;
ret = a * b;
return ret;
}
int main(int argc, char const* argv[])
{
unsigned a, b;
a = test1... |
C | //PARAM: --set ana.activated[+] useAfterFree
#include <stdlib.h>
#include <stdio.h>
void *my_malloc(size_t size) {
return malloc(size);
}
void my_free(void *ptr) {
free(ptr);
}
void *my_malloc2(size_t size) {
return my_malloc(size);
}
void my_free2(void *ptr) {
my_free(ptr);
}
int main(int argc, ch... |
C | /*
* punto.c
*
* Created on: 8 abr. 2021
* Author: eneko
*/
#include "punto.h"
#include <math.h>
float distancia(Punto p1, Punto p2){
int restaX;
int restaY;
restaX = p1.x - p2.x;
restaY = p1.y - p2.y;
return sqrtf((powf(restaX,2)+powf(restaY,2)));
}
void trasladarXY(Punto *p1, Punto *p2, int x, int y... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* draw.c :+: :+: :+: ... |
C | #include <stdio.h>
#include <stdlib.h>
#define stackSize 5
typedef struct stack
{
int data;
struct stack *pBottom;
} myStack;
myStack*pTop;
myStack* creatStack(int data);
int push (int data);
int pop (int*data);
int dataLimit ;
int main()
{
printf("Hello World");
myStack cell;
push(5);
push(10);
push(... |
C | #include <stdio.h>
#define RECIPROCAL(number) (1.0 / (number))
int main() {
float counter; /* Counter for our table */
for (counter = 1.0; counter < 10.0;counter+= 1.0)
{
printf("1/%f = %f\n", counter, RECIPROCAL(counter));
}
return (0);
}
//CORREÇÃO:
//linha 2 o define criado nao estava assosiado a nenhum ... |
C | /**
hind_brain.h
Purpose: Hindbrain libraries, constants, tuning parameters
@author Connor Novak
@email olingravl@gmail.com
@version 0.0.1 19/02/24
*/
#ifndef HIND_BRAIN_H
#define HIND_BRAIN_H
// Libraries
#include <Servo.h> // ESC and Servo PWM control
#include <Arduino.h> ... |
C | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <rays.h>
#include <constants.h>
#include <pthread.h>
#ifdef PARALLEL
#include <parallel_render.h>
#endif
#include "SDL.h"
uint8_t init();
SDL_Window *g_window = NULL;
SDL_Renderer *renderer = NULL;
uint8_t init() {
uint8_t... |
C |
void ChangePWM() //
{
// - 976 16 1
TCCR1A = 0b00000001; // 8bit
TCCR1B = 0b00001011; // x64 fast pwm
// - 976 - 8 2
TCCR2B = 0b00000011; // x64
TCCR2A = 0b00000011; // fast pwm
}
/* 8 8 255
// - 62.5
TCCR0B = 0b00000001; // x1
TCCR0A = 0b00000011; // fast pwm
// - 3... |
C | #ifndef ISTACK
#define ISTACK
#define INITIAL_CAPACITY 5
#define SCALING_FACTOR 2
typedef char* element;
typedef struct {
int capacity;
int top;
element *elements;
} stack;
stack *new_stack();
stack *create_stack( const int );
void destroy_stack( stack * );
stack *resize( stack *, const int );
int empty( const s... |
C | #include <stdio.h>
#include <time.h>
#define N 50000
float m[N][N];
int main()
{
float a = 0.0;
clock_t s, f;
s = clock();
for (int n = 0; n < 100; ++n)
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
a += m[i][j];
f = clock();
... |
C | void main(int n) {
int i = 0;
int j;
for (i=0; i<n; i=i+1) {
print i;
for(j=0; j<i; j=j+1) {
print j;
}
}
}
// i=0;
// for (i=0; i < n ; i=i+1) {
// print i;
// for (j=0; j<n; j=j+1) {
// print j;
// if (j == 2) {
// break;
// }
// }
// if (i ... |
C | #include "dataset.h"
#include "dbg.h"
#define MAX_LINE_LENGTH BUFSIZ
void dataset_init(Dataset *data, FILE *data_file) {
VECTOR_INIT(data->ex);
size_t attribute_count = 0, last_attribute_count = 0;
FILE *string_stream;
float attribute_value;
char linha[MAX_LINE_LENGTH];
while (fgets(linha, MAX_LINE_LEN... |
C | int sum(int *arr, int length){
int ret = 0;
for (int i = 0; i < length; i++){
ret += arr[i];
}
return ret;
}
|
C | #include "Oalloc.h" // "Once alloc", for allocating tons of little integers via pointers
#include "../blant.h"
#include "../blant-output.h"
#include "../blant-utils.h"
#include "blant-predict.h"
#include "htree.h"
#include "rand48.h"
#include <math.h>
#include <signal.h>
#include <ctype.h>
#include <unistd.h>
// Watch... |
C | #include <stdio.h>
int binary_search(int list[], int item, int left, int right);
void main()
{
int pos, max = 12, item = 60;
int list = {4,7,12,18,32,36,48,53,60,67,80,82};
pos = binary_search(list, item, 0, max-1);
printf("where? : %d", pos);
}
int binary_search(int list[], int item, int left, int r... |
C | #include "holberton.h"
#include <stdio.h>
char *_strncpy(char *dest, char *src, int n)
{
int copycounter = 0;
for (copycounter = 0; copycounter < n && *(src + copycounter) != '\0'; copycounter++)
*(dest + copycounter) = *(src + copycounter);
for ( ; copycounter < n; copyco... |
C | /* 20170201 NaJiwoong */
/* 2020 April 19 */
/* Environment
Ubuntu 16.04.12
gcc 5.4.0 */
/* Execution
"make"
- make execution file, and output.txt
"make clean"
- clean executino file, and output.txt */
#include <stdio.h>
#include <stdlib.h>
/* Function for S4-box mapping */
int s4box(int input){
... |
C | #include<stdio.h>
#include<math.h>
#define MOD 1000000007
typedef unsigned long long int ull;
ull pp(ull n,ull x)
{
ull i,ans=1;
for(i=1;i<=x;i++)
{
ans=ans*10;
}
return ans;
}
ull power(ull n)
{
ull ans=2,j=1,i,count=0;
//printf("%llu\n",n);
//printf("hello1\n");
if(n==1)
{
return ans;
}
if(n==0)
... |
C | #include <stdio.h>
#include <stdlib.h>
int main()
{
typedef struct {
int a[100];
char b;
double * c;
} mystruct_t;
mystruct_t d[10];
mystruct_t * ap = d;
printf("%x %u\n",ap, ap);
printf("%x %u\n", ap+1, ap+1);
printf("%x %u\n", &d[10]-d, &d[10]-d);
return 0;
}
|
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* read.c :+: :+: :+: ... |
C | #ifndef MAIN_H
#define MAIN_H
#include<stdio.h>
#include<stdlib.h>
typedef int data_t;
typedef struct node
{
data_t data;
struct node *link;
}slist;
enum status
{
FAILURE,
SUCCESS,
LIST_EMPTY,
DATA_NOT_FOUND
};
int insert_at_first(slist **head, data_t);
int insert_at_last(slist **head, data_t);
int delete_fi... |
C | /* File : sampleTimeSync.c
* Abstract:
*
* C-file S-function para sincronizarse con los tiempos de sampleo,
* mediante el uso de un reloj en tiempo real (PerformanceCounter)
* De esa forma, conseguimos una simulacion pseudo-tiempo-real.
*
* Copyright 2007 Toni Benedico Blanes
* Version: 1.... |
C | #include <stdio.h>
main()
{
printf("Sup! This my 1st C program after trying Learn C in 24 hours.\n");
return 0;
}
|
C | #include"handsk.h"
#include"ot.h"
#include <time.h>
SOCKET clientSOCKET;//全局的socket
int random_unique = 11;
void get_msg() {
char recv_buff[1024];
int r;
while (1) {
memset(recv_buff, 0, sizeof(recv_buff));
r = recv(clientSOCKET, recv_buff, 1023, NULL);
if (r > 0) {
recv_buff[r] = 0;
printf("recv from ... |
C | #include "log.h"
static FILE *log_fp = NULL;
/**
* Start our own debug logger.
* @param file_name
* @return
*/
int start_logger(char* file_name) {
log_fd = fopen(file_name, "w");
if (log_fd == NULL) {
fprintf(stderr, "Can not start logger.\n");
return 1;
}
return 0;
}
/**
* Close... |
C | /**
* @author Joseph Kawamura
*
* Desc:
* Node class used to construct the huffman tree. Each node contains a character, that characters frequency
* within the given text file as well as pointers to left and right children that can be used to construct
* a binary tree.
*
* Modified: April 26,... |
C | #include <stdio.h>
#include <string.h>
char *mystrcpy(char *dest, char *src)
{
if(NULL == dest || NULL == src)
{
puts("NULL pointer error.");
return NULL;
}
char *p = dest;
while(*src)
{
*p = *src;
src++;
p++;
}
*p = 0;
return dest;
}
int mystrlen(const char *src)
{
if(NULL == src)
{
puts("src... |
C | #include <stdio.h>
#include <string.h>
int ft_strlen(char *str)
{
int l;
l = 0;
while (str[l] != '\0')
{
l++;
}
return(l);
}
int main()
{
char *str;
str = "lol";
printf("%d\n", ft_strlen(str));
printf("%lu\n", strlen(str));
return (0);
}
|
C | #include "libmy.h"
int my_count(long n)
{
int count;
count = 0;
if (n == -2147483648)
return (11);
if (n == 0)
return (1);
if (n < 0)
count++;
while (n != 0)
{
n = n / 10;
count++;
}
return (count);
}
char *my_itoa(int num)
{
int i;
char *str;
int len;
long n;
n = num;
i = 0;
len = my_co... |
C | #include <sat/driver.h>
#include <avr/io.h>
void driver_init(void)
{
// For driver communication, we use PORTB by default
// Configuring pins to output
DDRB |= (1<<4)|(1<<3)|(1<<2);
// For PWM feature, we use Timer1
// Configuring timer
// Compare ch.A, PWM Phase Correct, 10-bit
TCCR1A = ... |
C | /*
* Author: 段鹏远(alex)
* Version: 0.1
* Time: 2014-9-29
* Function:
使用递归方法实现atoi函数
功能:将字符串转换成整数
*/
#include "apue.h"
int my_atoi(const char* p);
size_t my_atoi_r(const char* p, size_t num);
size_t tens(size_t num);
int main(int argc, char* argv[]){
printf("%d\n", my_atoi("-1234"));
return 0;... |
C | #include <stdio.h>
#include <stdlib.h>
int main()
{
printf("\"Ahmed said:\"I searched online and found that \\,\",new lines('\\n')and tabs('\\t')are among the special characters.\"\n");
printf("Mohamed replied:\"Great, I also managed to make a beep sound using the special character'\\a'.Hear this ..\"");
... |
C | /***************************************************************************
* File : vsyn_lib *
* Note : This file contains functions for synthesis of vowels. *
***************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#inc... |
C | /*************************************************************************
> File Name: memset.c
> Author: Amano Sei
> Mail: amano_sei@outlook.com
> Created Time: 2019年10月20日 星期日 11时57分56秒
************************************************************************/
#include <stdio.h>
#define VBYTES 32
... |
C | /*****************************************
Emitting C Generated Code
*******************************************/
#include <functional>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
/**************** Snippet ****************/
void Snippet(int x0) {
int x1 = 100;
std::function<int*(... |
C | #include <stdio.h>
#include <string.h>
const char* color[] = {"red", "blue", "yellow", "green", "black"};
int main(){
char str[10];
scanf("%s", str);
for (register int i = 0; i < 5; i++)
if (strcmp(str, color[i]) == 0){
printf("%d\n", i+1);
goto Founded;
}
print... |
C | #include <stdio.h>
#include <laniakea/ini.h>
void test_section_insert()
{
la_ini_section *sec = la_ini_section_new("Section 1");
la_ini_section_insert(sec, "key1", "value1");
la_ini_section_insert(sec, "key2", "value2");
la_ini_section_free(sec);
}
void test_insert()
{
la_ini *ini = la_ini_new(... |
C | #include<cstdio>
class Buffer {
public:
virtual int size() = 0;
virtual char &elem(int idx) = 0;
};
#define ARRAY_SIZE 10
class ArrayBuffer : public Buffer {
char buf[ARRAY_SIZE];
int id;
public:
int size() override {
return sizeof(buf);
}
char &elem(int idx) override {
return buf[idx];
}
... |
C | #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(int argc, char **argv){
unsigned int i;
int arquivo = open("mem4disk.DATA", O_RDONLY);
char *mem;
if((mem = (char*) malloc(DATASIZE)) == NULL){
perror("memory fa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.