language large_stringclasses 1
value | text stringlengths 9 2.95M |
|---|---|
C | #include<stdio.h>
#include<string.h>
main()
{
char a1[1000],a2[1000];
printf("\n ENTER THE FIRST STRING : \n\n");
gets(a1);
printf("\n ENTER THE SECOND STRING : \n\n");
gets(a2);
if(strcmp(a1,a2)==0)
{
printf("\n THE STRINFGS ARE EQUAL : \n\n%s\n\n%s\n",a1,a2);
}
else
{
printf("\n THE STRINFGS ARE NOT EQU... |
C | /**
* Return an array of size *returnSize.
* Note: The returned array must be malloced, assume caller calls free().
*/
#include <stdlib.h>
#include <string.h>
const int TRUE = 1;
const int FALSE = 0;
int isDigit(char c) {
if ('0' <= c && c <= '9') {
return TRUE;
}
return FALSE;
}
// 0: letter-l... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* draw_map.c :+: :+: :+: ... |
C | #include <stdio.h>
int main(void)
{
//Function prototypes
void PrintBinaryFormOfNumber(unsigned int);
//Variable declarations
unsigned int a;
unsigned int b;
unsigned int right_shift_A, right_shift_B;
unsigned int left_shift_A, left_shift_B;
unsigned int result;
//code
printf("\n\n");
printf("Enter An Int... |
C | #include <stdio.h>
int main()
{
long nc;
while(getchar() != '\n') {
++nc;
}
printf("%ld\n", nc);
} |
C | #include "stm32f10x.h"
#include "LED.H"
/*******************************************************************************
* : LED_Init
* : LEDʼ
* :
* :
*******************************************************************************/
void LED_Init()
{
GPIO_InitTypeDef GPIO_In... |
C | #include "loop.h"
#include <string.h>
#include "loop_heap.h"
loop_container_t* init_loop(){
loop_container_t* temp = NULL;
if((temp = (loop_container_t*)malloc(sizeof(loop_container_t))) == NULL){
return NULL;
}
else{ //if memory allocation for loops` container did not fail
if((temp->a... |
C | #include "holberton.h"
/**
* print_square - Print a square of lengh n
* @n : number of lines
* Return: Always 0.
*/
void print_square(int n)
{
int c;
int d = n;
if (n < 1)
{
_putchar('\n');
}
while (d > 0)
{
c = 1;
while (c <= n)
{
_putchar(35);
c++;
}
d--;
_putchar('\n');
}
}
|
C | #include<stdio.h>
void main()
{
int a[10],i,great;
printf("Enter a values:");
for (i=0;i<10;i++)
{
scanf("%d", &a[i]);
}
great=a[0];
for(i=0;i<10;i++)
{
if(a[i]>great)
{
great=a[i];
}
}
printf("greatest number %d",great);
return 0;
}
|
C | void strcpy(char*, char*);
//string copy function
bool strcomp(char*, char*);
//string compares returns true or false
void strcat(char*, char*);
//appends second string onto end of first
int strlen(char*);
//returns the length of the string
|
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "reversi.h"
#define _DEBUG
Point p_add(Point a, Point b)
{
Point res;
res = a;
res.x += b.x;
res.y += b.y;
return res;
}
Point p_sub(Point a, Point b)
{
Point res;
res = a;
res.x -= b.x;
res.y -= b... |
C | #include<stdio.h>
#include<stdlib.h>
struct node
{
int data;
struct node* left;
struct node* right;
};
struct node* newnode(int data)
{
struct node* nn=(struct node*)malloc(sizeof(struct node));
nn->data=data;
nn->left=NULL;
nn->right=NULL;
return nn;
}
struct stack
{
struct stack* n... |
C | #include<stdlib.h>
#include<stdio.h>
#define MAX 10000000
/*
void quick_sort(long int s[], int l, int r)
{
if (l < r)
{
//Swap(s[l], s[(l + r) / 2]); //м͵һ μע1
int i = l, j = r, x = s[l];
while (i < j)
{
while(i < j && s[j] >= x) // ҵһСx
... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#define PORT 8080
int main(){
char client_message[2000];
char buffer[1024];
int serverSocket,newSocket;
struct sockaddr_in s... |
C | #include<stdio.h>
#include<stdlib.h>
int main(){
int number;
scanf("%d",&number);
int test=number;
int sum=0,inter;
while (test>0)
{
inter=test%10;
test=test/10;
sum=sum+(inter*inter*inter);
}
if (sum==number)
{
printf("Its Armstrong!");
}else
... |
C | #include <string.h>
char * __cdecl strrev(char * string)
{
char *start = string;
char *left = string;
char ch;
while (*string++) /* find end of string */
;
string -= 2;
while (left < string)
{
ch = *left;
*left++ = *string;
*string-- = ch;
... |
C | /**
* @file mod_pulsgen.h
*
* @brief pulses generator module header
*
* This module implements an API
* to make real-time pulses generation using GPIO
*/
#ifndef _MOD_PULSGEN_H
#define _MOD_PULSGEN_H
#include <stdint.h>
#include "mod_msg.h"
#include "mod_timer.h"
#define PULSGEN_CH_CNT 32 ///< m... |
C | #include "localized_pokemon.h"
#include <commons/string.h>
t_localized_pokemon* localized_pokemon_create(char* nombre, t_list* posiciones){
t_localized_pokemon* localized_pokemon = malloc( sizeof(t_localized_pokemon) );
localized_pokemon->nombre = string_from_format("%s",nombre);
localized_pokemon->tamanio_nombre =... |
C | /* 5-8.c
#include <stdio.h>
#define OUTPUT1(a, b) a + b // ũ Լ
#define OUTPUT2(a, b) #a "+" #b // ũ Լ
int main(void)
{
printf(" %d \n", OUTPUT1(11, 22)); // 10
printf(" %s \n", OUTPUT2(11, 22)); // ڿ ġ
return 0;
}
*/ |
C | #include<stdio.h>
char atoupper(char c)
{
char d='c'-32;
return d;
}
main()
{
char c='s';
char d=atoupper(c);
printf("%c \n",d);
}
|
C | #include <stdio.h>
#define OK 0
#define ERROR 1
#define MAX_LEN 10
#define MIN_LEN 1
#define TRUE 1
#define FALSE 0
int sum_even(const int *arr, const int n);
int scanf_arr(int *arr, int n);
int check(const int *arr, const int n);
int main(void)
{
int n;
int rc = scanf("%d", &n);
if (rc != 1 || n < MIN_... |
C | #include <stdio.h>
int main()
{
int n;
printf("Enter sum \n");
scanf("%d",&n);
printf("No of 100 notes: %d \n",(n/100));
n%=100;
printf("No of 50 notes: %d \n",(n/50));
n%=50;
printf("No of 10 notes: %d \n" ,(n/10));
n%=10;
}
|
C | #include "TLC2543.h"
/*
Ȩ:https://github.com/MisakaMikoto128/TLC2543_STM32
ߣԸ
*/
void TLC2543_Init()
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, ENABLE );//PORTBʱʹ
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; // PB12
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //... |
C | //hash-open addressing
// open addressing is a method for handling collisions. In Open Addressing,
//all elements are stored in the hash table itself.
//So at any point, the size of the table must be greater than
// or equal to the total number of keys
#include<stdio.h>
#include<stdlib.h>
int count;
#define maxsiz... |
C | //NAME: Yunjing Zheng
//EMAIL: jenniezheng321@gmail.com
//ID: 304806663
#include <errno.h>
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "utilities.h"
const int PROGRAM_TYPE=ADD_TYPE;
// can adjust using process arguments
int DEBUG_FLAG, YIELD_FLAG, NUM_THR... |
C |
#include "stdio.h"
int main(){
int pasc[11];
int n = 11;
int x, i, j;
int cam;
x = 0;
printf("INGRESE UN NUMERO:");
scanf("%d",&cam);
printf("\n");
printf("INGRESE EL NUMERO DE FILAS: ");
scanf("%d",&n);
for (i=1; i<=n ; i++)
{
//Construimos el triangulo de pascal
... |
C | #include<stdio.h>
int main()
{
int g;
printf("Enter your grade :");
scanf("%d",&g);
g=g/10;
switch(g)
{
case 10 :
case 9 :
printf("\nYour grade is A.");
break;
case 8 :
printf("\nYour grade is B.");
break;
case 7 :
printf("\nYour grade is C... |
C | #incluide <studio.h>
int main []
[
int numero;
printf ( " \ n introduce un numero " );
scanf ( " % d , & numero " );
si (numero% 2 es 0 )
[
printf ( " \ n El numero es PAR " );
]
demás
[
printf ( " \ n El numero es IMPAR " );
]
return... |
C | #include "window.h"
static SDL_Surface *window;
static size_t window_width, window_height;
/* buffer used for window bar text */
#define TITLEBUFFER 40
#define BLACK SDL_MapRGB(window->format, 0x00, 0x00, 0x00)
#define WHITE SDL_MapRGB(window->format, 0xFF, 0xFF, 0xFF)
#define GREEN SDL_MapRGB(window->format, 0x00, ... |
C | #include "ctype.h"
#include "stdio.h"
#include "string.h"
void swap_chars(char *sentence, int char_closer_to_word_beginning_index, int char_closer_to_word_ending_index) {
char tmp = sentence[char_closer_to_word_ending_index];
sentence[char_closer_to_word_ending_index] = sentence[char_closer_to_word_beginning_i... |
C | /*
Lossy Block Reduction Filter.
Goal: Reduce the number of distinct pixel blocks such that subsequent compression of DXT output will compress better.
This is done as an image pre-filter rather than as part of the block-encoding process mostly to generalize over some of the subsequent encoding steps.
Note: May write... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf.c :+: :+: :+: ... |
C | #include <stdio.h>
int n;
int sqrt(int n, int a)
{
int ret = 1;
while (a--) {
ret *= n;
}
return ret;
}
int main(void)
{
//freopen("input.txt", "r", stdin);
int a, b;
while (scanf("%d", &n) != EOF) {
int div = sqrt(10, n / 2);
for (int i = 0; i < sqrt(10, n); i++) {
a = i / div;
b = i % div;
... |
C | #include "src.h"
void my_printf_o(va_list listarg)
{
int fd;
fd = va_arg(listarg, int);
my_putnbr_base(fd, "01234567");
}
void my_printf_u(va_list listarg)
{
unsigned int fd;
fd = va_arg(listarg, unsigned long int);
my_putnbr_base(my_put_nbr_unsigned(fd), "0123... |
C | #include <stdio.h>
#include <stdlib.h>
void swap(int *a, int *b){
int temp = *a;
*a = *b;
*b = temp;
}
/* Questa funzione partiziona l'array A in 3 parti:
1) A[sx..i] contiene tutti gli elementi minori del pivot;
2) A[i+1..j-1] contiene tutti gli elementi uguali al pivot;
3) A[j..dx] co... |
C | /* Given an interface name and a packet length (optional), prints to stdout
* the maximum number of packets (each within that length) that fits in the
* currently available TX slots. If the packet length is not specified, it
* is assumed that any packet to be transmitted fits within a single netmap
* slot, hence pr... |
C | /*!
\file
\brief Various functions for transfering data to/from slave/master memory
\date Started 6/3/2013
\author George
*/
#include "common.h"
/* the working directory; initialized during init */
static char xfer_wdir[BDMPI_WDIR_LEN];
/* disk I/O will be done in chunks of this number of bytes */
#define BDMPI_DI... |
C | #include <stdio.h>
#include <sys/epoll.h>
#include <fcntl.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <unistd.h>
#include <pthread.h>
#include "my_socket.h"
#include "my_err.h"
struct heihei{
char send_name[20];
char recv_name[20];
char mes[1024];
int send_fd;
int recv_fd;
};
struct haha{
int ... |
C | /*
* Operating System Interface
*
* This provides access to useful OS routines for the sandbox architecture.
* They are kept in a separate file so we can include system headers.
*
* Copyright (c) 2011 The Chromium OS Authors.
* SPDX-License-Identifier: GPL-2.0+
*/
#ifndef __OS_H__
#define __OS_H__
#include <l... |
C | // Module for interfacing with file system
#include "c_string.h"
#include "c_types.h"
#include "flash_fs.h"
#include "lauxlib.h"
#include "lualib.h"
#include "modules.h"
#include "platform.h"
#include "vfs.h"
static volatile int file_fd = FS_OPEN_OK - 1;
// Lua: open(filename, mode)
static int file_open(lua_State *L... |
C | //Adds access to libraries sdio and cs50 for certain features
#include <stdio.h>
#include <cs50.h>
//helps start off any program
int main(void)
//Start of program
{
//Allows assignment of a custom name by the user as the variable equal to answer
string answer = get_string("What is your name? ");
//displays outp... |
C | /*
output.txt should have:
foo:s,w,y,x
*/
void main()
{
int z = 12;//1
int x;//2
int y;//3
int w;//4
int r = 0, s;//5 6
// "x" should be printed
printf( "%d\n", x == 1 ? 12 : 13 );//7
// "y" should be printed:
printf( "%d\n", z == 12 ? y : 13 );//8
// "w" and "s" should be p... |
C | #pragma once
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
#include<assert.h>
#define MAX 50
typedef struct node
{
int adj;
}node;
typedef struct grap
{
char vertex[MAX];
node arr[MAX][MAX];
int vexnum;
int arcnum;
}grap;
typedef struct Queue
{
char a[MAX];
int front;
int rear;
int size;
}Queue... |
C | /**
* @file
* @brief Tests if System Timer's IRQ are handling when thread is running.
*
* @details There was a problme on STM32 platform:
* when after context switch timers, interrupts become disabled
* inside the next thread.
*
* @date 06.06.18
* @author Alex Kalmuk
*/
#include <errno.h>
#include <unistd.h>... |
C | int climbStairs(int n){
if (n == 1) return 1;
int* dp = (int*)malloc(sizeof(int) * (n + 1));
dp[1] = 1;
dp[2] = 2;
for (int i = 3; i < n + 1; ++i) {
dp[i] = dp[i - 1] + dp[i - 2];
}
int sum = dp[n];
free(dp);
return sum;
}
|
C | /*************************************************************************
> File Name: getHostname.c
> Author:wuhonglei
> Mail:1017368065@qq.com
> Created Time: Sat 31 Oct 2015 10:35:33 AM CST
> Description:virConnectGetHostname 获得主机(Dom0)的名字
*****************************************************************... |
C | #include<string.h>
#include<stdio.h>
#define fbuf(c) while((c=getchar())!='\n' && c!=' ' && c!='#')
void* fsearch(void*a,void*b,int ele_size,int n);
int main()
{
int str1[256]={0,},str2[256]={0,};
printf("Get two string_>");
char c=0;
int i=0,j=0;
scanf("%s",str1);
fbuf(c);
scanf("%s",str2+j)... |
C | #include<stdio.h>
#include<conio.h>
main(){
char name[1005], school[1005], tel[1005];
int age;
printf("Enter your name:\n");
gets(name);
printf("Enter your age:\n");
scanf("%d",&age);
printf("Enter your school:\n");
scanf(" %s", &school);
printf("Enter your telephone number:\n");
... |
C | //
// Created by Shahak on 06/06/2017.
//
#include "company.h"
#include "utility.h"
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#define INVALID_PARAMETER -1
struct Company_t {
char *email;
TechnionFaculty FacultyOfCompany;
Set company_rooms;
};
Company companyCreate(char *company_email,... |
C | #include <stdio.h>
int main ()
{
double k,total,result;
double i = 1;
printf("Digite um valor para k\n");
scanf("%lf",&k);
while(1)
{
total = 1/i;
result += total;
//printf("%lf\n",result);
if (result >= k)
{
printf("%.2lf\n",i);
break;
}
i ++;
}
return 0;
} |
C | #include <stdio.h>
int main(void) {
char *s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/0123456789";
char *str = "pqrst";
int l=5;
int j=0;
int t;
int n;
int n1;
if(l%3 == 0)
{
while(str[j]!='\0')
{
if(j%3==0)
{
t=2;
n=(int)str[j];
printf("%c ",s[n>>t]);
}
el... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include "structure.h"
#include "utilities.h"
#include "lyrics_io.h"
//Contains functions pertaining to file i/o
void readLinesToStructure(structure *s, char *filename, int numLines){ //reads untagged lines from file in... |
C | #define _GNU_SOURCE
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <pthread.h>
#include <dirent.h>
#include <regex.h>
pthread_mutex_t print_mutex;
pthread_mutex_t running_threads_mutex;
pthread_cond_t running_threads_cond;
int ... |
C | #include "spi.h"
void SPI1_Init(void); //ʼSPI
void SPI1_SetSpeed(u8 SPI_BaudRatePrescaler); //SPIٶ
u8 SPI1_ReadWriteByte(u8 TxData);//SPI߶дһֽ
SPI_InitTypeDef SPI_InitStructure;//ǰõSPIԾ涨
void SPI1_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Perip... |
C | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <ctype.h>
//Zad.1_1
int isNumber(const char *s)
{
int i=1;
if(s[0]=='-' || isdigit(s[0]))
{
}else
{
return 0;
}
for(i;i<strlen(s);i++)
{
if(! isdigit(s[i]))
{
return 0;
}
... |
C | /** \brief La funcion toma dos parametros tipo flotantes, y vivide uno por el otro.
*
* \param parametro A flotante.
* \param parametro B flotante.
* \return Retorna un flotante resultante de una divicion.
*
*/
float divicion (float , float );
/** \brief La funcion toma un numero, y mediante un for calcula su f... |
C | #include <stdlib.h>
#include <string.h>
typedef struct {
void* base;
int front;
int rear;
int queueCapacity;
int typeSize;
} CircularQueue;
typedef char String[256];
CircularQueue* create(int typeSize,int queueCapacity);
int enQueue(CircularQueue* cQueue,void* element);
int isFull(CircularQueue* cQueue);
void* ... |
C | /*
* Copyright (C) 2017 Niko Rosvall <niko@byteptr.com>
*/
#define _XOPEN_SOURCE 700
/* Make only POSIX.2 regexp functions available */
#define _POSIX_C_SOURCE 200112L
#include <stdio.h>
#include <regex.h>
#include "entry.h"
#include "regexfind.h"
void regex_find(Entry_t *head, const char *search, int show_passwor... |
C | #include <stdio.h>
#include <stdlib.h>
typedef struct bstNode{
int data;
struct bstNode *left;
struct bstNode *right;
}bstNode;
bstNode* insert(int data, bstNode* root)
{
//printf("Hey");
if(root == NULL){
//printf("I am null\n");
bstNode *node = (bstNode *)malloc(sizeof(bstNode));... |
C | #include<stdio.h>
#include<fcntl.h>
#include<unistd.h>
#include<errno.h>
void cpy(int instd , int outstd)
{
char buf[BUFSIZ]={0};
int n=0;
while((n=read(instd,buf,BUFSIZ))>0)
write(outstd,buf,n);
return;
}
int main(int argc , char* argv[])
{
int f=0;
if( argc < 3 || argc > 4) return 1;
if(a... |
C | #ifndef BLOCKGETANDSET_DEFINED
#define BLOCKGETANDSET_DEFINED
//ubNuAׂ
void SetBlock(MAP_DATA, BINDATA, int, int, int);
BINDATA GetBlock(MAP_DATA, int, int, int);
//T
int mapfind(MAP_DATA, int, int);
//\[g̍ޗƂȂ̒lvZ
int64 calc(MAP_DATA, int, int);
//ubNu
void SetBlock(MAP_DATA Mdata, BINDATA block, int x, int y, ... |
C | #include "holberton.h"
/**
* mul - check the code for Holberton School students.
* @a: init value
* @b: init value
* Return: Always 0.
*/
int mul(int a, int b)
{
int resultado;
resultado = a * b;
return (resultado);
}
|
C | /**
* Author: Gavin Christie
* Date Created: November 11th 2017
* Version: 1.0
* Main function for spell check program
**/
#include "DictionaryFunctions.h"
int main( int argc, char **argv)
{
/* Check that correct number of arguments are entering through terminal */
if ( argc < 2 || argc > 2 ) {
prin... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* test2.c :+: :+: :+: ... |
C | typedef long unsigned int size_t;
extern int printf (const char *__restrict __format, ...);
extern int scanf (const char *__restrict __format, ...) ;
extern int getchar (void);
extern int putchar (int __c);
int nextInt(){int f=0;char s=0;char c=getchar();while((c<48)||(57<c)){if(c==45){s=1;c=getchar();break;}c=get... |
C | #include <stdlib.h>
#include "transceivercom.h"
#include "packages.h"
const int maxPackages = 20;
void initPackages() {
allPackages.first = NULL;
}
void insertPackage(unsigned short moduleid, unsigned short macaddress, unsigned short nodeid, unsigned char * data) {
struct packageList * module = al... |
C | #include "../ecs/components.h"
#include "grammer_parser.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
// File example:
//
// s => sl
// s => sr # comment support
// s => sf
// l => l1
//
enum TokenType {
TOKENTYPE_ID, // ([a-zA-Z0-9])
TOKENTYPE_REPLACE, // ([a-zA-Z0-9]+)
TOKENTYPE_A... |
C | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(){
int n, m;
scanf("%d%d", &n, &m);
int i, comp, out = 0;
for(i = 7; i > 1; i--){
comp = (m%(int)pow(10, i) - m%(int)pow(10, i-2)) / pow(10, i-2);
if(n == comp){
out++;
}
}
printf("%d\n", out);
... |
C | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "fteik/fteik.h"
void solver2d_c(const double *slow,
double *tt,
const int nz, const int nx,
const double zsrc, const double xsrc,
const double dz, const double dx,
const int... |
C | #pragma once
//ͨCSPʵļAES_128ӽܹ
#include "stdafx.h"
#include <windows.h>
#include <wincrypt.h>
#define BLOCK_SIZE 1024
#define ALG_SYM_ALGO CALG_3DES
/*****************************************************
*EncryptFile
* ܣļ
* ΣPCHAR szSource, ܵļ
PCHAR szDestination, ܺļ
PCHAR passwd); ܿ
* Σ
*ֵBOOLTRUΪܳɹFALSE... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* args_check.c :+: :+: :+: ... |
C | #include <stdio.h>
#include <stdlib.h> /* exit(0); */
/*
Ǻθ Լ recursive function
: ڱ ڽŸ Ǻθ Լ
Լ θ ̰ ڵѴ.
*/
int main()
{
int a;
while(1)
{
printf("\n ϰ ϴ ԷϽÿ.");
printf("\nԷ ϰ, 0 ԷϽÿ.");
printf("\n\nԷ : ");
scanf("%d",&a);
if(a==0) /* Էµ 0̸ α . */
exit(0);
printf("%d! =",a);
printf(... |
C | #include <stdio.h>
int main(void) {
int n;
scanf("%d", &n);
int i, prev, curCount = 1, maxCount = 1;
if (n == 1) {
printf("1");
return 0;
}
scanf("%d", &prev);
for (i = 1; i < n; i++) {
int cur;
scanf("%d", &cur);
if (cur > prev) curCount++;
else {
if (curCount > maxCount) maxCount = curCount;
... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <signal.h>
#include <errno.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <unistd.h>
#define PORT "3490"
#define BACKLOG 10 //how many pending connections in queue
void sigchld_handler(int s)
{
... |
C | /*
û
û
*/
#include "user.h"
struct machine_structure Machine_Structure; //ṹ
struct input_structure Input_Structure ={120,0}; //ṹ
struct led_struct{
u16 timer;
u8 flag; //b1=1,˸;b1=0ֹͣ˸,b2=1ÿ2˸һ
u8 Blue_LED_on;
} LED_Struct;
/*
void User_Timer1S(void)
û1붨ʱ붨ʱ
*/
void User_Timer1s(void)
... |
C | /*Задача 18:
Направете сериализация и десериализация на структурата
typedef struct Person{
char name[20];
int age;
char gender;
}t_person;
в XML формат по показания в лекцията начин.*/
#include <stdio.h>
#define SIZE 20
static const char *FORMAT_PERSON_IN = "(%[^,], %d, %c)\n";
static const char *FORMAT_PERSON_OUT = "... |
C | #include <stdio.h>
int main(){
int *p;
int num = 12345;
p = #
printf("num is = %d\n", num);
printf("num address is = %p\n", &num);
printf("pointer value is = %p\n", p);
printf("pointer indicates value %d\n", *p);
*p = 23456;
printf("num is = %d\n", num);
printf("num address i... |
C |
int reverse(int,int);
int main(int argc, char* argv[])
{
int sz[5][5],n,m,i,j,e[5];
for(i=0;i<5;i++){
for(j=0;j<5;j++){
scanf("%d",&sz[i][j]);
}
}
scanf("%d%d",&m,&n);
if(reverse(n,m)==0){
printf("error\n");
}else{
for(j=0;j<5;j++){
e[j]=sz[n][j];
sz[n][j]=sz[m][j];
sz[m][j]... |
C | #include <stdio.h>
#include <string.h>
int main ()
{
FILE *origin;
FILE *result;
char c;
result = fopen("escribir.txt", "e");
origen = fopen("leer.txt", "l");
if ( origin == NULL){
printf("Error\n");
return 1;
}
while((c=getc(origin)) != EOF)
{
if (c == '/')... |
C | //1. Write a program in C to display the first 10 natural numbers.
#include<stdio.h>
#include<conio.h>
int main()
{
int i;
printf("The first ten natural numbers are:");
for(i=1;i<=10;i++)
{
printf("\n%d",i);
}
getch();
}
|
C | #include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
pthread_mutex_t mutex = PTHREA_MUTEX_INITIALIZER;
pthread_cond_t cond = PTHREA_COND_INITIALIZER;
void *thread1( void * );
void *thread2( void * );
int i = 1;
int main( int argc, char *argv[] )
{
pthread_t t_a, t_b;
pthread_create( &t_a, NULL, thread1, ... |
C | #include<stdio.h>
int main()
{
int x=13,y;
y= x++ + x++;
printf("%d\n",y);
printf("%d\n",x);
return 0;
} |
C | /*@A (C) 1992 Allen I. Holub */
#include <stdio.h>
#include <tools/debug.h>
#include <tools/set.h>
#include <tools/hash.h>
#include <tools/compiler.h>
#include <tools/l.h>
#include "parser.h"
/* FIRST.C Compute FIRST sets for all productions in a symbol table.... |
C | #ifndef __TYPES__
#define __TYPES__
#include <stdint.h>
typedef uint8_t u8; /* Unsigned types of an exact size */
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8; /* Signed types of an exact size */
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;
typedef u16 ... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* raycasting.c :+: :+: :+: ... |
C | #include <stdio.h>
#include <string.h>
#include <strings.h>
#include <ctype.h>
#include <stdlib.h>
#include <cs50.h>
int main(int argc, string argv[])
{
//checks if a letter repeats in string from command line argument
// Take one letter
for (int i = 0; i < strlen(argv[1]); i++)
{
// Compare that lette... |
C | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef enum {
INTEGER = 0, REAL, NAN
}Type;
typedef struct __Number {
Type t;
union {
int i;
double r;
}data;
}Number;
typedef enum {
ADD = 0, SUB, MUL, DIV
}Operation;
Number calculate(Number n1, Number n2, Operation op)
{
Number result;
switc... |
C | #include <stdio.h>
#include "ChainedList.h"
int main() {
ChainedList* list = chndlstEmpty();
printf("%d\n", chndlstLength(list));
chndlstDisplay(list);
chndlstAddValueAtEnd(list, 18);
printf("%d\n", chndlstLength(list));
chndlstDisplay(list);
chndlstAddValueAtEnd(list, 19);
printf("%d\... |
C | #include <iostream>
#include <fstream>
#include <stdlib.h>
#include <iomanip>
using namespace std;
const char* sortName = "quickSort";
const int MIN = 10;
const int MAX = 100000;
const int FILE_SIZE = 100;
const char* executionTime = "Nguyen_Hung_timeOfExecution.txt";
void generateFile(){
cout << "Randomly generatin... |
C | #ifndef CHTBL_H
#define CHTBL_H
#include <stdlib.h>
#include <List/list.h>
//定义链式哈希表(chained hash tables)结构体
//@buckets 表示坑位
//@函数指针h 指定哈希函数,为了尽可能的散列
//@table 是哈希表本身
typedef struct CHTbl_{
int buckets;
int (*h)(const void *key);
int (*match)(const void *key1, cons... |
C | int min (int num1, int num2) {
return (num1 < num2) ? (num1) : (num2);
}
int minimumDistances(int a_count, int* a) {
int ref = 100000;
int res = ref;
for (int i = 0; i < a_count; i++) {
for (int j = (i + 1); j < a_count; j++) {
if (a[i] == a[j]) {
... |
C | #include<stdio.h>
void main(){
int a;
printf("Size of integer before assignment is %d\n",sizeof(a));
a = 6636;
printf("Size of integer after assignment is %d\n",sizeof(a));
}
//memory occupied by integer does not depend on whether its assigned a value or not
|
C | #include "stdio.h"
/*
Write a program that, given a date, three ints (for example, 11 27 1997),
will print the number of that day within its year:
i.e. Jan 1st is always 1, Dec 31st is either 365 or 366.
The months of the year have lengths according to the following rules:
- The odd months up to and including month ... |
C | #include "set.h"
#include <stdio.h>
#include <stdlib.h>
typedef struct NodeS {
setElementT data;
struct NodeS *next;
} Node;
struct setCDT {
Node *head;
int size;
};
setADT setNew()
{
/* Allocate A */
setADT A;
A = (setADT) malloc(sizeof(struct setCDT));
if (A == NULL)
return NULL;
... |
C | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdint.h>
#include <inttypes.h>
#include <pthread.h>
int size;
unsigned long **matrix1;
unsigned long **matrix2;
unsigned long **resMatrix;
unsigned long random_int(int min, int max, int seed)
{
srand( seed ... |
C | /*
20设头指针为L的带有表头结点的非循环双向链表,
其每个结点中除有pred(前驱指针)data(数据)和next(后继指针)域外,还有一个访问频度域freq。
在链表被启用前,其值均始化为零。每当在链表中进行一次 Locate(L,x)运算时,令元素值为x的结点中freq域的值增1,
并使此链表中结点保持按访问频度非增(递减)的顺序排列,同时最近访问的结点排在频度相同的结点的前面,以便使频繁访问的结点总是靠近表头。
试编写符合上述要求的 Locate(L,x)运算的算法,该运算为函数过程,返回找到结点的地址,类型为指针型
*/
//思想:在双向链表中查找数据值为x的节点,查到后将节点从链表上摘下,然后再顺着节点的前驱链查找到... |
C | #include<stdio.h>
int a[7]={};
FILE *fp;
char c;
int allplus(int x)
{int i;
for (i=1; i<=6; i++)
a[i] += x;
return 0;
}
int check()
{int i;
for (i=1; i<=6; i++)
if (a[i] >= 100)
a[i] = 100;
return 0;
}
int scan()
{int i;
printf("Ҵҹսô(1/0):\n... |
C | #include <stdio.h>
int top=-1;
char a[20];
int push(char);
int main(){
int n,i,flag=0;
char c;
scanf("%d",&n);
fflush(stdin);
for (i=0;i<n;i++){
scanf("%c",&c);
if (c=='('||c=='{'||c=='['){
push(c);
}
else if ((c==')'&&a[top]=='(')||(c=='}'&&a[top]=='{')||... |
C | #include "expr_assert.h"
#include "assignment.h"
int fibo(int numberOfTerms,int *numberNeeded){
int a = -1,b = 1,i,c;
for(i=0;i<numberOfTerms;i++){
c = a + b;
numberNeeded[i] = c;
a = b;
b = c;
}
if(numberNeeded[0] == 0)
return 1;
return 0;
}
int concat(int *array1, int len_of_array1, int *array2, int ... |
C | #include <avr/io.h>
#include "config.h"
#include "light.h"
#include "uart.h"
#include "history.h"
uint8_t handle_light(const char *cmd, char action) {
log_cmd(cmd, action);
int mask = 0;
char c = cmd[1];
// set bits in mask according to pins that should be changed
if (c == '*') {
mas... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.