language large_stringclasses 1
value | text stringlengths 9 2.95M |
|---|---|
C | /* author: Tony Lai */
/* EXERCISE 2-6~8 */
#include <stdio.h>
#include <string.h>
#define MAXLINE 15 /* A SMALL NUMBER FOR TESTING */
int c, i, lim, stop, n;
enum boolean {NO, YES};
char s[] = "hellosdgngfrh";
char s1[] = "g";
char *test;
int o;
int atoi(char a[]);
unsigned setbits( unsigned x, ... |
C | HTML file :
<html>
<body>
<form action="slip22_2.php" method="get">
<center>
<table>
<tr><td>Enter 1st String : </td><td><input type="text" name="str1"></td></tr>
<tr><td>Enter 2nd String : </td><td><input type="text" name="str2"></td></tr>
<tr><td>Enter String To Replace : </td><td><input type="text"... |
C | #include<stdio.h>
#include<ctype.h>
int main()
{
int a;
printf("Enter a character \n");
scanf("%[^\n]",&a);
if (isalpha(a))
{
printf("the entered character is an alphabet \n");
if (islower(a))
{
printf("the entered character is a lowercase alphabet \n");
}
else
{
printf("the entered character ... |
C | #include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <semaphore.h>
#include "unistd.h"
#define N 10 //número de usuários
#define CARTAS 20 //quantidade de cartas na mochila
void * f_usuario(void *arg);
void * f_pombo(void *arg);
sem_t pombo;
sem_t cartas;
sem_t local;
sem_t voar;
int cards = 0... |
C | #include <stdio.h>
#include <stdlib.h>
#define rows_length 750
int main()
{
FILE* tp;
int i = 0;
int males = 0, females = 0, mr = 0, fr = 0, amage = 0, afage = 0, hage = 0, amweig = 0, afweig = 0, yage, obesep = 0, obesem = 0, obesef = 0;
int mbm1, mbm2, mbm3, ambm1 = 0, ambm2 = 0, ambm3 = 0, fbm1, fbm2... |
C | /*
* Copyright (c) 2010 Luca Abeni
*
* This is free software; see gpl-3.0.txt
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "int_coding.h"
#include "payload.h"
#include "config.h"
#in... |
C |
#include "stm32f10x.h" //使用STM32标准函数库需要添加此头文件
#include "stdio.h"
#include "stdout_USART.h"
void ADC_RCC_Init(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA |
RCC_APB2Periph_ADC1 , ENABLE ); //使能ADC1 通道时钟
RCC_ADCCLKConfig(RCC_PCLK2_Div6); //设置ADC 分频因子6,72M/6=12,ADC 最大时间不能超过14M
}
void ADC_GPIO_Init(void)
{
... |
C | #include <stdio.h>
int main()
{
int grid[3][3];
int row,col;
/* initialize the array */
for(row=0;row<3;row++)
for(col=0;col<3;col++)
grid[row][col] = 0;
grid[1][1] = 1;
/* display the grid */
for(row=0;row<3;row++)
{
for(col=0;col<3;col++)
printf("%d ",grid[row][col]);
putchar('\... |
C | #include<stdio.h>
int main()
{
int a;
printf("enter number:");
scanf("%x",&a);
a=(a<<24 & 0xFF000000)| (a>>24 & 0x000000FF)| (a<<8 & 0x00FF0000)| (a>>8 & 0x0000FF00);
printf("%x\n",a);
}
|
C | /******************************************************************************
* Filename : wd_outer.c
* Developer : Eyal Weizman
* Last Update : 2019-05-18
* Description : source file for the outer WD process.
*******************************************************************************/
#define _POSIX_C_SOURCE 200... |
C | #include <stdio.h>
int insert_num(int a[],int size,int num,int ind)
{
int n1,n2;
size++;
if(ind>=0&&ind<size)
{
n2=size-1;
for(n1=size;n1>ind;n1--)
{
a[n1]=a[n2];
--n2;
}
a[ind]=num;
}
else
{
printf("\nEnter the correct index....");
return 0;
}
return size;
}
int main(void)
{
int a[20],si... |
C | //====================================================================
// 工学部「情報環境実験1」(富永) 例題
// 多倍長整数の計算 除算と応用
//--------------------------------------------------------------------
// BigNum BigNumDiv.c
// ライブラリ
// Linux GCC 4.4
//--------------------------------------------------------------------
// 富永研究室... |
C | /*
* Trabajo.h
*
* Created on: 3 may. 2021
* Author: Julian Leandro Nieva 1C
*/
#ifndef TRABAJO_H_
#define TRABAJO_H_
#define MAX_TRABAJOS 10
#include "Fecha.h"
#define IS_EMPTY 0
#define NOT_EMPTY 1
typedef struct
{
int id;
int idMascota;//fk
int idServicio;//fk
int idVeterinario;//fk
eFecha fecha... |
C | /* 軭 */
#include "bootpack.h"
void init_palette(void)
{
static unsigned char table_rgb[16 * 3] = {
0x00, 0x00, 0x00, /* 0:\ */
0xff, 0x00, 0x00, /* 1: */
0x00, 0xff, 0x00, /* 2: */
0xff, 0xff, 0x00, /* 3: */
0x00, 0x00, 0xff, /* 4: */
0xff, 0x00, 0xff, /* 5: */
0x00, 0xff, 0xff, /* 6:dz */... |
C | #include <stdio.h>
#include <stdlib.h>
void main()
{
int a=86;
int b=21;
printf("%d \n",a/b);
float c=86.0;
float d=21.0;
printf("%f \n",c/d);
} |
C | #include<stdio.h>
#include<stdlib.h>
int main(){
FILE *fp=fopen("./0.bin","rb");
fseek(fp,0,SEEK_END);
int dat_size = ftell(fp)/sizeof(short);
fseek(fp,0,SEEK_SET);
unsigned short *dat;
dat = (unsigned short *)malloc(dat_size*sizeof(short));
fread(dat,sizeof(short),dat_size,fp);
f... |
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 <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
#include <syslog.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
int ReservarMemoriaComp(int n);
void* MapearMemoriaComp(int n);
int CrearSemaforos(int n, short* vals);
void Borr... |
C | #include "isr.h"
/** init_isr
* Initialize the exception interrupts
*/
void init_isr()
{
void *isrs[ISR_NUM] = {
&isr0, &isr1, &isr2, &isr3, &isr4, &isr5, &isr6,
&isr7, &isr8, &isr9, &isr10, &isr11, &isr12, &isr13,
&isr14, &isr15, &isr16, &isr17, &isr18, &isr19, &isr20,
&isr21, &isr22, &i... |
C | /*
* vasprintf.h
*
* Created on: 9 May 2017
* Author: egriffiths
*/
#ifndef LIBLIMESUITE_SRCMW_VASPRINTF_H_
#define LIBLIMESUITE_SRCMW_VASPRINTF_H_
#define _GNU_SOURCE
#define __CRT__NO_INLINE
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
int my_vasprintf(char ** __restric... |
C | /*
Minimum for spectrum chi2. Each phase needs a minimum to include a total systematic uncertainty for flux measurement.
The best fit point is sin_2_theta = 0.310, ms12 = 4.8e-5.
Weiran, Mar. 27, 2018.
*/
#include "../chi2SK.h"
#include "TH2D.h"
#include <iostream>
#include "TMinuit.h"
#include <sstream>
#incl... |
C | /**
* @file hds_error.h
* @brief This file defines error codes which will be used throughout hds.
* @author Tej
*/
#ifndef HDS_ERROR_H_
#define HDS_ERROR_H_
#ifndef HDS_DTYPES_H_
#include "hds_dtypes.h"
#endif
/**
* @enum error_codes_t
* @brief Defines error codes
*/
typedef enum {
HDS_ERR_HDS_STATE_INIT ... |
C | #include <assert.h>
#include <getopt.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <db/common/dberror.h>
#include <db/common/try.h>
#include <db/server/server.h>
#define PORT 5000
#define BACKLOG 16
#define NTHREADS 16
#define DBDIR "db"
struct server_options server_optio... |
C | #include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int i;
printf("SSAAP -> Small and Simple Application Arguments Printer\n\n");
for(i = 0; i < argc; i++)
{
printf("%d: \"%s\"", i, argv[i]);
}
printf("\n\n");
printf("(c) 2013");
return 0;
}
|
C | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "alloc.h"
#include "statemachine.h"
#include "literal.h"
char *SVM_TypeToStr(val_t dval) {
doubleunion_t val;
static char tmp[64];
val.d = dval;
switch (val.p.type) {
case TYPE_NUMBER:
return "number";
case TY... |
C | #include<stdio.h>
#include<conio.h>
void main()
{
int n1,n2,minmul;
printf("enter numbers");
scanf("%d %d",&n1,&n2);
minmul=(n1>n2)?n1:n2;
while(1)
{
if(minmul%n1==0 && minmul%n2==0)
{
printf(%d %d %d",n1,n2,minmul);
break;
}
++minmul;
}
getch();
}
|
C | #ifndef _PUMPS_H_
#define _PUMPS_H_
#include <Arduino.h>
#include "timer.h"
typedef enum pumps_state {
PUMP_IDLE,
PUMP_ACTIVE,
PUMP_STOPPED
} pumps_state;
typedef struct pumps
{
int pin;
unsigned long timeout_time;
pumps_state state;
timer pump_timer;
} pumps;
/* ---------------------------- PROTOTYPES ----... |
C | #include <stdio.h>
int main()
{
int i;
double now, sum = 0;
for(i = 0; i < 12; ++i) {
scanf("%lf", &now);
sum += now;
}
printf("$%.2lf\n", sum/12);
return 0;
} |
C | int main(){
int n,m[1000],i;
scanf("%d",&n);
char a[1000][256];
for(i=0;i<n;i++){
scanf("%s",a[i]);
m[i]=strlen(a[i]);}
for(i=0;i<n;i++)
{for(int j=0;j<m[i];j++){
if(a[i][j]=='T') a[i][j]='A';
else if(a[i][j]=='A') a[i][j]='T';
else... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
// жǷཻԼ㽻: list1:1 2 3 4 5 6 7 8 9, list2:12 13ӵlist1һ
// 1. һwhileһforȾཻ
//2.ijȣd=L1-L2, dȣȻͬʱֵͬ¼λã˵ཻ
typedef struct student{
int num;
struct student* pnext;
}stud,*pstud;
void list_tail_insert(pstud*,pstud*,int);
void list_pr... |
C | #include <stdio.h>
#include <fcntl.h>
#include "get_next_line.h"
int main(int argc, char **argv)
{
int fd;
int ret;
char *line;
size_t i;
if (argc <= 1)
fd = 0;
else
fd = open(argv[1], O_RDONLY);
i = 0;
while ((ret = get_next_line(fd, &line)) > 0)
{
printf("|%s|\n", line);
free(line);
i++;
}
pr... |
C | #include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int i,diem[20],n;
printf("nhap so mon(ko qua 20):\n");
scanf("%d",&n);
for(i=0;i<n;i++){
printf("diem mon thu %d:",i+1);
scanf("%d",&di... |
C | #include <stdio.h>
#define SIZE 7
int graph[SIZE][SIZE] = {
{999, 6, 5, 5, 999, 999, 999},
{999, 999, 999, 999, -1, 999, 999},
{999, -2, 999, 999, 1, 999, 999},
{999, 999, -2, 999, 999, -1, 999},
{999, 999, 999, 999, 999, 999, 3},
{999, 999, 999, 999, 999, 999, 3},
{999, 999, 999, 999, 999, 999, 999}
};
... |
C | #include "set.h"
#include "uarray.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
//#include "bitpack.h"
#include "ummem.c"
#include "umop.c"
#include "assert.h"
void check_newfree();
void check_length();
void check_storeload();
int main(int argc, char* argv[]){
/*if(argc != 2){
fprint... |
C | #include "svdpi.h"
#include "veriuser.h"
/*
* 2-state bit selects
*/
void bitsel_2state_test(svBitVecVal *val, int bi)
{
svBit sb;
sb = svGetBitselBit(val, bi);
io_printf("2-state val[%d]=%d\n", bi, sb);
/* now zero the bit */
svPutBitselBit(val, bi, 0);
/* one some bits */
svPutBitselBit(val, 20, 1);
svPut... |
C | #include <stdio.h>
#include <string.h>
struct student {
char name[15];
int age;
float mark;
};
void read_data(struct student arr[], int n);
void print_data(struct student arr[], int n);
int read_data_w_ptr(struct student* stru_ptr);
int main(void) {
struct student class[10];
printf("Welcome!!\n");
for (i... |
C | /*
* =====================================================================================
*
* Filename: ex6.c
*
* Description:
*
* Version: 1.0
* Created: 06/03/2013 10:25:11 AM
* Revision: none
* Compiler: gcc
*
* Author: Eli Gundry
*
* ==================... |
C | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include "../src/z_circular_buffer/z_circular_buffer.h"
#define LOOP_COUNT ( 4096 << 10 )
#define PRODUCER_THREAD_NUM 1
#define CONSUMER_THREAD_NUM 1
#define PERF_TRHEAD_NUM 1
#define TOTAL_THREAD_NUM ( PRODUCER_THREAD_NUM + \
... |
C | #include <stdio.h>
#include <string.h>
void main(){
int a[3];
int x;
a = [1 || 0,1 && 0,!0];
for(x=2;x>-1;x--){
printf("%d \t",a[x]);
}
return;
}
|
C | #include "/players/stark/defs.h"
inherit "/room/room.c";
int snake;
reset(arg) {
snake = 0;
if (arg) return;
set_light(1);
short_desc="A dimly lit forest";
long_desc=
" Light pours down from the heavens above. A slit in the green \n"+
"fabric of trees flows above the stream. You stand on a log that \n"+
"co... |
C | #include "FIT_RANGE.h"
#include "stdio.h"
#ifndef XES
#ifdef GSM
#include "../../interface/intergsm.h"
#else
#include "../../interface/interface.h" /* C++ class header */
#endif
#endif
#ifndef _DATATYPE_H
#define _DATATYPE_H
#include "../../include/datatype.h"
#endif
/*---------------------------------------------
... |
C | #include"defs.h"
int isWindow (double firstPacketWindowTime, double packetWindowTime , double windowLength){
double tFinal;
tFinal = firstPacketWindowTime + windowLength;
if (packetWindowTime <= tFinal)
return 0;
else
return 1;
}
|
C | #include <stdio.h>
int main()
{
int a;
float b;
char c;
char d[255];
// printf("address of a: %p\n",&a);
// printf("address of b: %p\n",&b);
// printf("address of c: %p\n",&c);
// printf("address of d: %p\n",d);
//printf("Please give a character: ");
//scanf("%c", &c);
//p... |
C | #include <stdio.h>
void josephusHelper(int n);
void josephus(int n, int arr[], int max);
void shift(int n, int arr[], int index);
int main() {
int a;
printf("How many soldiers are there: ");
scanf("%d", &a);
josephusHelper(a);
return 0;
}
void josephusHelper(int n) {
int arr[n];
for (int i = 0; i < n; i++... |
C | #ifndef STRING_INTERNING
#define STRING_INTERNING
struct _string {
size_t len;
const char *str;
};
static struct _string *table = NULL;
const char *str_intern_slice(const char *str, size_t len)
{
struct _string *s;
if (table == NULL)
goto push;
... |
C | /*********************************************************************************/
/* Course: Advanced Programming for Physics (2020-2021) */
/*********************************************************************************/
/* The program numerically computes the integral of the following... |
C | // Exercise 3 from chapter 6
// This program receives two integers from the user and shows the result of dividing the first by the second.
#include<stdio.h>
int main( void )
{
int num1, num2;
printf( "Enter two integer numbers separated by a blank space:\n" );
scanf( "%i %i", &num1, &num2 );
if( nu... |
C | //Функция strlen видит начало Си-строки и начинает сначала считать количество
//символов (байтов, отводимых под каждый символ), этот процесс выполняется
//до тех пор, пока не будет достигнут завершающий нулевой символ
//#include "../libft.h"
//#include "stdafx.h" //Для работы с VS12 C++11
//#include <stdio.h>
//#in... |
C | #include <stdio.h>
int main(void)
{
int ary[10] = { 31,41,59,26,53,58,97,23,84 };
printf("בւȌԁF");
for (int i = 0;i < 10;i++) {
printf(" %d", ary[i]);
}
printf("\n");
int tmp = 0;
for (int i = 0;i < 9;i++) {
for (int n = 0;n < 9 - i;n++) {
if (ary[n] > ary[n + 1]) {
tmp = ary[n];
ary[n] = ary[... |
C | /*
File Name: : main.c
Device : PIC32MM0256GPM048
Compiler : XC32 2.05
MPLAB : MPLAB X 4.15
Created by : http://strefapic.blogspot.com
*/
#include <xc.h>
#include "mcc_generated_files/mcc.h"
#include <stdio.h>
#include <stdlib.h>
#inclu... |
C | #include<stdio.h>
#include<conio.h>
main()
{
int i,len,n;
char a[110][110];
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%s",&a[i]);
for(i=0;i<n;i++)
{
len=strlen(a[i]);
if(len>10)
{
printf("%c%d%c",a[i][0],... |
C | /******************************************************************************
* Student Name : Brearne Gibson
* RMIT Student ID : s3496168
*
* Startup code provided by Paul Miller for use in "Programming in C",
* Assignment 2, study period 2, 2020.
************************************************************... |
C | /*! \file main.c
*
* Author: Javier Montenegro (https://javiermontenegro.github.io/)
* Details: program file for methods implementation.
*/
#include "common.h"
extern void client(const char* hostname, const unsigned int port, char *username);
int main(int argc, char *argv[])
{
//TODO: use ... |
C | /* UNIX "timer" driver for NOS, for reckoning time and delivering timer events
* when NOS is hosted locally on a UNIX machine.
*
* Copyright 2017 Jeremy Cooper, KE6JJJ.
*
* Timer devices are traditionally interrupt driven in NOS. But since
* this is a UNIX driver there are no interrupts to receive. Instead, we wi... |
C | ///////////////////////////////////////////////////////////////////////////////////
// The MIT License (MIT)
//
// Copyright (c) 2017 Tarek Sherif
//
// 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... |
C | /*
** EPITECH PROJECT, 2020
** dele.c
** File description:
** myftp
*/
#include "myftp.h"
#include <fcntl.h>
void dele(char *file, client_t *client, server_t server)
{
if (!client->is_connected)
return (send_message("530 Need connection\r\n", client->socket));
if (!file)
return (send_message("... |
C | #include "intro_state.h"
#include "util.h"
void play_intro_state()
{
WINDOW *intro = newwin(0, 0, 0, 0);
// window's background color
wbkgd(intro, COLOR_PAIR(7));
// fake loading :)
print_in_middle(intro, "loading...");
wrefresh(intro);
// play some useless animation
loading_animation(intro, 1);
// spl... |
C | /**
@file
circle.c - same as line modulo 360.
Etienne Démoulin - 2020.
this object has 1 inlet and 2 outlets
it responds to ints and floats in inlet. output a line in the first outlet / bang when done in the second outlet.
@ingroup demoul
*/
#include "ext.h" // you must include th... |
C | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "hash.h"
unsigned int hash(char *s){
unsigned int h;
unsigned char *p;
h=0;
for(p=(unsigned char *)s;*p!='\0';p++)
h= MULTIPLIER *h + *p;
return h%HASH_SIZE;
}
PROG_CELL lookup(char *s){
int index = hash(s);
while (table[... |
C |
//基础函数库:直线 实现
//=========================
//-------------------------------------------------------------------------------
#include <stdio.h>
#include <math.h>
#include "line.h"
#include "graph.h"
#include "window.h"
#include "calc.h"
static int __graph_line_calc_center(struct graph_line *cthis)
//维护中心点信息
{
... |
C | //recursive fibonacci variant - tail recursion
#include <stdio.h>
int fibonacciTR( int , int , int );
int main( void )
{
int term = 5;
printf( "fibonacci(%d) = %d" , term , fibonacciTR( term , 0 , 1 ) ); //only in c++ you can supply default argument
return 0;
}
int fibonacciTR( int n , int a , int b )
{
... |
C | /*
ClockIt TEXT. A modification by Dave Parker to ClockIt
written by Nathan Seidle at Spark Fun Electronics
A basic alarm clock that uses a 4 digit 7-segment display. Includes alarm and snooze.
Alarm will turn back on after 9 minutes if alarm is not disengaged.
To switch to text display, press and ho... |
C | #include "holberton.h"
/**
* _strspn - function that gets the length of a prefix substring.
* @s: prefix string
* @accept: returns number of bytes
* Return: Always 0.
*/
unsigned int _strspn(char *s, char *accept)
{
unsigned int b, a = 0;
while (s[a])
{
b = 0;
while (accept[b] && s[a] != accept[b])
b++;... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* int_handle_2.c :+: :+: :+: ... |
C | /**
* @file Login.h
* @author your name (you@domain.com)
* @brief Header file of login
* @version 0.1
* @date 2021-04-07
*
* @copyright Copyright (c) 2021
*
*/
/**
* @brief User created header file
*
*/
#include "HeaderFile.h"
/**
* @brief function for updating login details
*
*/
int login();
/**
... |
C | //Program to implement queue using two stacks
#include <stdio.h>
#define max 4
int stack1[max];
int stack2[max];
int top1 = -1;
int top2 = -1;
int gt;
//Function to push the element into the stack1
void push1(int element){
if(top1==max-1){
printf("overflow");
}else{
stack1[++top1] = element;
... |
C | /*
* 1-19.c
*
* Created on: Sep 24, 2009
* Author: Abhijith
*/
#include<stdio.h>
#define MAXLENGTH 1000
int getline(char line[], int lim);
void reverse(char string[], char rev[]);
int main()
{
char line[MAXLENGTH], rev[MAXLENGTH];
int len;
while ((len = getline(line, MAXLENGTH)) > 0)
... |
C | /* Program name: Discount.c
Author: Atish Jain
Task: Calcualte Discount and Final amount
*/
# include <stdio.h>
main()
{
int sales,dis,famt;
sales=dis=famt=0;
printf("Enter Sales Amount....:");
scanf("%d",&sales);
if(sales>=25000)
dis=sales*10/100;
else
dis=sales*5/100;
... |
C | /*
** Program-chaining function for Commodore platforms.
**
** This copy of the cc65 system library function makes smaller code by using
** Contiki's Personal File System (instead of POSIX) functions.
**
** 2016-03-16, Greg King
**
** This function exploits the program-chaining feature in CBM BASIC's ROM.
**
** CC65's ... |
C | /* In our program's we'll need to make decisions. One of the easiest ways
to do this in C is to use the "if statement". Here we provide a condition
that the run time evaluates. If the condition is satisfied and evaluates
to true, then the block of code associated with the statement is
executed. If not, then the block ... |
C | #include <stdio.h>
#include <math.h>
int isPrime(int n){
int i=2;
int ret = 1;
if(n<2)
return 0;
if(n==2)
return 1;
while(i<=(int)sqrt((double)n) && ret){
ret = !(n%i==0);
i++;
}
return ret;
}
int main(){
unsigned long sum=0;
int i;
for(i=2; i<2000000; i++)
sum += (isPrime(i)) ? i : 0;
printf("%l... |
C | #include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <stdio.h>
#include <ctype.h>
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <pthread.h>
#include <errno.h>
#include <math.h>
#define BUFSIZE 256
pthread_t allThreads[100]; //stores the handles of all thr... |
C | #include <stdio.h>
int main(){
float a = 0, b = 0, c = 0, d = 0;
scanf("%f %f %f %f", &a, &b, &c, &d);
float x = 0;
if(a <= b){
if(b > c){
x = (a + b + d) / 3;
if(x >= 7){
printf("Aprovado com %.1f\n",x);
}else{
printf("Final co... |
C | #include <stdlib.h>
#include <string.h>
#include "files.h"
#include "io.h"
void add_to_file(FILE *file, char *string)
{
int exit_code = OK;
char *word;
while (!read_string(&word, file))
{
read_string(&word, file);
if (!strcmp(word, string))
exit_code = 1;
free(word... |
C | #include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <limits.h>
#include <pthread.h>
#include <string.h>
int producers;
int consumers;
int buff_size;
int min_line_length;
int max_work_time;
int search_mode;
int info_mode;
char **buffer;
pthread_mutex_t *buff_mutex;
pthread_mutex_t prod_mutex;
pthread_... |
C | #include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netdb.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>
#include <time.h>
FILE *dbg;
int sockfd, visItsockfd[1024], address_len;
socklen_t vis... |
C | //Bora Mutluoglu | bmutluog | 1564633 | cs12b | March 17, 2018 |
//Dictionary.c implementation using hash tables instead of previously
//used ADT/Linked Lists/BST implementations.
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<assert.h>
#include"Dictionary.h"
// private types, hash functions given b... |
C | typedef struct
{
school data;
struct node * right, * left;
}node ;
//insert
void insert(node ** tree, school val)
{
node *temp = NULL;
if(!(*tree))
{
temp = (node *)malloc(sizeof(node));
temp->left = temp->right = NULL;
temp->data = val;
*tree = temp;
retu... |
C | #include <linux/module.h>
#include <linux/fs.h>
#include <linux/poll.h>
#include <linux/errno.h>
#include <linux/debugfs.h>
#include <linux/jiffies.h>
#include <linux/semaphore.h>
#define EUDYPTULA_ID "123456789012\n"
#define EUDYPTULA_ID_SIZE 13 /* EUDYPTULA_ID length */
MODULE_LICENSE("GPL");
MODULE_AUTHOR("EK")... |
C | /**
* *leet - function that encodes a string into 1337
* @str: string for encryption
* Return: string encrypted
*/
char *leet(char *str)
{
char letter_lower[6] = {'a', 'e', 'o', 't', 'l'};
char letter_uper[6] = {'A', 'E', 'O', 'T', 'L'};
char code[6] = {'4', '3', '0', '7', '1'};
int i, j;
for (i = 0; str[i]... |
C | #include "header.h"
static gboolean change_password_and_all_encryption(const gchar* old_pwd_entry, const gchar* new_pwd_entry);
/*
We call init_option_window() when our program is starting to load
option window with references to Glade file.
*/
gboolean init_option_window()
{
GtkBuilder *builder;
GEr... |
C | #include <stdio.h>
#define NUMBER 5
// 对元素个数为n的int型数组v进行倒序排列
void rev_intary(int v[], int n)
{
int temp;
for (int i = 0; i < n / 2; ++i) {
temp = v[i];
v[i] = v[n - i - 1];
v[n - i - 1] = temp;
}
}
int main(void)
{
int i;
int vx[NUMBER];
for (i = 0; i < NUMBER; ++i) {... |
C | #include <linux/sort.h>
#include <linux/slab.h>
/*sort utilization from highest to lowest*/
static int util_sort(const void* l, const void* r){
struct subtask sub1=*(struct subtask*)(l);
struct subtask sub2=*(struct subtask*)(r);
if(sub1->utilization>sub2->utilization) return -1;
else if(sub1->utilization<sub2->uti... |
C | /* 線形リストの利用例 */
#include <stdio.h>
#include "Member.h"
#include "LinkedList.h"
/* メニュー */
typedef enum {
TERMINATE, INS_FRONT, INS_REAR, RMV_FRONT, RMV_REAR, PRINT_CRNT,
RMV_CRNT, SRCH_NO, SRCH_NAME, PRINT_ALL, CLEAR
} Menu;
/* メニュー選択 */
Menu SelectMenu(void)
{
int i, ch;
char *mstring[] = {
"先頭にノードを挿入", ... |
C | #include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
#include "chop_line.h"
#include "list.h"
void watchBgProcesses(list_t* bg_pids_list){
struct list_node_t* node = bg_pids_list->head;
while(node != NULL){
int s... |
C | /*
Cell Plan
Kyle George
1-15-2020
*/
#include <stdio.h>
//Calculate a rate given an amount of data and an amount of time.
double calculateRateOfUse(int days, int amount) {
return (double)amount/(double)days;
}
//Executable Code
int main(void) {
//Variable Definitions
int totalGigs = 0; //Amount of data the us... |
C | #define UNUSED(x) x __attribute__ ((unused))
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
#include "interface.h"
#include "lib/lib.h"
// Storing executable path
char exec_path[1024];
size_t exec_path_len;
int load_commands(char UNUSED(*dir_name)) {
if(!getcwd(exec_path, 1024)) {
... |
C | #include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
int pipe_fd[2];
pid_t pid;
int ret = 0;
char r_buf[4];
char w_buf[4];
ret = pipe(pipe_fd);
if (ret < 0)
printf("pipe fail\n");
memset(r_buf, 0, sizeof(r_buf));
memset(w_buf, 0, sizeof(w_buf));
pid = fork();
if (... |
C | #include<stdio.h>
#include<malloc.h>
struct node
{
int data;
struct node *next;
}*head=NULL,*current,*first=NULL,*temp,*temp1,*ptr,*ptr1,*rslt=NULL,*rslt1,*rslt2,*p,*q,*r;
int w;
void result(int m,int n)
{
int z,a,b,d;
z=n+m;
if(rslt==NULL)
{
rslt1=(struct node*)malloc(sizeof(struct nod... |
C | #include "server.h"
Graph* initialise(int size)
{
// Create a graph
Graph* g = (Graph *)malloc(sizeof(Graph));
g->n = size;
g->graph = malloc(size * sizeof(Node));
// Initialise each node to NULL
for (int i = 0; i < size; i ++)
{
g->graph[i].head = NULL;
g->graph[i].prev =... |
C | //Program to contruct a BST from given preorder traversal
//This is the recursive approach
//It uses min_int max_int approach to construct the tree in O(n) time
//Assumption is made that all elements are distinct
#include <stdio.h>
#include <stdlib.h>
#define LARGE 10000
struct Node{
int data;
struct Node *l... |
C | /* * Funo : Programa com a fuo dizer se uma gangorra esta ou no equlibrada,
levando em considerao o comprimento das extremidades e o peso das pessoas.
* Autores: Denilson Higino da Silva | RGM: 36712
Fernando Oliveira de Lima | RGM: 36716
* Data : 07/05/2017
_________________________... |
C | #include "utils.h"
#include <API.h>
//#include <ctype.h>
#include <string.h>
//
// Updates the given variable with the current time in microseconds,
// and returns the time difference in seconds.
//
float timeUpdate(unsigned long *microTime)
{
unsigned long newMicroTime = micros();
float change = (newMicroTime - ... |
C | #ifndef __MATHCONSTANT_H__
#define __MATHCONSTANT_H__
#ifdef _MSC_VER
#define _USE_MATH_DEFINES
#endif
#include "math.h"
#include "stdlib.h"
// Constants for numerical routines
//
#define TINY 1.0e-30 // A small number
#define ITMAX 200 // Maximum number of iterations
#define E... |
C | #include <stdio.h>
main()
{
int i;
for (i = 1; i <= 4; i++)
{
printf("programacao\n");
}
}
|
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_vector_concat.c :+: :+: :+: ... |
C | #include "tests.h"
int
main(void)
{
TArray *arr = tarray_new(sizeof(s32));
for (s32 i = 0; i < 100; ++i) {
tarray_push(arr, i);
}
ASSERT(arr->size == 100);
for (s32 i = 0; i < 100; ++i) {
tarray_pop(arr);
}
ASSERT(arr->size == 0);
for (s32 i = 0; i < 100; ++i) {
tarray_push(arr, i);
}
tarray_eras... |
C | /*4.2 cwiczenia podpunktn 9 */
#include <LPC21xx.H>
#include <stdio.h>
#define MILI 4615
#define LED0_bm 0x10000 //16 bit ma wartosc 1
/*Funkcja odpowiedzialna za opoznienie
dla mojego kompilatora 1 ms to 4615 iteracji*/
void Delay(int iHowLong){
unsigned long int uiIntCounter;
char cCharIncrementation;
for(uiIntCo... |
C | #include<time.h>
#include<stdio.h>
#include<stdlib.h>
#define N 10
void Merge(int *a,int *L,int leftCount,int *R,int rightCount) {
int i,j,k;
i = 0; j = 0; k =0;
while(i<leftCount && j< rightCount) {
if(L[i] < R[j]) a[k++] = L[i++];
else a[k++] = R[j++];
}
while(i < leftCount) a[k++] = L[i++];
while(j < r... |
C | #include "lib_ccx.h"
#include "ccx_common_option.h"
#include "dvb_subtitle_decoder.h"
#include "utility.h"
#include <stdbool.h>
#ifdef WIN32
#include "..\\win_iconv\\iconv.h"
#else
#include "iconv.h"
#endif
//Prints a string to a file pointer, escaping XML special chars
//Works with UTF-8
void EPG_fprintxml(FILE *f,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.