language large_stringclasses 1
value | text stringlengths 9 2.95M |
|---|---|
C | /*
Given a positive integer n, find the pivot integer x such that:
The sum of all elements between 1 and x inclusively equals the sum of all elements between x and n inclusively.
Return the pivot integer x. If no such integer exists, return -1. It is guaranteed that there will be at most one pivot index for the given... |
C | /*
Author:Alphonce F. Stephano
Email/: alphoncesteven@gmail.com
Company-Group: afsaTech || SuperMesh
*/
#include <stdio.h>
int factorial(int numb)
{
if(numb > 1)
{
return numb*factorial(numb-1);
}
else {
return 1;
}
}
int main(void)
{
int numb;
tryagain:
printf("Enter an integer number 1 and 10 inclusive:")... |
C | #include <stdio.h>
#define dprint(expr) printf("<main>"#expr"=%d\n",expr)
#define DPRINT(fmt,args...) printf(fmt,###args)
#define paste(front,back) front##back
int main(int argc, const char *argv[])
{
int x = 100, y=2, name1 = 100;
dprint(x/y);
dprint(x+y);
dprint(x+y+2);
printf("name1 = %d \n", ... |
C | #include "hclib.h"
int ____num_tasks[32] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
# include <stdlib.h>
# include <stdio.h>
# include <math.h>
# include <time.h>
# include <string.h>
# include "poisson.h"
# include "main.h"
# include "timer.h"
double r8mat_... |
C | /*Implemente uma função que receba como parâmetro um array de números reais de
tamanho N e retorne quantos números negativos há nesse array. Essa função deve
obedecer ao protótipo:
int negativos(float *vet, int N);*/
#include<stdio.h>
#include<stdlib.h>
#define tam 9
int negativos(float*, int);
int main(int argc, char ... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lm_path_utils.c :+: :+: :+: ... |
C | #include <iostream>
#include <fstream>
#include <vector>
//#include "MyFunc.h"
using namespace std;
//!targetFile.eof()
unsigned long long gcd(unsigned long long a, unsigned long long b)
{
for (;;)
{
if (a == 0) return b;
b %= a;
if (b == 0) return a;
a %= b;
}
}
unsigned l... |
C | #include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define PI 3.14159265
typedef long double Typ;
struct point{Typ x, y, z; struct point * next;};
#define Point struct point
Point * make_Point(Typ X, Typ Y, Typ Z)
{
Point * nowy = malloc(sizeof(Point));
nowy->x=X;
nowy->y=Y;
nowy->z=Z;
nowy->next =... |
C | #include <stdio.h>
//prototipo da funcao
int somar(int a, int b);
int subtrair(int a, int b);
int multiplicar(int a, int b);
int dividir(int a, int b);
int somar(int a, int b){
return a+b;
}
int subtrair(int a, int b){
return a-b;
}
int multiplicar(int a, int b){
return a*b;
}
int dividir(int a, int b){
if (b != 0 ... |
C | #include<stdio.h>
#include<stdlib.h>
#define MAX 10007
int queue[MAX];
int rear = -1;
int front = -1;
void insert(int item);
int del();
int peek();
int isEmpty();
int isFull();
void display();
int main(){
int choice,item;
while(1){
printf("1.Insert\n");
printf("2.Delete\n");
printf("3.Displ... |
C | #pragma once
#define Z 4
#define MODULE(x) x<0?x*(-1):x
#define LOGIC(z) z > 3
#define STEPEN(x, y) pow(x, y)
#define SQRT(x) sqrt(x)
#define MAX(y,z) ((y)>(z))?(y):(z) //
#define MIN(y,z) ((y)<(z))?(y):(z)
#define PRINTI(w) puts("control output"); \
printf(#w"=%d\n",w)
// '\'
// '#' ᒺ
//
#define... |
C |
float maximum(float a, float b)
{
return (a>b)?a:b;
}
float funct(float a, float b)
{
return (a>b)?maximum(a,b):b;
}
int SIZE=1024;
int main()
{
#ifdef __NVCUDA__
acc_init( acc_device_nvcuda );
#endif
#ifdef __NVOPENCL__
acc_init( acc_device_nvocl );
//acc_list_devices_spec( ac... |
C | #include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
int n;
int i,j,a[n],temp;
//n=5;
printf("enter number");
scanf("%d",&n);
printf("enter elements");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=n-1;i>=0;i--)
{
j=i-1;
if(a[i]<a[j] && a[j]-a[i]==1)
{
temp=a[i];
a[i]=a[j];
a[j]=t... |
C | // Child process (or Player) for the "mind game".
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
void winhandler(int sig)
{
// you have won
fprintf(stderr, "You have won.\n");
// pid_t ppid = ... |
C | #include <stdio.h>
/*
Create a smartphone register application
* Read the content of smartphones.txt and store the informations in a structure called "smartphone:
* - the name of the gadget (which is shorter than 256 characters) (Don't bother with the underscore('_') character, it's the part of the name)
* - the year o... |
C | /*
* File: fileio.c
* Author: Brendan McCane
* Updated: Scott 2003
* Updated: Raymond 2005
* Updated: David 2014
*
* Description: Contains the I/O routines.
*/
/* ----- INCLUDES ---------------------------------------------------------- */
/* standard libraries */
#include <stdio.h>
#include <stdlib.... |
C | #include<stdio.h>
int main(void){
int sum=1;
int a=0,b=1,n;
printf("Enter the nth term: ");
scanf("%d",&n);
printf("Fibonacii series till n:\n ");
while (sum<=n){
printf("%d\t",sum);
a=b;
b=sum;
sum=a+b;
}
//return 0;
}
|
C | #include <stdio.h>
#include <stdlib.h>
typedef struct node{
int val;
struct node * next;
}Node;
Node * sumLists(Node *, Node *);
void printList(Node * head);
void push(Node ** head_ref, int data);
void free(Node * head);
int main(void){
Node * head1 = NULL, * head2 = NULL, * summed = NULL;
push(&head1, 3);
... |
C | #include<stdio.h>
void main()
{
int a,b;
printf("Enter 2 numbers: ");
scanf("%d %d",&a,&b);
a^=b^=a^=b;
printf("After swapping :a = %d b = %d",a,b);
}
|
C | #include <stdio.h>
#include <pthread.h>
pthread_t thread1, thread2;
void *fn1(void *arg){
int i = *(int *)arg;
printf("i = %d\n", i);
return ((void *)0);
}
struct parameter{
int size;
int count;
};
struct parameter arg;
void *fn2(void *arg){
struct parameter *pstru;
pstru = (struct parameter *) arg;
prin... |
C | #include <stdio.h>
void printd(int no);
int main()
{
int no = 0;
printf("Enter the number\n");
scanf("%d", &no);
printd(no);
return 0;
}
void printd(int n)
{
if (n < 0)
{
// /putchar('-');
n = -n;
}
printf("%d ", (n % 10));
if (n / 10)
{
printd(n / 10);
}
} |
C | /* chronos/hvdf.c
*
* HVDF Single-Core Scheduler Module for ChronOS
*
* Author(s)
* - Nahush Gondhalekar nahushg@vt.edu
*
* Copyright (C) 2009-2012 Virginia Tech Real Time Systems Lab
*/
#include <linux/module.h>
#include <linux/chronos_types.h>
#include <linux/chronos_sched.h>
#include <linux/list.h>
struct ... |
C | /*
* programs.h
*
* Author: rebecca
*/
#ifndef PROGRAMS_H_
#define PROGRAMS_H_
Instruction program1[] = {
Instruction(increment, LONG, a1, a1, k, 0),
Instruction(increment, LONG, a2, a2, k, 1),
Instruction(multiply, SHORT, x0, x1, x1, 2),
Instruction(multiply, SHORT, x6, x0, x2, 3),
Ins... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* check_quotes.c :+: :+: :+: ... |
C | /*************************************************************************
> File Name: create.c
> Author: Wangyao
> Mail: Yaowang_future@163.com
> Created Time: 2015年03月20日 星期五 21时26分19秒
> Function: 创建链表
************************************************************************/
#include "stud.h"
... |
C | #include <stdio.h>
#include <stdlib.h>
int* mergeEven(int M,int *arr1,int N,int *arr2)
{
int *merArr = malloc(sizeof(M+N)),index1=0,index2=0;
for(int index=0;index<M+N;index++)
{
if(arr1[index1]%2!=0)
merArr[index]=arr1[index1++];
else{
merArr[index]=arr1[index1++];
... |
C | #include "errors.h"
/* Global method which receive errorCode and lineIndex if exists and print error according to error type*/
void printError(const char* currFileName, ERROR_CODE errorCode, int lineIndex){
static char* fileName;
if (errorCode == INITIALIZING) {
fileName = calloc(strlen(curr... |
C | #include <assert.h>
#include <math.h>
#include "quaternion_exp.h"
VOID_t
quaternion_exp(const Quaternion_t* q, Quaternion_t* output)
{
assert(output != NULL);
Real64_t s;
Real64_t e;
Real64_t fq1Squared = q->fy * q->fy;
Real64_t fq2Squared = q->fz * q->fz;
Real64_t fq3Squared = q->dt * q->dt;
... |
C |
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <mpi.h>
#include "gui.h"
#include "nbody.h"
#define STRINGIFY1(x) #x
#define STRINGIFY(x) STRINGIFY1(x)
#if !defined(BUILD_PAR) && !defined(BUILD_SEQ) && !defined(BUILD_UNIT)
#define BUIL... |
C | //1. eloforditoi direktiva
#include <stdio.h>
#include <stdlib.h>
//2. fv. prototipus
//void arfolyamBekerese(double *arfolyamok, int meret);
void arfolyamBekerese(double *, int);
//void arfolyamBekerese(double arfolyamok[], int meret);
//void arfolyamokKiirasa(double *arfolyamok, int meret);
void arfolyamokK... |
C | #include<stdio.h>
#include<ctype.h>
void main(){
int len = 0;
char ch;
printf("Enter a sentence:");
while((ch = tolower(getchar())) != '\n'){
if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u'){
len++;
}
}
printf("Your sentence contains %d vowels.\n", len);
}
|
C | //3.1 Circular Queue, front->enqueue, rear->dequeue, simple array, compromising one place (0th index at start)
#include<stdio.h>
#include<stdlib.h>
#define SIZE 5
int rear=0,front=0;
void enqueue(int a[],int e)
{
if((rear+1)%SIZE==front)
{
printf("Queue Full\n");
}
else
{
rear = (rear+1)%SIZE;
a[rear]=e;
... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* float_flag.c :+: :+: :+: ... |
C | #include "alias_map.h"
#include "config.h"
#include "debug.h"
#if NODE == TBC
#define BITWORD 8
#define SHIFT 3
#define MASK 0x07
static u8t alias_map[1 + TBIM_NUM/BITWORD];
static u8t first_free=1;
static u8t test(u8t i)
{
return alias_map[i >> SHIFT] & (1 << (i & MASK));
}
/**************... |
C |
#include <stdint.h>
#include <math.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "apcilib.h"
#define DEVICEPATH "/dev/apci/pcie_da16_6_0"
#define BAR_REGISTER 2
int apci;
//------------------------------... |
C | #include <stdio.h>
#include <string.h>
int vis[10];
int valid(int x) {
int y = x % 10;
int z = x / 10;
return x >= 10 && x < 100 && !(y == z || vis[y] || vis[z]);
}
int use(int x) {
return valid(x) && (vis[x % 10] = vis[x / 10] = 1);
}
void unuse(int x) {
vis[x % 10] = vis[x / 10] = 0;
}
void r... |
C | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int n;
srand(time(0));
n = rand() % 100 + 1;// Generate a random number between 1 to 100
printf("The number is %d", n);
scanf("%d", &n);
// keep running until number is guesssed
return 0;
} |
C | #include<stdio.h>
int main(void){
char c[100]; int i=0,x=0,d=0;
printf("ingrese el numero \n");
gets(c);
while(c[i]!='\0'){
if (c[i]=='0'||c[i]=='1'||c[i]=='2'||c[i]=='3'||c[i]=='4'||c[i]=='5'||c[i]=='6'||c[i]=='7'||c[i]=='8'||c[i]=='9')
x++;
else
d++;
i++;
}
printf("la cantidad de d... |
C | #include<stdio.h>
int swap(int *p, int *q)
{
return 0;
}
int main()
{
int a=10,b=20;
int *temp,*p,*q;
p=&a;
q=&b;
temp = p;
p=q;
q=temp;
printf("a=%d, b=%d\n",a,b);
printf("*p=%d, *q=%d\n",*p,*q);
return 0;
} |
C | #include<stdio.h>
int main()
{
float s1,s2,s3;
printf(" Enter 3 sides of the Triangle : \n");
scanf("%f%f%f",&s1,&s2,&s3);
if( s1<=s2+s3 || s2<=s1+s3 || s3<=s1+s2 )
{
printf("\nTriangle is valid.");
}
else
{
printf("\nTriangle is not valid.");
}
return 0;
}
|
C | // this code sets up counter1 for an 4kHz, 10bit, Phase Corrected PWM
// @ 16Mhz Clock
#include <avr/io.h>
#include <util/delay.h>
int main(void){
DDRC |= 0xEF;
// PC4 is now an input, everything else is an output
DDRB |= 0x03;
// PB1 is now an output
PORTC |= (1<<PC0) | (1<<PC1) | (1<<PC2);
... |
C | #include<stdio.h>
#include "intstack.h"
int main(){
IntStack s;
if(Initialize(&s, 64) == -1){
puts("failed to excute stack.");
return 1;
}
while(1){
int menu,x;
printf("data space: %d/%d\n",Size(&s),Capacity(&s));
printf("(1)Push (2)Pop (3)Peek (4)Print (0)Exit: ");
scanf("%d",&menu);
... |
C | #include <stdio.h>
/* Return 1 when any odd bit of x equals 1; 0 otherwise
Assume w=32 */
int any_odd_one(unsigned x) {
return !!(0x55555555 & x);
}
/*
int main(void)
{
for(int i = 0; i < 64; i++)
printf("%d %d\n", i, any_odd_one(i));
}
*/
|
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* print.c :+: :+: :+: ... |
C | #include <stdio.h>
#include <stdlib.h>
#include <tagfs.h>
#include <errno.h>
int main(int argc, char *argv[]) {
char buf[255];
int result;
result = getcwt(buf, 255);
if(result == -1) {
switch(errno) {
case ENOSYS:
printf("Function has not been implemented. Did you insert the tagfs module?\n");
break;
... |
C | #include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<string.h>
#define STACK_INIT_SIZE 100
#define STACKINCREMENT 10
#define MAXNUM 100
typedef char SElemType ;
typedef enum{
ERROR,
OK,
OVERFLOW
}Status;
typedef struct {
SElemType *base;
SElemType *top;
int stacksize;
}SqStack;
//create a new st... |
C | #include <stdio.h> /* Standard Library of Input and Output */
#include <complex.h> /* Standard Library of Complex Numbers */
#include <locale.h>
int main()
{
setlocale(LC_ALL, "");
double complex z1 = 1.0 + 3.0 * I;
double complex z2 = 1.0 - 4.0 * I;
printf("\t\tTrabalhando com nmeros complexos:... |
C | // *********************************************************************************
// ***** Christopher Crews - February 2012 ********
// ***** Program Name: main.c ********
// ***** main - initalizes all the hardware and veriables. it sets up ********
// ***** and starts all the threads. this c file... |
C | #include "holberton.h"
/**
* main - make change with infinite amounts of 25, 10, 5, 2 and 1.
* @argc: The number of arguments.
* @argv: The argument vector.
*
* Description: makes change given an infinite ammount of coins of 25, 10, 5, 2
* and 1. Implemented with a greedy algorithm.
* Return: 1 if ... |
C |
void merge_seq(int *A, int n1, int *B, int n2, int* C);
void mergesort_seq(int *A, int start, int end, int* aux);
void merge_seq(int *A, int n1, int *B, int n2, int* C){
int i = 0;
int j = 0;
while(i < n1 && j < n2){
if(A[i] <= B[j]){
C[i+j] = A[i];
i++;
}else{ // A... |
C | #include <stdio.h>
#include <stdlib.h>
int main(void) {
int i, carry, tmp;
char *init, *current;
init = (char*) malloc(10000001);
current = (char*) malloc(10000001);
scanf("%s %s", init, current);
carry = 1;
for (i = 0; current[i] != 0; i++) {
tmp = (current[i] == init[i] ? 0 : 1) + carry;
carry = tmp > 1... |
C | /*
The Robot Arm Manager receives requests to grasp objects at specific points in
space (x, y, z) and time (t). It first computes an arm trajectory via the and
produces a set of nSteps actions (up to 100). Each action is composed of a set
of commands to each of the seven servos. If the goal is achievable, then Robot
Ar... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
int palindromo(char * string, int ini, int fim);
int main()
{
char strPalindromo[200];
printf("Digite a expressao");
gets(strPalindromo);
int fim = strlen(strPalindromo);
int retorno = palindromo(&strPalindromo, 0, fim -1);
if(retorno >0)... |
C | #include <stdio.h>
int menu()
{
int flag = 0;
int type = 0;
printf("**************************************主菜单*****************************************\n");
printf("(1)系统管理菜单\n");
printf("(2)出入库管理菜单\n");
do {
printf("请输入1或2选择菜单:");
scanf("%d", &flag);
if (flag != 1 && fla... |
C | #include<stdio.h>
using namespace std;
int main() {
int a = 1025;
int* p = &a;
printf("p = %d\n", p);
printf("p+1 = %d\n", p + 1);
printf("value at p = %d\n", *p);
char* p0;
p0 = (char*)p;
printf("p0 = %d\n", p0);
printf("p0+1 = %d\n", p0 + 1);
printf("value at p0 = %d\n", *p0);
printf("value at p0+1 = %d\n"... |
C | /*
* lcd.c
*/
#include "../LCD/lcd.h"
#include "../../MCAL/Dio/Dio.h"
#include "../../MCAL/Dio/Dio_Types.h"
#include "../../MCAL/Dio/Dio_config.h"
void lcd_command(uint8 cmd){
Dio_write(RS,Low);
Dio_write(RW,Low);
//DIO_Write(lcd_en,low);
GET_BIT(cmd,7)?Dio_write(D7,High):Dio_write(D7,Low);
... |
C | /* practice10.c */
#include<stdio.h>
#include<stdlib.h>
int main()
{
int i = 88;
int *ptr = &i;
printf("i=%d\n", i);
printf("*ptr=%d\n\n", *ptr);
*ptr = *ptr + 12;
printf("i=%d\n", i);
printf("*ptr=%d\n\n", *ptr);
return 0;
}
|
C | #include <stdio.h>
#include <stdlib.h>
/*
int main()
{
int fact=1,num;
printf("enter the number\n");
scanf("%d",&num);
for(int i=1;i<=num;i++)
fact *= i;
printf("factorial of %d is %d\n",num,fact);
return 0;
}
*/
// using recursion
int fact(int);
int main()
{
int num,ans;
printf("ent... |
C | #ident "@(#)convert.c 1.7 96/08/16 SMI" /* From AT&T Toolchest */
/*
* CONVERT.C
*
*
* LTOU (STR1, STR2)
* Copy STR1 to STR2, changing lower case to upper case.
*
* UTOL (STR1, STR2)
* Copy STR1 to STR2, changing upper case to lower case.
*/
#include "csi.h"
#ifdef KSHELL
#include "shtype... |
C | /* Copyright (c) 1990 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */... |
C | /*********************************************************************/
/* PhotoLab.c: homework assignment #3, for EECS 22, Fall 2017 */
/* */
/* Author: Mina Moghadam */
/* Date: 11/8/2017 ... |
C | #include<sys/ahci/ahci.h>
#include<sys/ahci/ahcicommands.h>
#include<sys/memory/mm_struct.h>
#include<string.h>
#include<sys/memory/free_phys_pages.h>
HBA_PORT hba_port = {0};
HBA_MEM hba_mem = {0};
static int check_type(HBA_PORT port);
int print_hba_mem(HBA_MEM *hba_mem);
void port_rebase(HBA_PORT *port, int portno,... |
C | /* Author: smohi002
* Partner(s) Name:
* Lab Section:25
* Assignment: Lab #4 Exercise #3
* Exercise Description: [optional - include for your own benefit]
*
* I acknowledge all content contained herein, excluding template or example
* code, is my own original work.
*/
#include <avr/io.h>
#ifdef _SIMULATE_
#i... |
C | /*
* Here is the layout of this file:
*
* - Format description
* - Global data
* - Error-handling routines
* - Parsing routines
* - Main function
*/
/*
* Format description
* ------------------
*
* There are several basic commands. When they take parameters, those parameters
* will be in the form of hexad... |
C | #ifndef _RTC_ //
#define _RTC_
static uint8_t _I2C_Time_Out; // -
static char _I2C_buf[6]; // /
static uint8_t _I2C_Error; //
//============= - ==============
unsigned char bin2bcd(unsigned char n)
{
return (n/10<<4)+(n % 10);
}
//==... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ftpf_unsigned_int_expander.c :+: :+: :+: ... |
C | #include "quest.h"
#include <string.h>
/* Definição da estrutura das perguntas (quest). */
struct quest{
long id; /* Id da quest. */
Date creationDate; /* Data de criação da quest. */
int score; /* Pontuação da quest. */
long ownerUserId; /* Id do user que elaborou a quest. */
char* title; /* Título... |
C |
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
#include<math.h>
#define max 200
#define size 5
#include"std_data.c"
#include"dissim.c"
static float cluster_setx[size][max],cluster_sety[size][max];
int find_mean(float mean_set[size][size])
{
static float meanx,meany,count;
for(int i=0;i<2;i+... |
C | //
// Created by Kuba Sokolowski on 12/07/2016.
//
#ifndef CHESSBOARD_MOVE_H
#define CHESSBOARD_MOVE_H
#include "Position.h"
struct Move {
Move(SpecialMoveType specialMoveType) : specialMoveType(specialMoveType) {};
Move(Position start, Position end, PieceType pieceType) : startPosition(start), endPosition(e... |
C | #include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <time.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/msg.h>
#include <sys/ipc.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#define RED "\033[0;31m"
#define GREEN "\033[32m"
#define DF "\033[0m"
/... |
C | /*****************************************************************
//
// NAME: Ehsan Kourkchi
//
// HOMEWORK: Project 1
//
// CLASS: ICS 212
//
// INSTRUCTOR: Ravi Narayan
//
// DATE: December 1, 2013
//
// FILE: hw09.c
//
// DESCRIPTION: This file contains the tcp header handling
// f... |
C | /*
* File: PWM.h
* Author: Asmaa Hashim
*
* Created on February 26, 2020, 11:43 AM
*/
#ifndef PWM_H
#define PWM_H
#include"PWM_HW.h"
#include"interrupt.h"
/*
* this enum contains all prescaller modes
*/
typedef enum{
PRE_1,
PRE_4,
PRE_16
}T2_CLK_DIV;
/*
* this enum contains interrupt modes... |
C | #define _CRT_SECURE_NO_DEPRECATE
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#include <fcntl.h>
#define MAXINODE 50
#define READ 1
#define WRITE 2
#define MAXFILESIZE 1024
#define REGULAR 1
#define SPECIAL 2
#define START 0
#define CURRENT 1
#define END 2
typedef struct superblock
... |
C | #include <stdio.h>
int main()
{
char ch;
puts("Would you like me to send your password to the bad guys?");
for (;;)
{
printf("Enter Yes or No (Y or N)?");
ch = getchar();
if (ch == 'N' || ch == 'n')
{
puts("Well then, your password is safe!");
break;
}
else if (ch == 'Y' || ch == 'y')
{
... |
C | /*!
@file float.c
@brief 浮動小数点の扱いで使う諸々のutility
*/
#include <stdio.h>
#include "float.h"
int32_t
f2i (float a)
{
union
{
float as_float;
int32_t as_int;
} ret;
ret.as_float = a;
return ret.as_int;
}
float
i2f (uint32_t a)
{
union
{
float as_float;
uint32_t as_int;
} ret;
re... |
C | #include <sys/resource.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <unistd.h>
#include <stdio.h>
#include <time.h>
#define U "Bubblesort" // 1
#define I "Insercao" // 2
#define S "Selecao" // 3
#define Q "Quicksort" // 4
#define H "Heapsort" // 5
#define M "Mergesort" // 6
typedef... |
C | #include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <dirent.h>
#include <string.h>
#include <unistd.h>
int main(){
DIR *dp;
FILE * wfp, *rfp;
struct dirent *dent;
char name_data, *file_data;
int i = 0, c;
if((dp = opendir("./sample")) == NULL){
perror("open");
exit(1);
}
chdir("sample"... |
C | #ifdef USE_QUADRATIC_HASH
#if defined(_MSC_VER) && defined(_DEBUG)
#define AVP_DUMP_MEM_LEAK
#endif
// Necessary includes and defines for memory leak detection:
#ifdef AVP_DUMP_MEM_LEAK
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_do_op.c :+: :+: :+: ... |
C | #include <stdio.h>
int isBitSet(int input, int bitpos) {
return ((input & (1 << bitpos)) ? 1 : 0);
}
int main() {
int input, position;
printf("Zahl eingeben: ");
scanf("%d", &input);
printf("Zu pruefende Stelle angeben (mit 0 beginnend): ");
scanf("%d", &position);
printf... |
C | #ifndef RNG_H
#define RNG_H
#ifdef __cplusplus
extern "C" {
#endif
/* Mersenne Twister pseudo-random number generator. Based on the
* implementation of src/common/Random.c of Cuba 1.4, itself an adaptation of
* the original C code of T. Nishimura and M. Matsumoto from
* http://www.math.sci.hiroshima-u.ac.jp/~m... |
C | /* test0c.c - launch EXAMPLE.BAS from C */
#include <mikeos.h>
/*
used MikeOS API :-
mikeos_get_file_size
mikeos_load_file
mikeos_run_basic
*/
/* filename and buffer must be on the static region */
static char FileName[] = "EXAMPLE.BAS";
static char Buf[8192];
/* test os_run_basic */
static void test_run_basic... |
C | void bubbleSort(int arr[], int n)
{
// Your code here
int temp;
for(int i=0;i<n;i++){
for(int j=0;j<n-i-1;j++){
if(arr[j]>arr[j+1]){
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
}
|
C | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <errno.h>
#include <netdb.h>
#include <arpa/inet.h>
int main(int argc , char *argv[])
{
int sockfd;
struct addrinfo hints, *servinfo, *p;
struct sockaddr_in *h;
int rc, ctr;
//if argc size is less than 2, then the hostna... |
C | #include <stdio.h>
#include <malloc.h>
#define STACKSIZE 4
typedef struct LIST {
int data;
struct LIST *next;
} LIST;
static int stack[STACKSIZE];
static int S_top;
static LIST *head,*tail;
void printstack(int *);
void printlist(LIST *);
void add(int x){
LIST *p1,*p2;
p2 = (LIST *)(malloc(sizeof(LIST)));
p... |
C | #include "simple_buf_alloc.h"
simple_buf_t *
simple_buf_alloc(simple_buf_t **pp_buf_freelist, size_t suggested_size) {
simple_buf_t *list_item = (*pp_buf_freelist);
if (list_item) {
(*pp_buf_freelist) = list_item->_next;
}
else {
list_item = malloc(suggested_size);
list_item->_base = (char *)(list_item + ... |
C | #include <stdio.h>
main()
{
hola();
printf("Hola, Mundo\n");
chau();
}
#include <stdio.h>
int hola() {
printf("Hola\n");
}
int chau() {
printf("Chau\n");
}
|
C | bool isMonotonic(int* A, int ASize)
{
int i,cnt=0;
for(i=0;i<ASize-1;i++)
{
if(A[i]<=A[i+1])
{
cnt++;
}
}
if(cnt==ASize-1) return true;
cnt=0;
for(i=0;i<ASize-1;i++)
{
if(A[i]>=A[i+1])
{
cnt++;
}
}
if(cnt==ASi... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* handle_unsigned_int.c :+: :+: :+: ... |
C | #include "structs.h"
int ft_find_unassigned_location(t_matrix *m, t_pos *p)
{
p->row = 0;
while (p->row < m->rows)
{
p->col = 0;
while (p->col < m->cols)
{
if (m->values[p->row][p->col] == 0)
return (1);
p->col++;
}
p->row++;
}
return (0);
}
|
C | //Program to evaluate a postfix expression.
#include<stdio.h>
#include<math.h>
int top=-1,top2=-1,stack2[50];
char stack[50],post[50],infix[50];
int ops(int x,int y,char op);
void push(char ele);
void push2(int ele);
char pop();
int pop2();
int isp(char ch);
int icp(char c);
void postfix();
void main()
{
int i=0,len,... |
C | #include<stdio.h>
#include<stdlib.h>
struct Array
{
int *A;
int size;
}object;
void init(int size)
{
object.size = size;
object.A = (int *)malloc(object.size * sizeof(int));
int i;
for(i=0;i<object.size;i++)
{
printf("Enter the Element\n");
scanf("%d",&object.A[i]);
}
}
void maximumElement()
{
int max,i;
... |
C | #include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
int main(int argc, char** argv) {
if(argc < 2) {
printf("%s <dir1> ... <dirN>\n", argv[0]);
return 1;
}
for(int i = 1; i < argc; ++i) {
pid_t chld = fork();
if(chld == 0) {
printf("%d:\n", getpid());
execlp("ls", "ls", argv[i], NULL);
} e... |
C | #include <stdio.h>
#include "domainOferta.h"
#include <errno.h>
#include <string.h>
#include <assert.h>
void validate(Oferta *off, char erori[]) {
char idErr[] = "Id invalid!\n", typeErr[] = "Tip invalid!\n", priceErr[] = "Pret invalid!\n", dateErr[] = "Data invalida!\n";
errno = 0;
if (off->id < 0)
{
strcat(ero... |
C | #include <stdlib.h>
#include <stdio.h>
#include "mem.h"
#include "timer.h"
#include "flexstack.h"
#define LENGTH 10
#define RESIZE_LENGTH 15
int main()
{
int i;
int data;
flexstack_t stack;
timer_t timer = timer_new();
timer_start(timer);
stack = flexstack_new(LENGTH,sizeof(int));
for(i = 0;i < LENGTH; i++)... |
C | #include <stdbool.h>
#include <string.h>
#include "i2c.h"
#include "gpio.h"
#define BUFFER_SIZE 256
#define WRITE 0
#define TIMINGR_CLEAR_MASK 0xF0FFFFFFU
typedef struct {
uint16_t addr;
uint8_t buf[32];
size_t n;
} i2c_msg;
static I2C_TypeDef *handle;
static void init_sda_pin() {
gpio_af_init(I2C_SDA_GPIO_POR... |
C | /*
* --------------------------------------
* Ŭ ȣ ( #2) *
* --------------------------------------
*/
#include <stdio.h>
int gcd(int,int);
int main(void)
{
int a,b;
printf(" Էϼ. : ");
scanf("%d %d",&a,&b);
printf("ִ=%d\n",gcd(a,b));
return 0;
}
int gcd(int m,int n)
{
if (n==0)
... |
C | /*题目:八进制转换为十进制*/
#include<stdio.h>
#include<stdlib.h>
int main()
{
int n=0,i=0;
char s[20];
printf("请输入一个8进制数:\n");
gets(s);
while(s[i]!='\0'){
n=n*8+s[i]-'0';
i++;
}
printf("刚输入的8进制数转化为十进制为\n%d\n",n);
return 0;
}
|
C | // hello.c
// compile gcc hello.c
// run ./a.out
#include <stdio.h>
int main(){
printf("********************* Hello World ***********************************\n");
printf("* from *\n");
printf("* GGGGGGGGG BBBBBB PPPPPP MM ... |
C | #include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
const int MIN_BLOCK_SIZE = 128;
const int MAX_BLOCK_SIZE = 512;
const int MIN_BLOCKS = 1024;
const int MAX_BLOCKS = 128*1024;
const int MAX_NUM_FILES = 256;
int is_power2(int n){
if(n == 0) return... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.