language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
/***************************************************** * Command-line Calculator * * Author: Aleksandar Stankovic * * Date: 05.11.2021 * * Usage: calc.exe OPERAND_1 OPERATOR OPERAND_2 * ********************************************...
C
#include <stdio.h> // Function to find and print pair int solve(int A[], int size, int x) { for (int i = 0; i < (size - 1); i++) { for (int j = (i + 1); j < size; j++) { if (A[i] + A[j] == x) { printf("Pair with a given sum %d is (%d, %d)\n", x, A[i], A[j]); r...
C
/* ######################################################## ### @Copyright Moreno Vera, Felipe Adrian ### ### Pila == Stack y demas traducciones ### ######################################################## */ #include <stdio.h> #include <string.h> #include<stdlib.h> //http://kinglike...
C
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include "ThreadRoutines.h" // Default Thread priority is 1 static int turn = 1; pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t condition1 = PTHREAD_COND_INITIALIZER; pthread_cond_t condition2 = PTHREAD_COND_INITIALIZER; void *ThreadRouti...
C
/* * 如何判定数组是否存在重复元素 */ #include<stdio.h> int isArrayRepeat(int *a, int n){ int i=0; int j=-1; for(i=0; i<n; i++){ j=a[i]; if(i==j) continue; if(a[i]==a[j]) return 1; a[i]=a[j]; a[j]=j; } return 0; } int main(){ int result = -1; int a[10]={10,9,5,4,7,6,1,3,2,9}; result=isArrayRepeat(a,10); i...
C
#include "MyUNP.h" /** * 从指定文件描述符中读取一行数据,若没有遇到换行符则该函数会自动 * 对最后一个字符进行填充'\n'。不过这个函数执行效率非常低 */ ssize_t readline1(int fd, void* buf, size_t maxlen) { ssize_t nread, n; char c, * ptr; ptr = buf; /* i从1计数是为了预留一个字符以在buf不能容纳的时候 在最后面放置一个'\n' */ for (n = 1; n < maxlen; ++n) { again: if ((nread = read(fd, &c, 1)) ...
C
#ifndef ADDERS_H_ #define ADDERS_H_ #pragma once #include "logic_gates.h" #include "miscellaneous.h" struct half_adder { struct xor_gate_two_in xor_0; struct and_gate_two_in and_0; }; void half_adder_initialize(struct half_adder* adder, pin_in_t a, pin_in_t b) { adder->xor_0.a = a; adder->xor_0.b = ...
C
#include <stdlib.h> #include <stdio.h> struct Pila{ int dato; struct Pila *siguiente; }; struct Pila *agregar (int n, struct Pila *tope){ if(tope==NULL){ struct Pila*tmp = malloc (sizeof(struct Pila)); tmp ->dato = n; tmp ->siguiente = NULL; } } int main(){ struct Pila *p1; p1=agregar(10,p1); return...
C
#include <stdio.h> #include <stdlib.h> #include <signal.h> #include <string.h> #include <unistd.h> #include <time.h> #include <errno.h> #define BUFFER_SIZE 80 #define NUM_OF_CMDS 4 // Declare built-in command functions void cd(char* args[]); void help(char* args[]); void exit_shell(); void guessing_game(); // Global...
C
#include "fs.h" #include "disk.h" #include "data_structures.h" #include "cache.h" #include <assert.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <errno.h> #include <unistd.h> #define FS_MAGIC 0xf0f03410 // Returns the number of dedicated inode blocks given the disk si...
C
/* * WaitGpio.c * * Created on: Jan 3, 2017 * Author: hico */ #include "stdio.h" #include "errno.h" #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <string.h> #include <sys/ioctl.h> #include "WaitGpio.h" int ReadGpio(const char* a_Filename,char a_ResetValue) ...
C
/* ** EPITECH PROJECT, 2018 ** Zappy - Server ** File description: ** Join a team */ #include "server.h" /** *@brief place a player with an egg * *@param server [in] the server *@param client [out] the client *@param egg [in] the egg *@return false in case of an error */ static bool egg_hatching(server_t *server, cli...
C
#include "lists.h" /** * add_nodeint - add new node at the beggining *@head: head of linked list *@n: integer to be part new node * * Return: addres of new element */ listint_t *add_nodeint(listint_t **head, const int n) { listint_t *new; new = malloc(sizeof(listint_t)); if (new == NULL) return (NULL); (...
C
/*=========================================================================== B <- IPBHT(r,A,i,k) Integral polynomial binary homothetic transformation. Inputs r : A BETA-digit. r >= 0. A : an element of Z[x_1,...,x_r]. i : 1 <= i <= r. k : a BETA-digit. Outputs B : an element of Z[x_1,...,x_r]. ...
C
/* 本次作业由本人独立实现完成,如有抄袭行为,愿承担由此带来的一切不良后果 */ #include<stdio.h> #include<string.h> int main() { int n, i, j; char telbook[50][10], namebook[50][10], temp[20]; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%s", &temp); strncpy(namebook[i], temp + 0, 10); scanf("%s", &temp); strncpy(telbook[i], temp + 0, 10)...
C
#include <wasm.h> #include <assert.h> #include <stdint.h> #include <stdio.h> #include <string.h> int main(int argc, char const *argv[]) { uint8_t input[] = {0x00, 0x01, 0x01, 0x02, 0x03}; wasm_parser_t *parser = &(wasm_parser_t){input, sizeof input}; { wasm_limit_t result; size_t end = 0; wasm_par...
C
/*I'd suggest people also take a look at the (beta) pthreads library that somebody wrote on top of clone() (the announcement is probably still in comp.os.linux.announce if you have a reasonable news spool). That is probably actually useful, unlike my minimal example. Linus ----*/ #include <signal.h> #include <st...
C
#include "thread_pool.h" Client* pHead = NULL; Client* pEnd = NULL; int client_num = 0; int client_user_connect = 0; int client_user_analyse = 0; int client_pre_connect = 0; int client_pre_analyse = 0; int client_set = 0; int match_end_str(char* str1,int len1,char* str2,int len2) { int i = 0; if(len1 < len2) ...
C
#include<stdio.h> #include<unistd.h> void main(){ int len, i, apipe[2]; char buf[BUFSIZ]; if(pipe(apipe) == -1){ perror("could not make pipe"); exit(1); } printf("got pipe, fd: %d, %d\n", apipe[0], apipe[1]); while(fgets(buf, BUFSIZ, stdin)){ len = strlen(buf); if...
C
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> typedef struct { char name[11]; char ID[11]; int score1[3]; int score2[3]; int score3[3]; }studentinfo, *studentptr; int main() { int i, average, s1, s2, s3; studentinfo list[6] = { '\0', 0 }; print...
C
/** * Author: Ahmed Alaa * main.c */ #define F_CPU 16000000UL #include "tm4c123gh6pm/stdtypes.h" #include "tm4c123gh6pm/gpio_reg.h" #include "tm4c123gh6pm/gpio.h" #include "tm4c123gh6pm/util.h" int main(void) { /* Setup Configurations */ GPIO_SetPinDirection(PORTF, PF4, INPUT); // Switch 1: Pin 4 on Port ...
C
#include <stdio.h> #include <math.h> int main(void) { FILE *rp,*wp; //б FILE *fin,*fo1,*fo2; //Է, short data; // 16Ʈ float qam,msg1,msg2; // ȣ Ǽ int n; fin = fopen("qam.raw","rb"); //qam.raw б fo1 = fopen("output1.raw","wb"); //output1.raw fo2 = fopen("output2.r...
C
/* Program:A program to check bitwise operator Author:ghost Date:25-06-2016 */ #include<stdio.h> int main(void){ char ch = 'A'; char temp = (ch & 100); printf("%d\n",ch); printf("%d\n",temp); printf("%c\n",ch); printf("%c\n",temp); return 0; }
C
#include "libft.h" int ft_strncmp(char *s1, char *s2, int n) { if (!s1) return (-1); while ((*s1 || *s2) && n--) { if (*s1++ != *s2++) return ((unsigned char)*--s1 - (unsigned char)*--s2); } return (0); }
C
#include "world_interaction.h" NodeRayInfo* new_node_ray_info() { NodeRayInfo *result = talloc(sizeof(NodeRayInfo)); result->info = (RayHitInfo){0}; result->node = NULL; result->next = NULL; return result; } NodeRayInfo *do_raycast(Region *map, Ray ray) { if (map->scene_root != NULL) { ret...
C
#include <stdio.h> #include <math.h> #include "NumClass.h" int isPrime(int x); int isStrong(int x); int isPrime(int x) { if (x == 1) { return TRUE; } if (x <= 0) { return FALSE; } for (int i = 2; i <= sqrt(x); i++) { if (x % i == 0) { return 0; } } return 1; } unsigned long long fact(int n) ...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #include "geometry.h" #include "linearalgebra.h" /*parameters of the Hamiltonian that need to be set*/ static int N; static double mass=0.0; static double *V; static double min = 0.0; //minimum value of the potential; static i...
C
#include<stdio.h> int main() { int a,b,c; scanf("%d %d %d",&a,&b,&c); for(int i = a ; i>0; i--) { if(a%i == 0 && b % i == 0 && c % i == 0) { printf("%d",i); break; } } }
C
#include <stdio.h> #include <stdlib.h> #include "allocator.h" long mem = 0; void * _malloc(int size) { mem += size; return malloc(size); } void * _calloc(int count, int size) { mem += size * count; return calloc(count, size); } // modificat in urma post-ului de pe foru...
C
#include "holberton.h" /** * _strlen_recursion - function that returns the length of a string * @s: string. * Return: x. */ int _strlen_recursion(char *s) { int x; x = 0; if (*s != '\0') { x = _strlen_recursion(s + 1); x++; } return (x); }
C
/* HNR CSCE 121-200, Fall 2016, Final Project Author: Megan Grahmann, Clare Lamers, Josiah Coad CODE DESCRIPTION: This is the code for interfacing the main menu */ // import guards #ifndef MAINMENU_H #define MAINMENU_H // GUI, graphics and supporting libraries #include "Graph.h" #include "GUI.h" #incl...
C
extern A; int power(int n) { int i, y = 1; for (i = 1; i <= n; ++i) { y *= A; } return (y); }
C
#include "types.h" #include "stat.h" #include "user.h" int main(int argc, char * argv[]) { int i=0; int tits[300]; while(i<300) { tits[i] = uptime(); i++; } for(i=0; i<300; i++) { printf(1, "tick[%d] = %d\n", i, tits[i]); } // YONGJIN IS A NAUGHTY BOI }
C
#include <stdio.h> /** Best: O(nlgn), AVG: theta(nlgn), Worst: O(nlgn) */ void print_array(int arr[], int n) { for (int i=0;i<n;i++){ printf("%d\n", arr[i]); } } void merge(int arr[], int l, int m, int r) { int i,j,k=0; int n1 = m - l + 1; int n2 = r - m; int left[n1]; int right[n2]; for(...
C
//INTEGRANTES: //Guilherme Nishi Kanashiro (RA: 628298) //Tiago Bachiega de Almeida (RA: 628247) #include <iostream> #include <string> #include <fstream> //relacionado a arquivo #include <stdio.h> #include <dirent.h> //Relacionado a diretorio #include <vector> #include <string.h> #include <sstream> //Relacionado a s...
C
#include <stdio.h> #define LIMIT 30 struct game { char title[LIMIT]; char platform[LIMIT]; char developer[LIMIT]; int release; char borrower[LIMIT]; int borrowed; }game; struct date { int day; int month; int year; }date; void addgame(void); void updategame(void); void removegame(void); int main(void) { p...
C
#include<stdio.h> #include<stdlib.h> void main() { int i,n,sum1=0,sum2; printf("Enter the number: "); scanf("%d",&n); int *a=(int *)malloc((n-1)*sizeof(int)); printf("Enter the elements:\n"); for(i=0;i<n-1;i++) scanf("%d",&a[i]); sum2=(n*(n+1))/2; for(i=0;i<n;i++) ...
C
#include<stdio.h> #include "Simple-linked-list.h" Node *head = NULL; int main(int argc,char** argv) { printf("Before delete \n"); insert_in_the_head(&head,1); insert_in_the_head(&head,2); insert_in_the_head(&head,3); insert_in_the_end(&head,4); display_List(head); printf("After delete \n"...
C
#include <sys/time.h> int gettimeofday(struct timeval *tv, struct timezone *tz); int settimeofday(const struct timeval *tv, const struct timezone *tz); int stime(const time_t *t); /* * settimeofday和stime都可以用来设置系统时钟,前者精度更高. * 无论是settimeofday,还是stime这两个调用所造成的那种系统时间突然变化,都会导致那些依赖于系统时钟单调 * 递增的应用造成有害的影响,出于这个原因,通常推荐使用...
C
#include <stdio.h> int count = 0; //Contatore di mosse void hanoi(int n, int sorg, int app, int dest); void muoviUnDisco(int sorg, int dest); int main(int argc, char **argv) { /* Dichiarazione delle variabili */ int dischi; /* Input */ printf("Caro utente,\nsono un robot che risolve il probleme del...
C
/* * hardware.c * * Created: 7/19/2020 11:06:26 AM * Author: olegk */ #include "common.h" #include "hardware.h" static void write_to_data_bus( unsigned char data ) { DDRB = 0xFF; PORTB = data; } static unsigned char read_from_data_bus() { DDRB = 0x00; PORTB = 0x00; return PINB; } #define EEPROM_WRITE_ENA...
C
#include <stdio.h> #include <stdlib.h> #include <err.h> int isAvailable(int puzzle[9][9], int row, int col, int num) { int start_row = (row/3) * 3; //Define the starting row int start_column = (col/3) * 3; //Define the starting column for(int i = 0; i < 9; ++i) { if (puzzle[row][i] == nu...
C
#include <sys/socket.h> #include <sys/types.h> #include <netdb.h> #include <stdlib.h> #include <stdio.h> #include <arpa/inet.h> #include <netinet/ip_icmp.h> #include <string.h> #include <stdint.h> #include <sys/time.h> #include "icmp-utils.h" struct sockaddr_in pong(int); int main(int argc, char* argv[]) { int s...
C
/* ************************************************************************** */ /* */ /* :::::::: */ /* push_swap.h :+: :+: ...
C
// CPromise.cpp : Defines the entry point for the console application. // #include <stdio.h> #include "cpromise_tests.h" #ifdef __cplusplus extern "C" { #endif void test_Execute_CPromise_Suite(void) { test_CanInitializeAndDisposePromiseManager(); test_CanProcessWithEmptyList(); test_CanAddAPromise(); test_...
C
#include <machinescience.h> #include <usart.c> #include <spi_master.c> #include <at45.c> #include <ms_print.c> #include <usart_print.c> #include <adc.c> #include <delay.c> #define MHZ8 0 #define KHZ125 6 #define NOTHING 9 volatile unsigned char minutes; volatile unsigned char hours; volatile unsigned...
C
#include "FrameDataPool.h" /** * 音视频数据队列 */ //视频帧数据相关函数 void initVedioFrameQueue(VedioFrameQueue * frameQueue) { memset(frameQueue, 0, sizeof(VedioFrameQueue)); frameQueue->length = 0; frameQueue->queueHead = NULL; frameQueue->queueTail = NULL; frameQueue->vedioQueueLock = SDL_CreateMutex(); } int pushVedioFr...
C
/*Swapping of array*/ #include<stdio.h> void main(){ int n,i,a[100],b[100]; printf("Ehter the size of array : "); scanf("%d",&n); printf("\n Enter the array elements : "); for(i=1;i<=n;i++){ scanf("%d",&a[i]); } printf("Entered elements are : "); for(i=1;i<=n;i++){ print...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> #define MAX 100000 void Merge(int *V, int inicio, int meio, int fim){ int *temp, p1, p2, tamanho, i, j, k; int fim1=0, fim2=0; tamanho = fim-inicio+1; p1=inicio; p2=meio+1; temp=(int*)malloc(tamanho*sizeof(i...
C
/* * COCONUT PI & CALCULATOR + more * By: Justin Kwok * Email: jckwok@ucsc.edu * Date: Feb 14, 2009 * Description: This program is a combination of the calculator and * coconut pi, along with various other small functions. */ /* Preprocessor commands */ #include <stdio.h> #include <math.h> #...
C
//#include <memory.h> struct information {char info[50]; struct information*next; }; struct information* creat() {struct information *head,*p1,*p2; p1=p2=(struct information*)malloc(len); p1->next=NULL; gets(p1->info); while(strcmp(p1->info,"end")!=0) {p2=p1; p1=(struct information*)malloc(len); ...
C
#include <stdlib.h> #include <math.h> #include "gl-matrix.h" mat4_t mat4_create(mat4_t mat) { mat4_t dest = calloc(sizeof(float), 16); if (mat) { dest[0] = mat[0]; dest[1] = mat[1]; dest[2] = mat[2]; dest[3] = mat[3]; dest[4] = mat[4]; dest[5] = mat[5]; ...
C
#include <stdio.h> #include <time.h> #include <stdlib.h> #include <string.h> /* Input data must be uniqued! */ // TARKISTA VAIKUTTAAKO SORTTAUKSEN AIKAAN SE ETTÄ ON JO SORTATTU! void main(void){ FILE *input = fopen("input", "rb"); FILE *output; char output_name[25]; char buffer[103]; if(input ...
C
#include<stdio.h> #include<stdlib.h> #include<sys/types.h> int arreglo[5] = {1,2,3,4,5}; int i, j; int pares, impares; int main(){ i = 0; j = 0; pares=impares=0; switch(fork()){ case -1: { printf("Hubo problemas al crear el proceso\n"); } case...
C
#include <stdlib.h> #include "header.h" struct s_queue *queueInit(void) { struct s_queue *queue; if ((queue = (struct s_queue*)malloc(sizeof(struct s_queue)))) { queue->first = NULL; queue->last = NULL; } return queue; } char *dequeue(struct s_queue *queue) { char *message = NULL; if (queue->first) { me...
C
#include <pthread.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> #define MAX_NUM 7 #define MAX_THREAD 3 // Global Variables int part = -1; // processing the thread No. int sum = 0; float avg = 0.0; int num[MAX_NUM] = {90, 81, 78, 95, 79, 72, 85}; int min = 0; int max = 0; // Function Prototype void *...
C
#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "monty.h" /** * push_t - Entry Point * @head: variable * @line_number: variable * Return: 0 */ void push_t(sttack_t **head, unsigned int line_number) { sttack_t *nuevo_nodo; (void)line_number; nuevo_nodo = add_node(variabl...
C
#include<stdio.h> #include<string.h> #include<sys/socket.h> #include<arpa/inet.h> #include<unistd.h> #include <stdlib.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #define MAXLEN 1024 int main(int argc , char *argv[]) { FILE *fp; char *line = NULL; size_t len = 0; ssize_t ...
C
#include <unistd.h> void ft_foreach(int *tab, int length, void(*f)(int)); void ft_putchar(char c) { write(1, &c, 1); } void ft_putnbr(int nbr) { long num; num = nbr; if (num < 0) { ft_putchar('-'); num *= -1; } if (num > 9) ft_putnbr(num / 10); ft_putchar(num % 10 + 48); } typedef void (*funptr)(in...
C
#include "lablog.h" #include "commandhandler.h" #include <stdio.h> #include <string.h> #include <stdlib.h> #include <getopt.h> #include <unistd.h> #include <stdbool.h> FILE * infoFile = NULL; FILE * tempInfoFile = NULL; FILE * logFile = NULL; FILE * tempLogFile = NULL; int main(int argc, char* argv[]){ ...
C
/** * * File: stack.c * Description: Operations over stack * Author: David Benes <xbenes41@stud.fit.vutbr.cz> * **/ #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <stdbool.h> #include <string.h> #include "error.h" #include "stack.h" #include "pool.h" /////////////////// // Path Stack // ...
C
/*Página 7 do PDF */ #include <stdio.h> #include <stdlib.h> int main(void) { int num = 20; int *Pont_num = &num; printf("O valor da varial num = %d.", num); printf("\nO valor contido no endereco da variavel num: %x. \n", &num); printf("O valor contido no ponteiro *Pont_num: %d. \n", *...
C
#include<stdio.h> int main(void) { int t,n,arr[200]={0},m=0,i,j,temp=0,x=0; scanf("%d",&t); for(;t>0;t--) { scanf("%d",&n); arr[0]=1; m=1; for(i=2;i<=n;i++) { for(j=0;j<m;j++) { x=(arr[j]*i)+temp; arr[j]=x%10; temp=x/10; ...
C
#include <stdio.h> #include <math.h> int main() { int trials, n, m, potencia, digitos = 0; scanf("%d", &trials); while (trials > 0) { scanf("%d %d", &n, &m); digitos = 1 + m * log10(n); printf("%d\n", digitos); trials--; } return 0; }
C
#pragma once inline float ApproachVal(float target, float value, float speed) { float delta = target - value; if (delta > speed) value += speed; else if (delta < -speed) value -= speed; else value = target; return value; }
C
#include "unp.h" #include <sys/types.h> /* See NOTES */ #include <sys/socket.h> int main(int argc, char **argv) { int sockfd; struct sockaddr_in servaddr; struct sockaddr_in srcaddr; if (argc != 3) err_quit("usage: udpcli <IPaddress> <port>"); bzero(&servaddr, sizeof(servaddr)); servaddr.sin_fam...
C
/** * * 给定仅有小写字母组成的字符串数组 A,返回列表中的每个字符串中都显示的全部字符(包括重复字符)组成的列表。例如,如果一个字符在每个字符串中出现 3 次,但不是 4 次,则需要在最终答案中包含该字符 3 次。 你可以按任意顺序返回答案。 示例 1: 输入:["bella","label","roller"] 输出:["e","l","l"] 示例 2: 输入:["cool","lock","cook"] 输出:["c","o"]   提示: 1 <= A.length <= 100 1 <= A[i].length <= 100 A[i][j] 是小写字母 来源:力扣(LeetCode) 链接:http...
C
/** * @file * Defines the public interface for searching and iterating over roles. * * @author Kevin Carr kcarr@tresys.com * @author Jeremy A. Mowery jmowery@tresys.com * @author Jason Tang jtang@tresys.com * * Copyright (C) 2006-2007 Tresys Technology, LLC * * This library is free software; you can ...
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 <stdio.h> #include <string.h> #include <stdlib.h> #include <errno.h> #include <netdb.h> #include <unistd.h> #include <arpa/inet.h> #include <sys/wait.h> #include <fcntl.h> #include <sys/sendfile.h> #include <sys/types.h> #include <sys/socket.h> //socket creat #include <...
C
#include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <stdint.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/msg.h> #include <errno.h> struct foo_msgbuf { long mtype; struct { int x; int y; } mdata; }; int main() { key...
C
/** * @file page.c * @brief Virtual Memory management * * @author Daniel Balle (dballe) * @author Loic Ottet (lottet) * @bugs No known bugs */ #include <page.h> #include <interrupts.h> #include <stdlib.h> #include <string.h> #include <malloc.h> #include <common_kern.h> #include <x86/page.h> #include <assert.h>...
C
#include <stdio.h> int add(int a, int b){ return a + b; } int minus(int a, int b){ return a - b; } int multiply(int a, int b){ return a * b; } int divide(int a, int b){ return a / b; } int operation(int a, int b, int (*operation)(int, int)){ return operation(a, b); } int main(int argc, char* argv[]){ int val; ...
C
/* Includes */ #include <stdio.h> #include <string.h> #include "internal.h" #include "benzina/benzina.h" /** * @brief String Utilities: * * basename(s): * If s is made up of path segments, return pointer to beginning of last * such segment, else s itself. * strequals(s,p): * Returns 0 if strings ...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> void hex_dump(char *f_name) { FILE *fp = fopen(f_name, "rb"); if (fp == NULL) { fprintf(stderr, "File open error\n"); exit(1); } unsigned char buf; for (int i = 0; fread(&buf, sizeof(char), 1, fp) >= 1; ++i) printf("...
C
// // vetorDescritor.c // Problema // // Created by Vinícius Cantuária on 27/04/2018. // Copyright © 2018 Vinícius Cantuária. All rights reserved. // #include "vetorDescritor.h" void normalizaVetor(float *vetor) { float minimo = 0.0; float maximo = 0.0; for (int i = 0; i < TAMANHOVETOR; i++) { ...
C
#include <sys/mman.h> #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <stdlib.h> #include <sys/stat.h> #include <fcntl.h> #include <signal.h> #include <sys/time.h> #include <time.h> #define name "/forker" #define size 10 struct clocky{ int h,m,s,ms; }; struct item{ struct clocky thehour; in...
C
/* QueueViaStack.c * stackʵһqueue * ˼· stackNewest stackOldest * Note ʱstackOldestǿ ҪȫstackNewestԪƵstackOldest * When someone creates something with all of their heart, * then that creation is given a soul. */ #include "stdafx.h" #include <stdio.h> #include <string.h> #include <stdlib.h> struct ...
C
#include<stdio.h> union ustud // size allocate the largest data size { int rollno; char name[10]; float fees; char subject[12]; }ustudent; struct sstud // size allocate the sum of all datatype size present in struct { int rollno; char name[10]; float fees; char subject[10]; ...
C
/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ struct ListNode* swapPairs(struct ListNode* head) { if(!head) return head; struct ListNode* dummy = (struct ListNode*)malloc(sizeof(struct ListNode)); dummy->next = head; struct ListN...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_get_walls.c :+: :+: :+: ...
C
#include "key.h" #include "delay.h" //ʼ //PC4PC5 ó void KEY_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);//ʹPORTCʱ GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);//رjtagʹSWDSWDģʽ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4|GPIO_Pin_5; GPIO_InitS...
C
/* * ap.c * * Created on: 2018. 5. 12. * Author: Baram */ #include "ap.h" void apInit(void) { uartOpen(_DEF_UART1, 115200); uartOpen(_DEF_UART2, 115200); } void apMain(void) { while(1) { // PC로 부터 명령 받아서 _DEF_UART2 포트로 문자열 출력 // if (uartAvailable(_DEF_UART1) > 0) { uint8_t...
C
/** * CacheSim.c * This program is designed for class exercise only. * It is provided as is. There is no warranty or support of any kind. * * Krerk Piromsopa, Ph.D. * Department of Computer Engineering * Chulalongkorn University * Bangkok, Thailand. * * History * 2013 - Initial design * 2015 - Refactor/Cl...
C
#include "election.h" int main(int argc, char * argv[]) { nombreProcessus = atoi(argv[1]); pid_t* tableauPID = (pid_t*) calloc(nombreProcessus, sizeof(pid_t)); int i; int PvF[nombreProcessus][2]; /* Allocation des tubes */ int** tube = (int**) malloc(nombreProcessus * sizeof(int*)); for (i...
C
/* * uart.c * * Created: 2/22/2020 4:02:43 PM * Author: quaz9 */ #include "uart.h" void uart_init(uart_device* P_device) { //initializes struct containing all the options for uart communication static usart_serial_options_t usart_options = { .baudrate = 115200, .charlength = USART_CHSIZE_8BIT_gc, .pari...
C
//Activity selection by greedy's Algorithm #include<stdio.h> #include<time.h> int main() { int t1,n,i; clock_t t; t=clock(); printf("enter the no. of testcases\n"); scanf("%d",&t1); while(t1--) { printf("enter the no. of activities\n"); scanf("%d",&n); int s[n]; int e[n]; printf("enter the s...
C
/********************************************************** * Name: memory.h * * Date: 9/14/16 * * Description: This module contains several memory * manipulation functions. * * Author: Ben Heberlein & Jeff Venicx * ***********************************************************/ #ifndef MEMORY_H #define MEMORY_H #includ...
C
/* $ID: matrix.c, last updated 2018/07/30, F. Osorio */ #include "matrix.h" /* basic matrix manipulations */ double norm_sqr(double *x, int inc, int n) { /* sum(x * x) */ double ans; ans = F77_CALL(dnrm2)(&n, x, &inc); return SQR(ans); } void ax_plus_y(double alpha, double *x, int incx, double *y, int incy, ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_del_str_ind.c :+: :+: :+: ...
C
#include <stdlib.h> #include <stdio.h> #define MAXSIZE 10 typedef int ElementType; int ERROR; /*当使用单链表来存储队列时,单链表的表头可以实现插入和删除,但链表末尾只能实现插入*/ struct Node{ ElementType Data; struct Node *Next; }; struct QNode{ struct Node *front; struct Node *rear; }; typedef struct QNode *Queue; Queue PtrQ; ElementType D...
C
#include <stdio.h> int main () { printf ("This is my first program on github.\r\n"); return 0; }
C
/* 5. Accept on character from user and check whether that character is vowel (a,e,i,o,u) or not. Input : E Output : TRUE Input : d Output : FALSE */ #include "Header.h" int main() { char cValue = '\0'; BOOL bRet = FALSE; printf("Enter character\n"); scanf("%c",&c...
C
#include "../../../ft_printf.h" static int d_posit_over_w_m(t_flags flags, int size, char *s_res) { int sum_d; sum_d = 0; if (flags.val_p == 0 && *s_res == '0') sum_d += over_width(flags.val_w, 0); else { sum_d += write_d_s_res(s_res, size); sum_d += over_width(flags.val_w, size); } return (sum_d); } st...
C
#include "timer0.h" void Timer0_Init(void) { TMR0H = 0; // Reset Timer0 to 0x0000 TMR0L = 0; INTCONbits.TMR0IF = 0; // Clear Timer0 overflow flag INTCONbits.TMR0IE = 0; /* T0CON values bit 7 TMR0ON: Timer0 On/Off Control bit 1 = Enables Timer0 0 = Stops Timer0 bit 6 T08BIT: Timer0...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_input.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> int randrange(int n){ return rand() / (RAND_MAX / n + 1); } void printHistogram(int n){ for(int i = 0; i < n; i++) printf("%c", '*'); } int main(){ int i; int d1, d2; int a[12]; float total = 0; float sumpow = 0; for(i = 2; i <...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdint.h> #include <errno.h> #include "metadata.h" struct metadata *md_init(char *filename, int line, const char *fxn_name, void *ret_ptr, void *arg_ptr, clock_t time, int alloc_free, int retval, int error, u_int size, int flag){ struct ...
C
#include <stdio.h> int main(){ printf("%d \n", counter(5)); printf("%d \n", counter(15)); printf("%d \n", counter(10)); printf("%d \n", counter(25)); } int counter(int k){ int counter = 0; int i; for(i=1; i<=k; i++){ int tmp = i; while(tmp%5 == 0){ tmp /= 5; counter++; } } return counter; }
C
/*Swap odd even bits in a number*/ #include <stdio.h> #include <stdint.h> #include <string.h> #include <stdlib.h> #define EVEN_SET 0xAAAAAAAA #define ODD_SET 0x55555555 int main() { uint32_t number = 23; uint32_t even_data = number & EVEN_SET; uint32_t odd_data = number & ODD_SET; odd_data = odd_data << 1...