language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include "bib.h" int main() { setlocale(LC_ALL, "Portuguese"); int op; char nomeArquivo[256]; FILE *file; int N; dados_cov *D; indexacao *I; int achou; do{ op = menu(); switch (op){ case 1: //Ler Arquivo printf("Digite o nome do arquivo a ser lido:...
C
/*Създайте test1.txt файл в избрана от вас директория. Сложете някакви данни в него на латиница - име, поздрав, брой. Отворете за четене. Използвайте fgetc() , която взема само един char от файла. Направете while цикъл, за да изпишете всички символи, проверявайте за край на файл с EOF. Проверявайте дали файловият п...
C
#include<stdio.h> void DisplayRangeRev(int iStart,int iEnd) { int iCnt=0; for(iCnt=iEnd;iCnt>=iStart;iCnt--) { printf("%d\n",iCnt); } } int main(int argc,char * argv[]) { int iFirst=0,iLast=0,iRet; printf("Enter the first and last number->"); scanf("%d%d",&iFirst,&iLast); printf("reverse order between %d...
C
int main() { int n,count=0; scanf("%d",&n); char s[100]; scanf("%s",s); for(int i=0;i<n-1;i++) { if(s[i]==s[i+1]) { count++; } } printf("%d",count); return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "lists.h" List* List_Concatenate(List* firstList, List* secondList) { if(firstList->count == 0){ firstList->first = secondList->first; firstList->last = secondList->last; firstList->count = secondList->count; return...
C
/************************************************************************* > File Name: 2.75.c > Author: hcwang > Mail: shexing.w@gmail.com > Created Time: Thu 30 Apr 2015 10:21:55 PM CST ************************************************************************/ #include<stdio.h> unsigned unsigned_high_prod(unsi...
C
#include "assemble.h" #include "instr.h" #include "register.h" #include <string.h> #include <stdlib.h> // Three static char buffers to put the params in while assembling static char param1[MAX_PARAM_LENGTH + 1] = { [MAX_PARAM_LENGTH] = '\0' }; static char param2[MAX_PARAM_LENGTH + 1] = { [MAX_PARAM_LENGTH] = '\0' }; s...
C
#include <stdio.h> #define SQR_SIZE 5 #define AUG_SQR_SIZE (SQR_SIZE + 4) int main() { int magicSqr[SQR_SIZE][SQR_SIZE] = {0}; int augSqr[AUG_SQR_SIZE][AUG_SQR_SIZE] = {0}; int currNum = 1; int iM, jM; for (int n = 0; n < SQR_SIZE; n++) { for (int i = 0; i < SQR_SIZE; i++) { augSqr[SQR_S...
C
#include <stdio.h> #include <malloc.h> typedef int QElemType; typedef struct QNode{ QElemType data; struct QNode *next; }QNode,*QueuePtr; typedef struct{ QueuePtr front,rear;/*头、尾两个指针*/ }LinkQueue; /*********************************** *入队列 *入口参数:队列链表指针,入队列元素 ***********************************/ int EnQueue...
C
/** * \addtogroup USARTInterface.c * @{ * * @file USARTInterface.c * @author p344575 * @brief USART interface for using TI USART spi driver * @copyright &copy; 2016 Porsche Engineering Services GmbH * * @internal * $LastChangedDate: 2017-11-14 12:44:56 +0100 (Di, 14 Nov 2017) $ * $LastChangedBy: ksteingas...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/ipc.h> #include <sys/shm.h> #include <sys/sem.h> #include <sys/wait.h> #include <sys/types.h> #include <time.h> #include "golibroda.h" int semid, waiting; void get_time() { struct timespec tp; if(clock_gettime(CLOCK_MONOTONIC, &tp)==-1) ...
C
#include<stdio.h> int main() { float p, l; printf("Masukkan panjang persegi (m) = "); scanf("%f", &p); printf("Masukkan lebar persegi (m) = "); scanf("%f", &l); printf("Luas persegi adalah (m2) = %.2f \n", p * l); return 0; }
C
#include <stdlib.h> #include <signal.h> #include <stdio.h> #include <string.h> #include <stdbool.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> //variable for the maximum number of processes that can be run by program #define maxProcesses 5 //global variable ...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> /* * STRUCTURE D'UNE NODE * La node contient un symbole (char) et une fréquence d'apparition dans le code */ typedef struct node_s{ char symbol; int freq; struct node_s* fg; struct node_s* fd; }node; /* * ...
C
#include <stdio.h> //printf(). scanf(), fopen(), fscanf(), fprintf() 등 실행에 주가 되는 함수를 위함 #include <string.h> //체스판과 데이터를 저장하고 변경하는 과정에 있어서 필요한 strcpy(), strcat(), strcmp(), strlen()를 위함 #include <stdlib.h> //system("clear")를 위함 #include <termio.h> // getch() 함수를 정의하기 위해 필요한 tcgetattr(), ICANON, ECHO, VMIN, VTIME, tcs...
C
#include <stdio.h> #include <stdlib.h> #include "uthash.h" typedef struct { int key; int data; UT_hash_handle hh; } item; int main() { item *i, *j, *items=NULL; int k; /* first item */ k = 12345; i = (item*)malloc(sizeof(item)); if (i == NULL) { exit(-1); } i->key ...
C
#include <stdio.h> int main(void){ int N,D,K; scanf("%d%d%d",&N,&D,&K); int L[D],R[D]; for(int i = 0;i < D;i++) scanf("%d%d",&L[i],&R[i]); int S,T; for(int i = 0;i < K;i++){ scanf("%d%d",&S,&T); for(int j = 0;;j++){ if(S < T){ if(L[j] <= S && S < R[j]){ if(L...
C
#include <stdio.h> #include <stdlib.h> #include "../fila/Fila_interface.h" #include "../pilha/Pilha_interface.h" #include "Fila_pilha_interface.h" #include "Fila_pilha_privado.h" #define TRUE 1 #define FALSE 0 p_fila_pilha criar(int quantidade_dado_pilha, int tamanho_dado_pilha) { p_fila_pilha pfp = malloc(sizeof(...
C
#include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/fs.h> #include <linux/miscdevice.h> #include <asm/uaccess.h> // 定义设备文件名 #define DEVICE_NAME "wordcount" static unsigned char mem[10000]; // 保存向设备文件写入的数据 static char read_flag = 'y'; //y:設備已讀取 n:設備未讀取 static int written_count =...
C
/* handling keyboard interrupt * get the correct character from corresponding scan value */ //#define ASM 1 #include "keyScan2ascii.h" #include "lib.h" #define ARRAY_LEN 256 #define NULL 0 #define CAPS_LOCK 0x3A /* constants for keyboard ascii*/ #define ESC 27 #define BACKSPACE 8 #define TAB 9 #define NEWLINE 10 #de...
C
//This file contains functions pertaining to getting and implementing action by user #include <stdio.h> #include <stdlib.h> #include "struct_def.h" #include "input.h" #include "move.h" //recursive function to reveal all appropriate tiles void RevealTiles(Board* board, int row, int col) { int i, j; if (ro...
C
#include "cc.h" int pos = 0; int code_pos = 0; Token tokens[100]; void tokenize(char *p) { int i = 0; while(*p){ if (isspace(*p)){ p++; continue; } if(*p == '+' || *p == '-' || *p == '*' || *p == '/' || *p == '(' || *p == ')' || *p == '=' || *p == ';' ){ tokens[i].ty = *p; tok...
C
#include<stdio.h> #include<stdlib.h> void change_ptr(int * const ); int main(void) { int var1 = 0, var2 = 0; /* the ptr is const, not the data */ int * const ptr = &var1; /* ptr = &var2; */ change_ptr(&var1); printf("%d\n", *ptr); return EXIT_SUCCESS; } void change_ptr(int * const ptr) {...
C
/* ============================================================================ Name : PrefixSums.c //SERIAL Author : David Katz ============================================================================ */ #include <stdio.h> #include <stdlib.h> /*--------------------------------------------------...
C
#pragma once #include "gc.h" #include "header.h" /// This header: /// struct Map; /// Map*map_insert(Map*,SinObj*,SinObj*); /// SinObj*map_keys(Map*); /// SinObj*map_get(Map*,SinObj*); extern "C" { /// Map is defined as a linked list of keys and values. /// Not hashed at all, thats too hard... Oh well. typedef struct...
C
#include <stdio.h> #include <string.h> #include <uloop.h> void f1_cb(struct uloop_timeout *t) { int msec = 1000; printf("%s: %d\n", __func__, msec); uloop_timeout_cancel(t); } void f2_cb(struct uloop_timeout *t) { int msec = 2000; printf("%s: %d\n", __func__, msec); uloop_timeout_set(t, msec); } void f3_cb(str...
C
#include<stdio.h> #include<conio.h> struct node { int info; struct node *next; }*start; void main(){ int ch; clrscr(); printf("A Program By CHANPREET SINGH"); printf("\n\t\t\tMAIN MENU"); printf("\n\t\t\t1 Create a linked list"); printf("\n\t\t\t2 Insert into linked list"); printf("\n\t\t\tDelete from linked list");...
C
#include<stdio.h> void towers(int n, char a, char b, char c) { if (n == 1) { printf("\Muta discul 1 de pe tija %c pe tija %c", a, b); return; } towers(n - 1, a, c, b); printf("\nMuta discul %d de pe tija %c pe tija %c", n, a, b); towers(n - 1, c, b, a); } int main() { int nr; printf("nr:"); ...
C
#include "Scheduler.h" Semaphore *s_hello; int main() { scheduler = new RoundRobinScheduler(); s_hello = new Semaphore(0); scheduler->start(new Thread(hello, NULL)); scheduler->start(new Thread(world, NULL)); // three threads are active now! scheduler->running->wait_all(); delete scheduler; // opt...
C
/* Copyright (C) 2016 Evan Christensen | | 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 Software without restriction, including without limitation the | rights to use, copy, modify, merge, publish, d...
C
#include<stdio.h> int main() { int x=0; int y=0; printf("enter the x"); scanf("%d\n",&x); printf("enter the y"); scanf("%d\n",&y) ; return 0; }
C
#include "fitz-internal.h" #define MAX4(a,b,c,d) fz_max(fz_max(a,b), fz_max(c,d)) #define MIN4(a,b,c,d) fz_min(fz_min(a,b), fz_min(c,d)) /* Matrices, points and affine transformations */ const fz_matrix fz_identity = { 1, 0, 0, 1, 0, 0 }; fz_matrix fz_concat(fz_matrix one, fz_matrix two) { fz_matrix dst; dst.a = ...
C
int test(int a, int b) { int x = 1 / a; int i, j; for (i = 0; i < b; i++) { j = j + x; } return j; }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* redirections_2.c :+: :+: :+: ...
C
/*********************************************************************** / / SUBTRACT MASS FROM STAR AFTER FEEDBACK / / written by: Ji-hoon Kim / date: January, 2010 / modified1: / / PURPOSE: Currently this file is not being used; now the functionality / of this file has moved to / / M...
C
#include <stdio.h> #include <stdlib.h> #define ERROR -1 #define TRUE 1 #define FALSE 0 #define Maxsize 20 typedef int ElemType; typedef struct { ElemType Data[Maxsize]; ElemType length; } SqList; typedef int Status; Status GetElem(SqList L, int i, ElemType *e){ if(L.length < i || L.length == 0 || i < 1) ...
C
#include <stdlib.h> #include <stdio.h> #include "main.h" typedef unsigned char byte; typedef int error_code; #define ERROR (-1) #define HAS_ERROR(code) ((code) < 0) #define HAS_NO_ERROR(code) ((code) >= 0) /** * Cette fonction compare deux chaînes de caractères. * @param p1 la première chaîne * @param p2 ...
C
// Implements a dictionary's functionality #include <stdbool.h> #include <stdio.h> #include <string.h> #include <strings.h> #include <ctype.h> #include <stdlib.h> #include "dictionary.h" // Represents a node in a hash table typedef struct node { char word[LENGTH + 1]; struct node *next; } node; // Number of...
C
#include "bsp_adc.h" __IO uint16_t ADC_ConvertedValue[5]={0,0,0,0,0}; float ADC_Value[5]; /** * @brief ADC GPIO ʼ * @param * @retval */ static void ADCx_GPIO_Config(void) { GPIO_InitTypeDef GPIO_InitStructure; // ADC IO˿ʱ ADC_GPIO_APBxClock_FUN ( ADC_GPIO_CLK, ENABLE ); ...
C
#ifndef LCD_H_ #define LCD_H_ #define DL_4 0 #define DL_8 1 #define ONE_LINE 0 #define TWO_LINE 1 #define FONT_SMALL 0 #define FONT_BIG 1 //LCD_voidInit //Initiate LCD as per configuration in lcd_config.h //return: void LCD_voidInit(); //LCD_voidClrDisp //Clear LCD display //return: void LCD_voi...
C
#include <stdio.h> /*** 1. Sum of all numbers less than or equal to n and also co-prime to n = (phi(n) * n) / 2 2. Lagrange's Polnomial: A polynomial of degree n can be uniquely represented and evaluated from it's value in n + 1 distinct points (x_i, y_i) For the function f(x) = x ^2, given three points ...
C
// // main.c // Labs // // Created by Warren Seto on 1/23/17. // Copyright © 2017 Warren Seto. All rights reserved. // #include "types.h" #include "stat.h" #include "user.h" void outputPrimeFactor(int* input); int pid; int main(int argc, const char * argv[]) { // Declare an integer to find its prime factors ...
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
/* * Autor: Cristobal Liendo I. * Fecha: 09/10/17 * Descripcion: Parametros de funciones */ #include <stdio.h> int cuadrado(int); int main() { int numero, resultado; numero = 5; resultado = cuadrado(numero); printf("El cuadrado del numero es %d", resultado); printf(" y el de 3 es %d\n", cuadr...
C
//Realizar programa para controlar varias bibliotecas usando estructuras dentro de estructuras #include<stdio.h> #include<string.h> #define N 50 typedef struct{ char nombre[N]; char autor[N]; int lleno; }libro; typedef struct{ libro lib[10]; char nombre[N]; int lleno; }biblioteca; biblioteca bi[3]; void anad...
C
#include<stdio.h> #include<stdlib.h> #include<pthread.h> #include<time.h> int thread_num; long long int number_of_tosses,batch; long long int number_in_circle[5]; void* toss(void * bank) { long mybank=(long)bank; long long int sample_num=0; long long int i=0; srand(time(NULL)); unsigned seed=rand(); long ...
C
#ifndef _SYS_FUTEX_H #define _SYS_FUTEX_H #include <sys/types.h> typedef struct { /* futex ID */ long id; /* * val==0 - futex free * val==1 - futex locked, but noone is waiting * val==2 - futex locked, someone is waiting */ short val; } futex_t; /* Futex initialize and destroy fu...
C
#include <stdio.h> int main() { int dividers[] = {3, 5, 7, 13}; char messages[4][10] = {"Fizz", "Buzz", "Tapioca", "Kefir"}; for (int i = 1; i <= 100; i++) { int dividerExist = 0; for (int j = 0; j < 4; j++) { if (i % dividers[j] == 0) { printf("%s", messages[j]...
C
#include "Handlers.h" #include "estructuras.h" #include "globales.h" extern cpSpace * modChipmunk_cpEspacio; extern int modChipmunk_Crear; extern modChipmunkStruct_nodo * modChipmunk_ListaHandlers; typedef struct {int a,b;} modChipmunkStruct_param2d; modChipmunkStruct_param2d modChipmunkParam(int a,int b){ modChi...
C
/* * Queue.h * * Created on: Apr 9, 2019 * Author: WINNGUYEN */ #ifndef QUEUE_H_ #define QUEUE_H_ #include <msp430.h> #include <stdint.h> #include <stdlib.h> #define MAX_QUEUE_SIZE 16 typedef int bool; #define true 1 #define false 0 #define FULL_KEY 2 #d...
C
/* * TWI_Funcoes.c * * Created: 17/01/2018 14:35:23 * Author: Henrique */ #include "TWI_Header.h" int nCounter = 0; // funo para iniciar o SCL ou o clock de oscilao void initTWI(void) { // para calcular o Two Wire Bit Rate, usar a seguinte formula: // SCL frequency = CPU Clock frequency / 16 ...
C
/* author: Joselito_Junior date: 14/10/2017 version: 1.0 Descrição: Essa uma implementação simples de uma fila sequencial circular */ #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 5 // Tipo base dos elementos da lista typedef struct elementos{ char nome[50]; }t_elemento; typedef struc...
C
#include <stdio.h> int main() { float sal,pres,cond; printf("Digite o valor do salario:"); fflush(stdout); scanf("%f", &sal); printf("Digite o valor da prestacao do emprestimo: "); fflush(stdout); scanf("%f", &pres); cond = sal * 0.2; if (cond > pres) { printf("Emprestimo concedido!"); ...
C
#include <stdio.h> int res(int n,int m){ int a=0; for(int i=2;i<=n;i++){ a=(a+m)%i; } a = a + 1; return a; } int main(){ int m,n; while(scanf("%d %d",&n,&m)==2){ if (m == 0 && n == 0) { break; } printf("%d\n",res(n,m)); } return 0...
C
/* Filename: ubertooth-rssi.c * Version: 2 * Date: Jan 2015 * Authors: Daniel Holmes & Dylan Jaconbsen (mostly borrowed and edited code from existing ubertooth functions) * Description: Code that gets the RSSI data with an associated complete local name and outputs to the terminal * Notes: This code can be run fro...
C
#include <stdlib.h> /** * _calloc - allocates an array to memory, with each value zero'ed out * @nmemb: elements to allocate * @size: size of each element * Return: pointer to array of allocated memory */ void *_calloc(unsigned int nmemb, unsigned int size) { char *array; unsigned int count; void *ptr; count = 0; i...
C
/** * @file lv_qrcode * */ #ifndef LV_QRCODE_H #define LV_QRCODE_H #ifdef __cplusplus extern "C" { #endif /********************* * INCLUDES *********************/ #include "../../../lvgl.h" #if LV_USE_QRCODE /********************* * DEFINES *********************/ /********************** * TY...
C
#include <stdio.h> int main() { int a, b, c1 = 0, c2 = 0, c3 = 0, c4 = 0; for (a = 0; a < 5; a++) { scanf("%d", &b); if (b % 2 == 0) c1++; if (b % 2 == 1 || b % 2 == -1) c2++; if (b > 0) c3++; if (b < 0) c4++; } printf("%d valor(es) par(es)\n", c1); printf("%...
C
#include<stdio.h> int main() { int a,i; scanf("%d",&a); printf("INPUT \n %d \n",a); printf("Output \n"); for(i=0;i<a;i++) { printf("HELLO\n"); } return 0; }
C
/* # Name: Irvin Samuel # Date: Tuesday, 26 Jan 2021 # Title: Lab4 Part 3 (TCP/IP Socket programming) # Description: This program implements socket programming and simulates a multi-thread client */ #include <pthread.h> #include <stdlib.h> #include <stdio.h> /* printf, stderr */ #include <sys/socket.h> #include <...
C
#include <stdio.h> #include <sys/stat.h> #include <sys/types.h> #include "common.h" int open_next_file(struct picam_ctx *ctx, char *last_fname, int len) { char dir[1024]; struct tm now, *pnow; time_t tm_now; /* create directory based on todays date */ tm_now = time(NULL); pnow = localtime_r(&tm_now, &now); s...
C
/* ** EPITECH PROJECT, 2021 ** minishell ** File description: ** functions for the exit command */ #include "minishell.h" int get_exit_status(param_t *params) { int status = 0; int tmp = 0; int i = 0; if (is_int(params->input[1]) != 1) { my_putstr("Invalid Syntax\n"); return (256); ...
C
#include "common.h" int main() { //declare the vars qlist *front = NULL; data_t data, n_data, g_data; int opt, status, num; //run an infinite while loop while(1) { //print the user options printf("\n1.ENQ\n2.DEQ\n3.print\n4.EXIT\n"); scanf("%d", &opt); printf("\n"); switch(opt) { //enqueue cas...
C
#include "turtle.h" #include "tensor3D.h" /* Note that depth is the first indices and that the indices were pernutated with respect to NR */ /*-----------------------------------------------------------------------*/ double ***d3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh) /* allocate a doubl...
C
#include <stdio.h> int taille (int nb) { int i; int tab[100]; for(i=0;tab[i]!='\0';i++) { if (nb>=0 && nb<=9) { tab[i]=nb; } } return i; } int main () { int nb; scanf("%d",&nb); printf("%d\n",taille(nb)); }
C
#include<stdio.h> #include<stdlib.h> #include<pthread.h> const int MAX = 100; int arr[100]; int found = 0; int t; int n; void *search_l(void *arg){ int *s = (int *)arg; int key = *s; for(int i = 0; i < n;i++){ if(found == 0 && arr[i] == key){ t = 1; found = 1; break; } else if(foun...
C
#ifndef __SE_BEENAKKER_DECOMP #define __SE_BEENAKKER_DECOMP #include <math.h> double self_coeff(double xi) { return -8*xi/sqrt(PI); } double C1(double r) { double r2 = r*r; return erfc(r) + 2*(2*r2 - 3)*r*exp(-r2)/sqrt(PI); } double C2(double r) { double r2 = r*r; return erfc(r) + 2*(1 - 2*r2)*...
C
#include <stdio.h> #include <stdlib.h> long long int cycle_length(long long int); int main() { long long int i, j, cycle, iter, result, firsttime = 1; while(scanf("%lld %lld", &i, &j) != EOF){ if(firsttime != 1) printf("\n"); else firsttime = 0; ...
C
#include <stdio.h> #include <stdlib.h> int main() { int n;do{printf("n(odd number)-> ");scanf("%d",&n);}while(n%2==0); for(int i=0;i<(n/2+1);i++) { printf("*"); for (int j=0;j<=(i-2);j++) { printf(" "); } if(i-1>=0){printf("*");} for (int j=0;j<(...
C
/* Row = 4 Column = 4 # # # # # * * # # * * # # # # # 1,1 1,2 1,3 1,4 2,1 2,2 2,3 2,4 ...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<ctype.h> #define N 100 int TOP = -1; char S[N]; void PUSH(char ITEM) { if(TOP >= N-1) { printf("\nStack Overflow."); } else { TOP = TOP+1; S[TOP] = ITEM; } } char POP() { char ITEM ; if(TOP <0) { printf("\nStack Underflow!"); exit(...
C
#include <stdio.h> #include <stdlib.h> #define N 8 /* preenche o tabuleiro com peças e printa */ void printMatriz(char **M){ int i,j; printf(" 0 1 2 3 4 5 6 7\n"); for(i=0;i<N;i++){ printf("%d",i); for(j=0;j<N;j++){ printf("[%c]",M[i][j]); } printf("\n"); ...
C
#ifndef __UTILITIES_H #define __UTILITIES_H //macros #define BIT(n) (0x01<<(n)) //generic functions /** * @brief returns the absolute value of a number * * * @param n number whose absolute value we want to know * * @return Absolute value of n */ int abs(int n); /** * @brief returns sign of a number ...
C
/* // file: /std/player/history.c // author: Portals (wayfarer and huthar) // last modified: 1992/03/08 - Truilkan@TMI */ #include <security.h> private nosave string *history_queue; private nosave int cmd_num, ptr; private nosave int max; int query_cmd_num() { return cmd_num ? cmd_num : 1; } int query_ptr() { return...
C
/************************************************************************* > File Name: server.c > Author: > Mail: > Created Time: Sat 29 Apr 2017 10:47:45 AM CST ************************************************************************/ #include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <sys/epo...
C
#include<stdio.h> #include<string.h> typedef struct list{ int nu; double a,b,c,d,ave; }lis; int main() { lis a[3]; int i; for(i=0;i<3;i++){ scanf("%d%lf%lf%lf%lf",&a[i].nu,&a[i].a,&a[i].b,&a[i].c,&a[i].d); a[i].ave=(a[i].a+a[i].b+a[i].c+a[i].d)/4.0;} for(i=0;i<3;i++) prin...
C
#include <stdio.h> int kadane(int a[],int n){ int i,max_so_far = 0,max_end_here=0; for (i=0;i<n;i++){ max_end_here=max_end_here + a[i]; if (max_end_here <0) max_end_here = 0; if (max_end_here > max_so_far) max_so_far = max_end_here; } return max_so_far; } ...
C
/** * $Id: lcd.c 672 2013-04-12 10:30:44Z klugeflo $ */ /****************************************************************************** File: lcd.c Project: Roomba Embedded Systems Training Description: LCD text output Author: Florian Kluge <kluge@informatik.uni-augsburg.de> Universität Augsburg Created...
C
#include <stdio.h> #include <cs50.h> typedef struct node { int n; struct node* next; } node; bool insert_node (int value, node* list) { // create a new node node* new_node = malloc(sizeof(node)); if (new_node == NULL) { return false; } new_node->n = value; // create...
C
/* * Copyright (c) 2002, Intel Corporation. All rights reserved. * This file is licensed under the GPL license. For the full content * of this license, see the COPYING file at the top level of this * source tree. * Test that pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock) * * Under no circumstances sh...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> struct tableau { int taille; int T[1500]; }; typedef struct tableau tableau; int comp_selection; int comp_insertion; int comp_bulle; int alea(int n) { return rand()%n; } void ini_struct_tab(tableau *a,int tail) { int i; (*a).taille=tail; for(i=0;i<(...
C
#include <stdio.h> #include <stdlib.h> struct fib_test{ int id; void *point; // char point[0]; }; int main() { struct fib_test *ft; ft=malloc(sizeof(struct fib_test)+10); printf("sizeof(struct fib_test)=%d\n",sizeof(struct fib_test)); memset(ft->point,0,10); printf("memset\n"); sprint...
C
#include <stdio.h> #include <stdlib.h> void buildMAX(int arr[],int n); void heapify(int arr[],int n, int i); void Swap(int arr[],int a,int b); int main() { int arr[]={4,10,3,5,1}; buildMAX(arr,5); for(int i=4;i>0;--i){ Swap(arr,i,0); buildMAX(arr,i);} } void buildMAX(int a...
C
#include<stdio.h> main() { int n1=5,n2=10; n1=n1^n2; n2=n1^n2; n1=n1^n2; printf("%d %d",n1,n2); }
C
#include <stdlib.h> #include <sys/types.h> #include <sys/shm.h> #include <sys/stat.h> #include <string.h> #include "clients.h" union semun { /* Used in calls to semctl() */ int val; struct semid_ds * buf; unsigned short * array; #if defined(__linux__) struct semin...
C
#include <stdlib.h> int main(){ int* p = malloc(50); free(p); // 'til here, everything fine int y = 5; int* x = realloc(&y, 50); // trying to realloc non existing pointer return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <time.h> #include <sys/stat.h> #include <string.h> #include <fcntl.h> enum position{START_ROOM, MID_ROOM, END_ROOM}; struct Room { int id; char* name; int numOutboundConnections; enum position roomLocation; struct Room *outboundConnection...
C
#include <stdio.h> void arrays_are_pointers(){ printf("\nArray names are pointers\n\n"); char arr[3] = { 'A','B','C'}; printf("%p %c", &arr, *arr); printf("Address of arr[0]: \n&arr[0] %p \n\n",&arr[0]); printf("Value of arr[0]:\n *(&arr[0]) %c or arr[0] %c \n", *(&arr[0]), arr[0]); } int m...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <arpa/inet.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <netinet/in.h> #include <unistd.h> #include <fcntl.h> char ANSWER_OK[] = "HTTP/1.1 200\n"; char ANSWER_WRONG[] = "HTTP/1.1 404\n"; char CONTENT_IMG[] = "content-...
C
#include <stdlib.h> typedef struct { int userData1; int userData2; } Object; typedef struct { Object o; int privateData; } ObjectWrapper; void * cache; Object* allocate(int u1, int u2) { ObjectWrapper *ret = malloc(sizeof(ObjectWrapper)); ret->privateData = 0; ret->o.userData1 = u1; ret->o.userData2...
C
#include <stdlib.h> #include <stdio.h> struct empleado{ char nombre[20]; float salario; }emple[100],*pemple=emple; void ingresar_empleados(); void imprimir(); float mayor=0; float menor=999999; int posmayor,posmenor; int empleadon; int main(){ ingresar_empleados(emple); imprimir(emple); ...
C
#include<stdio.h> int nhap() { int n; do{ printf("nhap so phan tu mang: "); scanf("%d",&n); } while(n<=0||n>30); return n; } void NhapMang(int a[], int n) { int i; for(i=0;i<n;i++) { printf("a[%d]= ",i); scanf("%d", &a[i]); } } void XuatMang(int a[], int n) { int i; printf("\nMang: "); for(i=0;i<n;i...
C
/* * heap.h * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be usefu...
C
/* * filetable.c * Author: Gregory Venezia * Date: 4/27/2015 * Course: CSC3320 * Description: This file provides a file table data structure. */ #include "filetable.h" /* Creates the table Pre: None Post: Adds a table to the volume with a reference in memory. */ table_t * filetable_create() { table_t * ta...
C
#include <stdio.h> int main(int argc, char *argv[]) { if(argc >= 3){ FILE* a; FILE* b; int i=0; int n; int sum=0; a = fopen(argv[1], "r"); b = fopen(argv[2], "w"); while(fscanf(a, "%d", &n) != EOF) sum += n; fprintf(b, "%d", sum); fclose(a); fclose(b); } else return 0; }
C
#include <stdio.h> #include <math.h> #include<stdint.h> #include<stdlib.h> #define WID 1920 #define HEI 1080 #pragma pack(push,1) typedef struct tagBITMAPFILEHEADER { unsigned short bfType; uint32_t bfSize; unsigned short bfReserved1; unsigned short bfReserved2; uint32_t bf0ffBits; }BITMAPFILEHEADER; #pragma ...
C
/////////////////////////////////////////////////////////////////////// //Problem Statment: Write a program which accept file name from user and read whole file. //Developed By : Ashwini Sharad Palve //Input : File name //Output : All file containts //Date : 10-09-2020 /////////////////...
C
#include "lib_rcc.h" /** * @brief Enable MCO (Microcontroller Clock Output). * @param mco_config: CFGR register MCO configuration 3 bits. * @retval None */ void RCC_MCOEnable(uint8_t mco_config) { /* Set 24-26 bits in CFGR regestry */ uint32_t mask = ~(((0x01U << 3) - 0x01U) << 24); RCC->CFGR = (RCC->...
C
#include "sorts.h" #include <stdlib.h> /*< malloc >*/ #include <stdint.h> /*< uint8_t >*/ #include <string.h> /*< memscpy >*/ static int _CheckSortInputParameters( void* _arrayOfDataToSort, size_t _dataSizeInByte, size_t _arrayDataToSortInByte, CompareFunc _compareOperation, Swa...
C
#include<STC15.h> //״̬ typedef unsigned char uchar; typedef unsigned int uint; typedef enum Key1_State{Init1_State,Affirm1_State,Single1_State,Repeat1_State}; sbit KEY1 = P3^3; sbit KEY2 = P3^2; sbit KEY3 = P3^1; sbit Led1 = P3^5; // //#define key Key1 void KEY_Init(uchar k) { static uchar Key1_StateValue = 0; /...