language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
// 4.Write a program which accept number from user and count frequency of 4 in it. // Input : 2395 // Output : 0 // Input : 1018 // Output : 0 // Input : 9440 // Output : 2 // Input : 922432 // Output : 1 #include <stdio.h> int CountFour(int iNo) { int iDigit = 0; int iCnt = 0; while (iNo > 0) { ...
C
//inet函数族的使用 #include<stdio.h> #include<stdlib.h> #include<string.h> #include<sys/socket.h> #include<netinet/in.h> #include<arpa/inet.h> int main(void) { char buffer[32]; int ret = 0; int host = 0; int network = 0; unsigned int address = 0; char *str = NULL; struct in_addr in; in.s_addr = 0; //输入一个以.分隔...
C
#include <ctype.h> #include <math.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> bool finding_bracket(char* UKAZAT) //поиск скобки { int flag = 0; while (*UKAZAT != 10) { if (*UKAZAT == '(') { flag = 1; break; } UKAZAT++; }...
C
//24. FUA para ler o código da peça 1, a quantidade de peças 1, o valor unitário da peça //1, o código da peça 2, a quantidade de peças 2, o valor unitário da peça 2 e o //percentual de IPI a ser acrescentado ao valor de cada peça. Calcule o valor a ser //pago para cada peça e o valor total da compra. Escrever a quanti...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_next_line.c :+: :+: :+: ...
C
// Verificador de soluciones para instancias de Braun et al. // Parametros: <archivo_instancia> <archivo_sol> // El archivo de instancias DEBE llevar el cabezal con datos (NT, NM). // #include <stdio.h> #include <stdlib.h> #include <string.h> #define INFT 9999999999.0 #define NO_ASIG -1 #define SIZE_NOM_ARCH 1024 #d...
C
#include <stdio.h> #include <stdlib.h> int main() { int var1, var2, temp; printf("Inserire la variabile 1: "); scanf("%d", &var1); printf("Inserire l'variabile 2: "); scanf("%d", &var2); temp = var1; var1 = var2; var2 = temp; printf("La variabile 1 e' %d, la var...
C
//˵ͷջջʱֱָ̾Ϳ //ڽԪزʱ½ĽڵָָջָͿ #include<stdio.h> #include<stdbool.h> #include<malloc.h> typedef int elementype; typedef struct node{ elementype data; struct node *next; }stacknode, *linkstackptr; typedef struct stack{ linkstackptr top; //ջָ int count; // }Linkstack; /* ջSΪջ򷵻TRUE򷵻FALSE */ ...
C
#ifndef RANDOM_PALETTE #define RANDOM_PALETTE #include <tonc_video.h> #include <tonc_memmap.h> #define PALETTE_SIZE ( 248 ) typedef struct Palette { COLOR colors[PALETTE_SIZE]; // max of 256 colors in palette u8 index; // current index u8 length; // keeps track of how many colors have been added } Palett...
C
/*Chapter 9: Arrays, Practice example 2*/ /*Passing Array elements to a function*/ /*Demonstration of call by value*/ #include<stdio.h> void display(int); int main() { int i; int marks[] = {55, 65, 75, 56, 78, 78, 90}; for (i = 0; i <7; i++) { display(marks[i]); } return 0; } void disp...
C
#include <stdio.h> int cubeByValue(int n); void cubeByReference(int *nPtr); int main(int argc, char *argv[]) { int number = 5; printf("Valor original do numero: %d\n", number); cubeByReference(&number); printf("Novo valor do numero: %d\n", number); return 0; } int cubeByValue(...
C
#include<stdio.h> void Tower_of_Hanoi(int n,char x,char y,char z) { if(n>0) { Tower_of_Hanoi(n-1,x,z,y); printf("\n%c to %c",x,y); Tower_of_Hanoi(n-1,z,y,x); } } int main() { int n=3; Tower_of_Hanoi(n,'A','B','C'); }
C
#include <stdio.h> #include <stdlib.h> void resolution(FILE *p, int *X, int *Y) { fseek(p, 0, SEEK_SET); fscanf(p, "%d", X); fscanf(p, "%d", Y); printf("X, Y = %d, %d\n", *X, *Y); fseek(p, 0, SEEK_SET); } void lim_int(unsigned char **tab_interieur, unsigned char **contraste, int X, int Y, int *E, int *I) { int...
C
#include <stdio.h> char** os_argv; char* os_argv_last; void init_setproctitle() { char * p; size_t size; int i; size = 0; os_argv_last = os_argv[0]; for (i = 0; os_argv[i]; ++i) { if (os_argv_last == os_argv[i]) { size += strlen(os_argv[i]) + 1; printf("i:%d size:%d\n", i, size); os_argv_last = o...
C
/* * File: EEPROM.c * Author: True Administrator * * Created on February 22, 2017, 3:31 PM */ /* ============================================================================= This file contains the functions required to read and write to the EEPROM, the registers used to store permanent data ===================...
C
/** * @file inode.c * @brief accessing the UNIX v6 filesystem -- core of the first set of assignments */ #include <stdio.h> #include <string.h> #include <inttypes.h> #include "unixv6fs.h" #include "inode.h" #include "error.h" #include "sector.h" #include "bmblock.h" /** * @brief read all inodes from disk and print...
C
#include <stdlib.h> #include "stack.h" void push(struct stack* this,int input) { this->stk[++this->sp] = input; } int pop(struct stack* this) { return this->stk[this->sp--]; } struct stack* new_stack() { struct stack* stk = malloc(sizeof(struct stack)); stk->sp = -1; return stk; } void delete_stack(struct stac...
C
// // main.c // Types // // Created by 何洲 on 2019/5/10. // Copyright © 2019 何洲. All rights reserved. // #include <stdio.h> int main(int argc, const char * argv[]) { // char greeting[6] = {'H', 'e', 'l', 'l', 'o', '\0'}; // char greeting[] = "Hello"; char *greeting = "Hello"; printf("%s\n", greeting)...
C
#include <sys/stat.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include "events.h" #include "proto_s3.h" #include "sock.h" #include "warnp.h" #include "wire.h" struct put_state { int done; int failed; }; static int callback_done(void * cookie, int failed) { struct put_state * C = cookie; C->d...
C
#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #define D_LINE_TABLE_MAX 20 typedef struct LINE_TABLE_T { int LineBuffer[D_LINE_TABLE_MAX]; int LineTableLen; }LineTable_t; static LineTable_t LineTable = {{0}, 0}; void PrintLineTable(void) { printf("\nTable value :\t"); for...
C
#ifndef OBJ_LOAD_H #define OBJ_LOAD_H #include "model.h" #include <stdio.h> /** * Load OBJ model from file. */ int load_model(Model* model, const char* filename); /** * Count the elements in the model and set counts in the structure. */ void count_elements(Model* model, FILE* file); /** * Read the elements of...
C
#include <mctop.h> #include <getopt.h> const size_t msize = (2 * 1024 * 1024LL); int main(int argc, char **argv) { int on = 0; if (argc > 1) { on = atoi(argv[1]); } printf("On node %d\n", on); // NULL for automatically loading the MCT file based on the hostname of the machine mctop_t* topo ...
C
/* * ---------------------------------------------------------------------------- * "THE BEER-WARE LICENSE" (Revision 42): * <joerg@FreeBSD.ORG> wrote this file. As long as you retain this notice you * can do whatever you want with this stuff. If we meet some day, and you think * this stuff is worth it, you can b...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* algo.c :+: :+: :+: ...
C
#include <stdio.h> #define MAXVAL 100 static int sp = 0; static double val[MAXVAL]; void printStack() { int len = sp; printf("stack content: "); while(len--) { printf(" %.8g", val[len]); } printf(" \n"); } void push(double f) { if (sp < MAXVAL) { val[sp++] = f; } ...
C
/*------------------------------------------------------------------------- * * jsonb_op.c * Special operators for jsonb only, used by various index access methods * * Copyright (c) 2014-2023, PostgreSQL Global Development Group * * * IDENTIFICATION * src/backend/utils/adt/jsonb_op.c * *------------------...
C
/* utility.c */ #include "zcc.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> void fexit(const char *format, ...) { puts(format); printf("\n"); exit(0); } static int isvar[][3] = { /* IR_ADD */ { 1, 1, 1 }, /* IR_SUB */ { 1, 1, 1 }, /* ...
C
#ifndef COLA_H #define COLA_H /** Definicion del tipo de elemento almacenado en la cola **/ typedef struct { char nombre[15]; char localizacion[15]; } TIPOELEMENTOCOLA; /** Estructura para la cola **/ typedef void *TCOLA; /** * Reserva memoria para una cola de datos con el tipo [TIPOELEMENTOCOLA]. * * @param...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* exec_port_cmd_arg_tab.c :+: :+: :+: ...
C
#include "../include/apue.h" #define BSZ 48 void fun(char* str, int size) { for (int i = 0; i != size; ++i) printf("%c", str[i]); printf("\n"); } #define TEST do { printf("测试:"); fun(buf, BSZ);} while (0) int main() { FILE* fp; char buf[BSZ]; memset(buf, 'a', BSZ - 2); buf[BSZ - 2] = '\0'; buf[BSZ - 1] = 'X'...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> int printRandoms(int l) { int num = rand() % 10 + l; printf("Number is ganerated.\n"); return num; } void guessNumber(int val) { int gus_no, chance = 1; while (chance < 9) //No of chances: 8 { printf("Now guess the number:-...
C
#include <stdio.h> int main() { char a[10],b[10]; int i,n,ele; scanf("%[^\n]s",a); for(i=0;a[i]!='\0';i++) { n++; } for(i=0;i<n;i++) { if(a[i]==' ') { ele=i; } } for(i=ele+1;i<=n;i++) { a[i-1]=a[i]; } for(i=0;i<=n;...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* unicode_conv.c :+: :+: :+: ...
C
#include <stdio.h> #include <sys/types.h> #include <unistd.h> #include <string.h> #include <sys/wait.h> int main() { for (int i = 0; i < 2; i++) // loop will run n times (n=5) { if (i == 0) { if (fork() > 0) { write(STDOUT_FILENO, "Hello ", 6); ...
C
/* * articulo.c * * Created on: 24 Jun 2020 * Author: Carlos */ #include <stdio.h> #include <stdlib.h> #include "IOdata.h" #include "articulo.h" #include "LinkedList.h" #include "parser.h" #include "controller.h" #define LENGTH 128 eArticulo* articulo_new() { eArticulo* this = (eArticulo*)...
C
#include <stdio.h> #include <string.h> #include <math.h> long long gcdl(long long m, long long n){ long long tmp; while(m>0){ tmp = m; m = n%m; n = tmp; } return n; } long long lcm(int m, int n){ return m*(n/gcdl(m,n)); } int main(){ int t,n,m; long long lc...
C
#include<stdio.h> #include<math.h> int main() { long int i,a,c,m,n,z,x[10000]; float y[10000],t; a = 1664525; //multiplier c = 1013904223; //increment m = 4294967296; //modulus z = 0; //#seed n = 10000; t=0; for (i=0;i<n;i++) { x[i]=z; z = (a*z+c)%m; //linear congruential random no generator if(x[i]>t) ...
C
#include <stdio.h> #include "lists.h" /** * listint_len - print all the elements of a list * @h: listint_t * Return: number of nodes */ size_t listint_len(const listint_t *h) { int i = 0; while (h) { h = h->next; i++; } return (i); }
C
#include<stdio.h> int main() { int i,n; while(scanf("%d", &n)==1){ int slug[n],level=0; for(i=0;i<n;i++) scanf("%d", &slug[i]); for(i=0;i<n;i++){ if(slug[i] < 10){ if(level<1) level = 1;} else if(slug[i]>=10 && sl...
C
#include "main.h" /** * clear_bit - sets a bit at an index to 0 * @n: the number * @index: index of bit to be cleared * Return: 1 or -1 */ int clear_bit(unsigned long int *n, unsigned int index) { if (*n == 0 && index == 0) { *n &= ~(1 << index); return (1); } else if (*n == 0 || index > 63) return...
C
#include <stdio.h> #include <stdlib.h> int main(){ int size=2; typedef struct { int x; float y; char c; } record; record *ptr,*ptr2; ptr=(record *)calloc(size,sizeof(record)); ptr->x=12;ptr->y=13.12;ptr->c='i'; /*ptr2=ptr; ptr->x=12;ptr->y=13.12;ptr->c='i'; printf("%d %f %c\n",ptr->x,ptr->y,p...
C
#include "strings.h" #include <stdlib.h> #include <stdio.h> #define MAXPATH 261 #define MAXCNT 10 #define MAXSIZE (MAXPATH*MAXCNT) int stok(char *str, char delim, char *ptr[], int size) { char *suf = str; ptr[0] = str; int i, j = 1; while( ( i = schr(suf, delim, size) ) >= 0 ) { suf[i] = '\0'; suf = suf + i +...
C
/* ** EPITECH PROJECT, 2021 ** mylist ** File description: ** string_list_concat */ #include <string.h> #include <stdlib.h> #include "mylist/string_list.h" static char *set_size_and_returns(char *str, size_t nmemb, size_t *length) { if (length) { *length = nmemb; } return str; } static size_t get...
C
#include "menu.h" #include "hash.h" #include "lista.h" #include "utils.h" #include <stdbool.h> struct comando { const char *nombre; const char *documentacion; ejecutar ejecutor; hash_t *subcomandos; }; struct menu { hash_t *comandos; }; comando_t *comando_crear(const char *nombre, const char *doc...
C
#include<stdio.h> #include<stdlib.h> const long long row = 100, col = 100; long long N, q, lastAnswer = 0; long long i = 0; long long *counter; void query1 ( long long *array[q], long long x, long long y ) { long long index = ( x ^ lastAnswer) % N; array[index][counter[index]++] = y; //printf("%lld. Value of arr...
C
/* Main program of calculator example. Simply invoke the parser generated by bison, and then display the output. */ #include <stdio.h> #include <string.h> #include "expr.h" #include "stmt.h" #include "scope.h" #include "param_list.h" #include "type.h" #include "decl.h" /* Clunky: Declare the parse function generated ...
C
#include <dlfcn.h> #include <stdio.h> #include <assert.h> #include <string.h> #include <stdlib.h> #define CCAT(x, y) x ## y #define CCAT2(x, y) CCAT(x, y) #define T1_CCAT(x) CCAT2(T1_PREFIX, x) struct router { short int res_code; T1 res_buf; }; void router_construct(struct router* r) { r->res_code = 0; ...
C
#include <stdio.h> #include <time.h> void cabecalho(){ FILE *arquivo = fopen("./data/graph.csv", "w"); if(arquivo == NULL){ printf("arquivo nao foi aberto\n"); }else{ fprintf(arquivo,"cliente,data,hora \n"); fclose(arquivo); } } void escreveArquivo(char *cliente){ time_t t...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include "point.h" void initPoint(Point2D *p) { p->x=0; p->y=0; } void setPoint(Point2D *p,int x,int y) { p->x=x; p->y=y; } int comparePoint(Point2D *p1,Point2D *p2) { if(p1->x==p2->x && p1->y==p2->y) return 1; else return 0; } double distEuclid(Point2D...
C
#include <msp430.h> // constants const char slaveAddrLED = 0x0012; // LED address const char slaveAddrLCD = 0x0014; // LCD address const char slaveAddrRTC = 0x0068; // RTC address const unsigned int lightThreshold = 130; // ADC value threshold to distinguish if light o...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <time.h> #define HEIGHT 105 #define WIDTH 160 #define IMMUTABLE_ROCK -1 #define ROCK 0 #define ROOM 1 #define CORRIDOR 2 #define MIN_NUMBER_OF_ROOMS 10 #define MAX_NUMBER_OF_ROOMS 25 #define MIN_ROOM_WIDTH 7 #define DEFAULT_MAX_ROOM_WIDTH 15 #define M...
C
#include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdio.h> #include <errno.h> #include <string.h> #include <unistd.h> #define logp(...) {printf("[%s:%d] ", __FILE__, __LINE__); printf(__VA_ARGS__);} #define BUFLEN 1024 #define MAXADDRLEN 256 #define PORT 8888 in...
C
/******************************************************************************* * Circular Buffer ******************************************************************************* * FileName: CircularBuffer.h * Dependencies: Compiler.h * Author: Fernando Lpez Lara - Labora...
C
/* Name: renderer Purpose: The renderer module allows for the visual representation of an entire model, or specific parts of the model based on the current state of the objects within the model-> Author: Tyrone Lagore Version: March 10, 2014 */ #include "defines.h" #include "renderer.h" #include "offsets.h" #includ...
C
#ifndef _VARIABLES_H #define _VARIABLES_H #include "banking.h" // Lets keep these odd numbers so null terminate makes even #define MAX_VAR_NAME 11 #define MAX_VAR_VAL 81 char* vars_get(char* name); void vars_set(char* name, char* value); void printVars(); DECLARE_BANKED(vars_get, BANK(4), char*, bk_vars_get, (char*...
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
/*############################################################# * File Name : cnt.c * Author : winddoing * Created Time : 2021年05月10日 星期一 16时08分42秒 * Description : *############################################################*/ #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <...
C
#include "holberton.h" /** ** print_square - print a diagonal. ** @size: input diagonal. ** Return: no return. **/ void print_square(int size) { int columna; int fila; int numeral = 35; if (size <= 0) { _putchar('\n'); } else { for (columna = 1; columna <= size; columna++) { for (fila = 1; fila <= size; fila++) { _...
C
#include "types.h" #include "stat.h" #include "user.h" #include "fcntl.h" #include "fs.h" void headbyte(char* path, long long int nBytes) { int fd; fd = open(path, O_RDWR); if(fd < 0) { printf(1, "Error: Cannot open fd %s\n", path); return; } char chr[1]; while(read(fd, chr, sizeof(char))) { if (nBytes =...
C
#include <p18f4550.h> #include "PWM_timer0.h" #define TOP_INT 65535 #define TOP_RAMPA 12000 #define LARGURA_TOTAL 53535 #define MAX_DUTY 240 #define MIN_DUTY 10 unsigned char *portA_p0; unsigned char mask_A; unsigned int true_duty0_A; unsigned char *portB_p0; unsigned char mask_B; unsigned int true_duty0_...
C
#include "gl_pixel.h" #include "log.h" const size_t gl_pixel_npos = -1; static const gl_pixel_config _pixel_configs[] = { {GL_RED, 1, -1}, {GL_RG, 2, -1}, {GL_RGB, 3, -1}, {GL_BGR, 3, -1}, {GL_RGBA, 4, 3}, {GL_BGRA, 4, 3} }; static const size_t _num_pixel_configs = sizeof(_pixel_configs) / sizeof(gl_pixel_co...
C
/*--------------------------------------------------------------------------*/ /*---------------- TREE STRUCTURE ------------------------------------------*/ /* definition of datatype reednode */ typedef struct REEDNode REEDNode; /* definition of datatype reedtree */ typedef struct REEDTree REEDTree; /* def...
C
/*switch .. case*/ #include<stdio.h> void main() { int n; printf("Choose: \n1.Unlimited Pack@Rs.22@1hr.\n2.20mb@Rs.10\n3.1GB@Rs.500\nSelect: "); scanf("%d",&n); switch(n) { case 1: printf("Your unlimited pack is activated!"); break; case 5: case 2: printf("Your ...
C
#define _GNU_SOURCE #include <sched.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> void setCpuAffinity(int cpu) { cpu_set_t mask; CPU_ZERO(&mask); CPU_SET(cpu, &mask); int rc = sched_setaffinity(0, sizeof(mask), &mask); if (rc == 0) { pri...
C
/*===================================================================================*/ /*************************************************************************************/ /** * @file 23_shell_progarm.c * @brief Exercise on execlp * @details A small shell program that has a command prompt “ashish> ” a...
C
#include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/wait.h> #include <unistd.h> #include <string.h> #include <stdlib.h> #include "header.h" #include <signal.h> /** * main - most AMAAAZINGGG simple SHELL, I call it SHELLY * @ac: argument counter. * @av: argument vector. * @env: environment...
C
/* Authors: Matt Rutherford, Megan Molumby, Abubakr Hassan Course: COP2220 Project #: 2 Title: Modularized Conversion Tool Due Date: 10/5/2014 Prompts user to input values for fahrenheit, feet, and pounds. Checks user input to make sure it is an integer and within a specified range and then displays the origin...
C
#include<stdio.h> int main() { int number; printf("enter the number"); scanf("%d",&number); if(number==0) { printf("armstrong number between two intrevels"); } else { printf("not print"); } }
C
/* * File: main.c * Author: Leonardo Adamoli * * Created on April 22, 2018, 4:06 PM */ #include <stdio.h> #include <stdlib.h> #include <locale.h> #include "PilhaCF.h" /* * */ int main(int argc, char** argv) { PilhaCF pilha1, pilha2, pilhaAux; int i, dado, resp; setlocale(LC_ALL, "port...
C
#include <stdio.h> #include <sqlite3.h> #include <string.h> #include <stdlib.h> #include "global.h" #include "sorting.h" char ex_value_sorting[6]; int strcmp_flag_sorting=0; int sorting_mode=0; char sorting_DESC[]=" ORDER BY price DESC;"; char sorting_ASC[]=" ORDER BY price ASC;"; char str_sorting[100]="SELECT * FROM ...
C
/* /cmds/player/emote.c * from the Nightmare IV LPC Library * for those times when you are feeling emotional * created by Descartes of Borg 950412 */ #include <lib.h> inherit LIB_DAEMON; mixed cmd(string args) { if( !creatorp(this_player()) && !avatarp(this_player()) ) { if( (int)this_player()->...
C
/* bbsclock.c */ #include <time.h> /* copy time into arg sting in form (HH:MM:SS xM) */ gettime(_ttime) char *_ttime; { long tloc ; char tchar ; int hour ; struct tm *localtime() , *tadr ; tloc = time((long *) 0) ; /* get time to tloc */ tadr = localtime (&tloc) ; tc...
C
/********************* ** Brian Palmer ** CS344 ** Project3 ** smallsh.c **********************/ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <fcntl.h> #include <signal.h> #include <unistd.h> #include <stdlib.h> /* Background Process Counter */ int pid_c = 0; /* Exit Status Var */ char exit_st...
C
#ifndef RANGE_H #define RANGE_H float scaleValue(float minIn,float maxIn, float minOut,float maxOut, float value) { float rangeIn = maxIn-minIn; float rangeOut = maxOut-minOut; return (rangeOut/rangeIn)*(value-minIn)+minOut; } float scaleJoystickValue(float minOut,float m...
C
#include <stdio.h> int main(void) { int num_one, num_two, den_one, den_two; printf("Enter two fractions separated by a plus sign: "); scanf("%d/%d+%d/%d", &num_one, &den_one, &num_two, &den_two); printf("The sum is %d/%d\n", num_one * den_two + num_two * den_one, den_one * den_two); return 0; }
C
/*************************************************************************** * Copyright (C) 2005 by Jon Barrett * * jbarrettcr@gmail.com * * * * This pr...
C
/* * Nazim BL * mikroC PRO for ARM */ //STM32f03 , Bluepill 72Mhz, external Quartz + PLLx9 unsigned int k=0,v1=0,v2=0,p1=0,p2=0; const unsigned int VMAX=315; unsigned int a=5,b=300,delta=1,diff=0; long idc=0,vdc=0; void setup(); void PWM_Setup(unsigned long fo); void setVref(unsigned int ...
C
#include <stdio.h> #include <string.h> #include <malloc.h> typedef int elemType; typedef struct b_node{ elemType data; struct b_node *lchild,*rchild; }b_node,*b_tree; //按数组顺序创建二叉树 void createTree(b_tree *T,elemType a[],int len,int index){ //修改一个指针 要用二级指针 if(index >= len) return; *T = (b_node *)...
C
#include<stdio.h> #include<errno.h> #include<fcntl.h> #include<stdlib.h> #include<unistd.h> #include<string.h> #include<sys/mman.h> /** * 存储映射I/O能将一个磁盘文件映射到内存空间的一个缓冲区上, * 当从缓冲区中读取数据时,就相当于读文件中的相应字节 * 将数据存入缓冲区中时,相应字节就自动写入文件 * * #include<sys/mman.h> * void *mmap(void *addr, size_t len, int prot, int flag, int fd, o...
C
#include <stdlib.h> #include <stdio.h> char *ft_itoa(int nbr) { char *string; int sign; int temp_nbr; int size; printf("\ntrying to convert %d\n", nbr); sign = (nbr < 0) ? -1 : 1; size = (sign < 0) ? 2 : 1; temp_nbr = nbr; while (temp_nbr /= 10) size++; if (!(string = (char*)malloc(sizeof(char)*(size + 1)...
C
#include "../utility.h" /** * 函数名:newdonroot * 功能描述:求出[a,b]区间内的非线性方程f(x)的一个实根 * 输入参数:x0(迭代初值以 * 返回值及迭代终值的初值指针) * f(非线性方程左端函数) * fd(非线性方程左端函数的导函数) * eps(精度要求),max(最大迭代次数) * 返回值:0(迭代失败)1(迭代成功) */ int newdonroot(double *x0,double(*f)(),double(*fd)(),double eps,int max) { double x,d...
C
// Metodo Selection Sort: // Este es un algoritmo que permite ordenar un array de manera especial. // Como toda estructura, tiene sus ventajas y desventajas, es un algoritmo que es facil de implementar, // no requiere memoria adicional y tiene un funcionamiento de intercambio constante, por otra parte // puede llegar ...
C
#include "tile.h" void initTile(Tile* t) { t->posX=0; t->posY=0; t->collision=0; } int getPosX(Tile t) { return t.posX; } int getPosY(Tile t) { return t.posY; } char getCollision(Tile t) { return t.collision; } void setPosX(Tile* t, int x) { t->posX=x; } void setPosY(Tile* t, int y) { ...
C
/**************************************************************************************** * File name: Table.h * Compiler Visual Studio 2019 * Author: Jonathan Slaunwhite , 040939090 * Course:CST 8152 Compilers, Lab Section:013 * Assignment 2 * Date: 2020-03-22 * Professor: Sv.Ranev * Purpose: This is t...
C
#include "msg.h" static int CHUNK_SIZE; static int mqid; static char dir_name[10]; void get_file_name(int chunk_id, char * buffer) { strcpy(buffer, dir_name); buffer += strlen(buffer); strcpy(buffer, "/chunk"); sprintf(buffer+6, "%d", chunk_id); buffer += strlen(buffer); strcpy(buffer, ".txt")...
C
#ifndef LINEARHASH_H_ #define LINEARHASH_H_ #define EMPTY -1 /* ִ */ #define DELETE -2 /* */ typedef enum { FALSE, TRUE } bool_t; typedef struct _linear_hash { int *hash; /* int ؽ̺ */ int size; /* hash table ũ */ } hash_t; bool_t createHash(hash_t *hsp, int size); /*...
C
/*12.Write C code to count and print all numbers from LOW to HIGH by steps of STEP. Test with LOW=0 and HIGH=100 and STEP=5.*/ #include <stdio.h> int main(){ int i; int low, high, step; printf("enter value of low and high "); scanf("%d%d", &low, &high); printf("enter the step"); scanf("%d", &step)...
C
#include "arr_util.h" #include <assert.h> void test_create(){ int size =sizeof(int); int length =10; ArrayUtil arr = create(size,length); assert(arr.length==length); assert(arr.typeSize==size); dispose(arr); }; void test_resize(){ int size =4; int length =10; int newlength =20; ArrayUtil arr = create(size,l...
C
#include <GL/glut.h> #include "game.h" #include "init.h" const int width = 800; const int height = 600; int mouse_x; int mouse_y; int getMouseX() { return mouse_x; } int getMouseY() { return mouse_y; } void loop() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); draw(); glutSwapB...
C
#include <math.h> #include <float.h> #include <stdio.h> #ifndef JSI_AMALGAMATION #include "jsiInt.h" #endif bool Jsi_NumberIsSubnormal(Jsi_Number a) { return fpclassify(a) == FP_SUBNORMAL; } bool Jsi_NumberIsNormal(Jsi_Number a) { return (fpclassify(a) == FP_ZERO || isnormal(a)); } bool Jsi_NumberIsNaN(Jsi_Number n)...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strsub.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> int angles[6]; void parser(char *line){ // Takes in a char*, converts char* to int, comma separated const char *delim = ","; char *p = strtok(line, delim); int counter = 0; while (p != NULL){ // convert *p to in...
C
/* GAudio 2.1.0.8, (C)2013 by Eric Du(E) This program is a part of the GAudio SDK. Use GAudio's echo effect */ #include <stdlib.h> #include <conio.h> #include <stdio.h> #include "gaudio.h" float circle = 0; const float radius = 5; void GAPIENTRY tellpos(gsource* source,int32_t position) { circle += 0.04f...
C
#include<stdio.h> // Type Casting void main() { float a,b; int c; printf("enter 2 numbers\n"); scanf("%f",&a); scanf("%f",&b); c=a+b; printf("the sum of the numbers is:%d\n",c); }
C
#include <stdio.h> #include <stdlib.h> #include "strutil.h" int main(void) { char *str = "Hello, WORLD!"; char *lower = strutil_lowercase(str); printf("Original: \"%s\"\n", str); printf("Lowercase: \"%s\"\n", lower); free(lower); return 0; }
C
#ifndef GARBAGECOLLECTOR_H_ # define GARBAGECOLLECTOR_H_ # include <pebble.h> # include "../Scopper/Scopper.h" /** * A container for given pointers to keep them for cleaning by the MemoryManager * @see alloc * @see custom_alloc * @see resource_handle */ typedef struct s_Resource { void *data; void (...
C
#include <stdio.h> #include "exchap9.h" void question92(){ /* Déclarations */ int A[100], B[50]; /* tableaux */ int N, M; /* dimensions des tableaux */ int I; /* indice courant */ /* Saisie des données */ printf("Dimension du tableau A (max.50) : "); scanf("%d", &N ); for (I=0; I<N; I++) { ...
C
#include "../usart/usart.h" #include <stdlib.h> #include <util/delay.h> #include <avr/io.h> #include<avr/pgmspace.h> #include<stdio.h> #define duzina_ime 7 #define pass 9 int8_t proveri(char str1[], char str2[], int8_t duz1, int8_t duz2) { if (duz1 != duz2) return 0; for(int i = 0; i < duz1; i++) { if (str1[i]...
C
#include <stdio.h> int main() { int i=0; for (printf("one\n");i < 3 && printf("");i++) { printf ("SUNNY\n"); } return 0; }
C
/* area.c. Program to compute area contributing to each Pixel in DEM for cell outflow based on angles. David G Tarboton Utah State University SINMAP package version 0.1 9/2/97 */ #include "lsm.h" void main(int argc,char **argv) { char pfile[MAXLN],afile[MAXLN], *ext; int err,row=0,co...