language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
/* 根据完全二叉树的定义 具有n个节点的完全二叉树 与 满二叉树中的编号从1~n的节点一一对应 */ //采用层次遍历 将所有节点加入队列(包括空节点)。 //当遇到空节点时,再查看其后是否有非空节点。若有则不是 bool IsComplete(BiTree T) { InitQueue(Q); if(!T) return 1; //空树为满二叉树 Enqueue(Q,T); while(!IsEmpty(Q)) { DeQueue(Q,p); if(p) //节点非空 将其左右孩子入队列 { EnQueue(Q,p->lchild); EnQueue(Q,p->rchild); ...
C
#include <stdio.h> #include <stdlib.h> int* activity_selection(int a[], int s[], int f[], int n) { int* arr = malloc(sizeof(int)*n); // array arr of size n arr[0] = 0; //array will start from index 1. So, fake item at index 0 arr[1] = a[1]; int k=1; int i; int iter = 1; for(i=2; i<=n; i++...
C
/* * Find the smallest member of the longest amicable chain with no members above N */ #include <stdio.h> #include <stdlib.h> #include "utils.h" #include "math_utils.h" #include "linked_list.h" #define INFINITY -1 static int * get_divisor_sums (int); static int get_solution (const int *, const int *, int); int ma...
C
#include "holberton.h" /** * create_file - create a file with read/write access for user * @filename: name of file to create * @text_content: string to write to file * Return: 1 on success, -1 on failure */ int create_file(const char *filename, char *text_content) { int fd, rstatus, i; if (filename == NULL) ret...
C
#ifndef ROBOT #define ROBOT #define pi 3.14159 #define nombreCranParToursDeRoue 100 #define tailleTableauValeursImpulsions 10000 #include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> int nombreCoordonnees; int periode; //en secondes typedef struct position { int roueGaucheX; ...
C
/* * 2s_w02p01_ultrasonic.c * * Created: 2020-09-23 오전 9:49:37 * Author : Yunseo Hwang */ #define F_CPU 16000000UL #include <avr/io.h> #include <util/delay.h> #include "lcd1602a_h68.h" #include "uart.h" #define BV(n) (1 << n) #define SOUND_VELOCITY 340UL #define TRIG 6 #define ECHO 7 void ultrasonic_set(); uns...
C
#include <stdlib.h> #include <stdio.h> #include <time.h> // time for seeding #include <pthread.h> // include pthread functions and structures #include <semaphore.h> // include semaphores #include <unistd.h> // include sleep /** Producer - Consumer Simulation * @author Nefari0uss * * This simulation was to help ...
C
/******************************************************************** * formula.h * * Defines types for fault trees. * * Author: Clovis Eberhart ********************************************************************/ #ifndef __CCL_FAULT_TREE_H__ #define __CCL_FAULT_TREE_H__ #include <stdbool.h> #include "proof.h"...
C
#include <stdio.h> #include <stdlib.h> int palidromo(int *p,int n) { int i=0; int j=n-1; int cont=0; for(i=0;i<n;i++) { if(p[i]==p[j]) { } else if(p[i]!=p[j]) { cont++; } j--; } if(cont==0) //e palidromo {...
C
/* Pet Thread Library * (c) 2017, Jack Lange <jacklange@cs.pitt.edu> */ #include <stdio.h> #include <stdlib.h> #include <setjmp.h> #include <assert.h> #include "pet_thread.h" #include "pet_hashtable.h" #include "pet_list.h" #include "pet_log.h" #define VERBOSE 0 #define STACK_SIZE (4096 * 32) typedef enum {P...
C
#include<stdio.h> #include<math.h> char a[100][100]; int n; void printmatrix() { int i,j; for(i=0;i<n;i++) { for( j=0;j<n;j++) printf("%c ",a[i][j]); printf("\n"); } } int getmarkedcol(int row){ int i; for(i=0;i<n;i++) if(a[row][i]=='Q') { return(i); break; } } int feasible(int row,int col) {...
C
extern char* strfleft(char* string,char separator); /*úַstringĵһseparator䱾ߵַ stringΪַseparatorΪָ stringвseparator򷵻Դַstring separatorΪstring׸ַ򷵻ؿַ stringΪַ򷵻ؿַ*/ extern char* strlleft(char* string,char separator); /*úַstringһseparator䱾ߵַ stringΪַseparatorΪָ stringвseparator򷵻Դַstring separatorΪstring׸ַ򷵻ؿַ stringΪַ򷵻ؿַ...
C
#include <unistd.h> #include <time.h> #include <sys/types.h> #include <fcntl.h> int main() { time_t result; pid_t pid; int filedes; ssize_t nread; char buffer[32]; pid = fork(); if(pid > 0) { sleep(1); exit(1); } else if(pid == 0) { setsid(); filedes = open("./curtime.txt", O_RDWR | O_CREAT, 064...
C
#include "clientSession.h" #include "packet.h" #define BACKLOG 20 bool message=false; struct message processPacket(struct message incomingPacket, User *current){ printf("in process packet!\n"); struct message packetToSend; //process the packet //1. look at the packet type switch (incomingPa...
C
#include<stdio.h> int main() { /*1. жswitch caseʱִ䣻 caseûbreak;ִкĴֱbreak; ûзcaseִdefault; default⣬ûûbreak;ִк䣻 switchһҪbreakdefault ÷*/ int x=3,a=0,b=0; switch(x--) { case 0:b++; case 1:printf("%d",a++); default:b=b-2; case 2:printf("%d",a++),b++; } printf("a=%d,b=%d",a,b); return 0; }
C
#include <stdio.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> extern int errno; #include "functions.h" void no_such_file_or_directory_error(char *filename){ char error_message[200]; errno = 2; strcpy(error_message, "tail: ...
C
#include <stdio.h> int main(void) { int input[10]; int sum; float avg; int repeat; do { sum = avg = repeat = 0; printf("Bitte geben sie 10 ganze Zahlen ein.\n"); for (int i = 0; i < 10; i++) { printf("Zahl %d: ", i + 1); scanf("%d", &...
C
#include<stdio.h> #include<math.h> float f(float x) { return sin(x)+3*x-exp(x); } void swap(float* x0,float *x1) { float x; x=*x0; *x0=*x1; *x1=x; } int main() { float x0,x1,x2,e=0.00005; printf("Enter initial guesses: "); scanf("%g%g",&x0,&x1); do { if(fabs((*f)(x0))<fabs(...
C
/* * File name: CTRL_Application.h * Created on: Oct 21, 2021 * Author: osama */ #ifndef CTRL_APPLICATION_H_ #define CTRL_APPLICATION_H_ /********************************************************/ /* Definitions & Configurations */ /********************************************************/ #define ...
C
#include <math.h> #include "vector.h" struct Vector VEC_N = {0, -1}; struct Vector VEC_S = {0, 1}; struct Vector VEC_E = {1, 0}; struct Vector VEC_W = {-1, 0}; struct Vector VEC_NE = {1 / sqrt(2), -1 / sqrt(2)}; struct Vector VEC_NW = {-1 / sqrt(2), -1 / sqrt(2)}; struct Vector VEC_SE = {1 / sqrt(2), 1 / sqrt(2)}; s...
C
/** * @file sock_init.c * @author your name (you@domain.com) * @brief * @version 0.1 * @date 2021-09-12 * * @copyright Copyright (c) 2021 * */ #include "tftpd_commands/tftp_sock_init.h" struct tftp_connection *tftp_conn; bool tftp_sock_init (char *ip, u_short port) { int retval; tftp_conn = (struct tft...
C
#include"functions.h" void interface(int socket) { int option=0; printf("Welcome! enter one of the following options to continue...\n"); printf("1 : Sign Up\n"); printf("2 : Sign In\n"); scanf("%d",&option); while(option!=1 && option!=2) { printf("Select either 1 or 2 :- "); ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "getCharTest.c" #define MAXWORD 50 struct node{ char *string; struct node *downLeft; struct node *downRight; int len; int occurrence; struct node *left; struct node *right; }; int strcmpPre(char *str1, char *str2, int num){ w...
C
#define MAX_COL 100 #define MAX_LIN 100 typedef struct info_s{ char caminho[MAX_LIN][MAX_COL]; // ponteiro para as linhas do mapa int linhas; // guarda o numero de linhas int colunas; // guarda o numero de colunas }info_t; info_t *infoMapa; typedef struct pilha_s{ int atual; int quantidade; i...
C
#include<stdio.h> #include<stdlib.h> #define TOKEN_SIZE 2000 #define TOKEN_ARRAY_SIZE 200 int strcmp(const char *s1,const char *s2); char** strtoken(const char *s, const char *delim,int *len); void strcat(char* envPath, char* path); void strcpy(char* dest, char* src); int strlen(char *s); void free_array(char **tokens...
C
/*Program 5.9 : Write a program that displays sum of the elements passed as command line arguments.*/ #include<stdio.h> #include<stdlib.h> void main(int argc,char* argv[]) { int i; float result; result=0.00; for(i=1;i<argc;i++) result=result+atoi(argv[i]); /* Function atoi(),converts a number represented as a...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> typedef struct blockInfo { char **blocks; // 2d char array to hold text in keyLength sized blocks char *key; // string used to encipher each block char *IV; // string used to initiate encipher algorithm int k...
C
#define PCRE2_STATIC #define PCRE2_CODE_UNIT_WIDTH 8 #include <stdio.h> #include <string.h> #include <stdlib.h> #include <string.h> #include "uthash/uthash.h" #include "text_cleanser.h" #include "preg_replace.h" char *replace(char *re, char *replacement, char *subject) { char *output; output = preg_replace(re, ...
C
// Computing the length of a string, recursive function size_t my_strlen_rec(const char *); // Computing the lenght of a string, iterative function size_t my_strlen_ite(const char *); // Comparing two strings "lexical graphically" order, iterative function. int strcmp_ite(const char *, const char *); // Comparing t...
C
#include "shell.h" /** * call_env - Built in function for env * * @env: Double char pointer * * Return: Integer */ int call_env(char **env) { int i = 0; int len = 0; char *copy = malloc(8192); while (env[i] != NULL) { len = _strlen(env[i]); copy = _strdup(env[i]); write(STDOUT_FILENO, copy, len + 1...
C
#include<stdio.h> int main(){ int b, p,i; int r=1; printf("Digite o valor da base:"); scanf("%d",&b); getchar(); printf("Digite o valor da potencia:"); scanf("%d",&p); getchar(); for(i=0;i<p;i++){ r= r*b; } printf("O resultado e :%d",r); return 0; }
C
#include "minishell.h" void reset_input_mode (void) { tcsetattr (STDIN_FILENO, TCSANOW, &g_saved_attributes); } /* Make sure stdin is a terminal. */ /* Save the terminal attributes so we can restore them later. */ /* Set the funny terminal modes. */ /* Clear ICANON and ECHO. */ static void set_input_mode (t_term...
C
#include <stdio.h> extern int getPrecision(); extern void setPrecision(int); int main(void){ int choice, precision; do{ printf("1. Check precision\n2. Set precision\n0. Exit\n>"); scanf("%d", &choice); if (choice == 1){ precision = getPrecision(); switch (preci...
C
#include "raylib.h" int main(void) { // Initialization //-------------------------------------------------------------------------------------- const int screenWidth = 800; const int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input"); Vector2 ballPosition = {...
C
#include <stdio.h> #include <string.h> #include <stdbool.h> #define LET 26 #define MAX 1000010 #define clr(ar) memset(ar, 0, sizeof(ar)) #define read() freopen("lol.txt", "r", stdin) int r, idx, counter[MAX], trie[MAX][LET]; void initialize(){ int i; r = 0, idx = 1, counter[r] = 0; for (i = 0; i < LET; i...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> void doRead(const int fd) { do { char buffer[100]; bzero(buffer,sizeof(buffer)); if(read(fd,buffer,sizeof(buffer)) < 0) { perror("read er...
C
#include <stdio.h> #include "square.h" int main() { struct square s = newSquare(); printf("perimeter: %d\n", squarePerimeter(s)); printf("area: %d\n", squareArea(s)); return 0; }
C
// WAP to display following pattern: #include <stdio.h> int main() { for (int i = 1; i <= 4; i++) { for (int j = 1; j <= i; j++) { printf("%d", j); } printf("\n"); } printf("\n"); for (int i = 5; i >= 2; i--) { for (int j = 5; j >= i; j--) { printf("%d", j); } p...
C
#include <stdio.h> int main(){ double k; int n=1; scanf("%lf",&k); double sum=0; while(sum<=k){ sum=sum+1.0/n; n++; } printf("%d",n-1); return 0; }
C
#include <sys/stat.h> #include "memo_int.h" typedef struct _MemoPublisher { int connection; char* hostname; char* port; } MemoPublisher; static int mk_msg(int len, char* msg, char* topic, char** buf) { uint32_t slen; int topic_len = strlen(topic); slen = htonl(len + topic_len + 1); ...
C
#include <stdio.h> int cal(int *a, int num){ int max, sum = 0; for(int i = 0; i < num; i += 2){ if(a[i] > a[i + 1]){ max = a[i]; } else{ max = a[i + 1]; } sum += max; } return sum; } int main(){ int a[10]; for (int i = 0; i < 10; ...
C
#include<stdio.h> #include<stdlib.h> typedef struct node { int info; struct node *next; }node; node* insert(node*,int); node* delNode(node*); void display(node*); void main() { node *head; head=NULL; int ch,op,num; do { printf("Menu\n1 INSERT\n2 DELETE nth NODE\n3 DISPLAY\n4 EXIT\...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> struct node { int data; struct node* xnp; }; struct node* head = NULL; struct node* XOR(struct node *a, struct node *b) { return (struct node*) ((long long int) (a) ^ (long long int) (b)); } void insert(int pos, int data) { struct node* newptr = (struc...
C
#include <stdio.h> #include <string.h> typedef struct student { int id; char name [21]; float percentage; } student_t; int main() { student_t record; record.id = 20; strncpy (record.name, "Arowoiya", 21); record.percentage = 97.5; printf("The identity of the student is : %d \n", record.i...
C
#ifndef FUNCTION_C_INCLUDED #define FUNCTION_C_INCLUDED #include "function.h" void printStat(struct car car) { if (car.type != TESLA) { printf("Km: %.2f\nGas: %.2f\n", car.km, car.gas); } else { printf("Km: %.2f\n", car.km); } } #endif // FUNCTION_C_INCLUDED
C
#include <stdio.h> #include <time.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <dirent.h> int main(int argc, char const *argv[]) { int i = copy(argv[1]); printf("%d\n",i ); /* code */ return 0; } int copy(char *argv) { // i代表当前已经打印了的行数 int i = 1; char *target ...
C
#include <stdio.h> /* * The book says: * "environ points to a NULL-terminated list of pointers to null-terminated strings" * * let me see if we can work this out from the symbols: * * environ is a symbol that is a pointer to a pointer to a character variable * "pointer to a character variable" is the same...
C
/* A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a^2 + b^2 = c^2 For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc such that a + b + c = n. */
C
/* Fondamenti di Informatica T1 - modulo di laboratorio Anno accademico 2020-2021 Cognome nome: Carr Edoardo Numero matricola: 0000970140 numero esame: */ #include <stdio.h> #include <stdlib.h> #include "array.h" /*TODO * test * check input */ TYPE* subArray(TYPE* a, int dimA, TYPE first, TYPE last, int* dimS...
C
#include "help_function.h" /** * @brief Vytvori packet pro dotaz * * @param dns_header Ukazatel na hlavicku protokolu * @param dns_question Ukazatel na dotaz * @return char* Vraci ukazatel na vytvoreny packet ktery se posle na server */ char *create_buffer(DNSHeader *dns_header, DNSQuestion *dns_question) { ...
C
#include "../include/kernel.h" #include "../include/string.h" #include "../include/io.h" #include "../include/i386/gdt.h" static unsigned char bufkbd[1024] = {0,}; static inline int syscall(int a, int b, int c, int d){ int _a; asm volatile("movl %1, %%eax; movl %2, %%ebx; movl %3, %%ecx; movl %%edx, %4;int $0x60;movl...
C
#include<stdio.h> #include<unistd.h> #include<stdlib.h> #include<sys/types.h> #include<sys/wait.h> int findTempSum(int start, int end, const int arry[]) { int ts = 0; for (int j = start; j < end; j++) { ts = ts + arry[j]; } return ts; } int main(){ int arry[1000]; int s1[2],s2[2]...
C
/* ** my_select.c for my_select in /home/menich_a/rendu/PSU_2013_my_select ** ** Made by menich_a ** Login <menich_a@epitech.net> ** ** Started on Fri Jan 10 12:58:18 2014 menich_a ** Last update Sun Jan 19 20:13:51 2014 menich_a */ #include <sys/ioctl.h> #include <signal.h> #include <ncurses/curses.h> #include <...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> // Used by qsort(). int cmpfunc (const void * a, const void * b) { return ( *(int*)a - *(int*)b ); } // Prints an array, assuming 0 termination void printArray (int *toPrint) { printf("\n[") ; for (int i = 0; toPrint[i] != 0; i++) ...
C
/* Problem Statement - To accept two numbers from user and display its addition */ #include "Header.h" int main() { int iValue1 = 0; int iValue2 = 0; int iRet = 0; printf("Enter 1st number :\t"); scanf("%d",&iValue1); printf("Enter 2nd number :\t"); scanf("%d",&iValue2); iRet = Ad...
C
/************************************************************************* > File Name: test1.c > Author: > Mail: > Created Time: Sat 14 Nov 2015 04:24:39 PM CST ************************************************************************/ #include<stdio.h> #include<stdlib.h> typedef struct node *ptr; typedef ptr b...
C
#include <stdio.h> void bfs(int); int a[20][20], q[20], visited[20], n, f=0, r=-1, i, j; int main(){ int v; printf("Graph Traversal Breadth First Search\n"); printf("\nEnter the number of vertices: "); scanf(" %d", &n); for(i=1; i<=n; i++){ q[i] = 0; visited[i...
C
// William Randall // wrandall1000@gmail.com // 805167986 #include <pthread.h> //pthread #include <stdio.h> //fprintf #include <stdlib.h> //exit #include <string.h> //strerror //atoi #include <getopt.h> //getopt #include <time.h> //GLOBAL VARS pthread_mutex_t mutex_lock = PTHREAD_MUTEX_INITIALIZER; volatile int spi...
C
#include "libft.h" void proc_uint(t_option *options, va_list ap) { unsigned long num; char *number; num = va_arg(ap, unsigned int); if (options->precision == 0 && num == 0) { number = ""; print_num(options, number); } else { number = ft_utoa(num); if (number == NULL) { options->error = -1; r...
C
#include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <unistd.h> #include <netinet/in.h> #include <arpa/inet.h> #include <string.h> #include <pthread.h> #include <signal.h> #include <time.h> #include <errno.h> #include "common.h" int sendMsg(char *msg,int sock,skaddr *addr,int...
C
/* * dac8532_set.c: * Very simple program to write the DAC8532 serial port. Expects * the port to be looped back to itself * Matt Ebert 04/2018 /* define from bcm2835.h define from Board DVK511 3.3V | | 5V -> 3.3V | | 5V RPI_V2_G...
C
#include <stdio.h> #include <stdlib.h> #include <malloc.h> #include "../kp_6/data.h" #include "../kp_6/output.h" #include "../kp_6/re_builder.h" const int N = 12; void best (info_stud *tmp) { int markss[12] = {0}; int students[12] = {0}; while (tmp) { if (tmp->sex_stud == 'F') { markss[tmp->group_num] ...
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 <tertium/cpu.h> #include <tertium/std.h> #define STRCPY(a, b) c_mem_cpy((a), sizeof((b)), (b)) char * c_gen_dirname(char *s) { usize n; if (!s) return nil; if (!*s) return STRCPY(s, "."); n = c_str_len(s, -1) - 1; for (; s[n] == '/'; --n) if (!n) return STRCPY(s, "/"); for (; s[n] != '/'; --n) if (!n...
C
#include "stdio.h" int main() { struct { int a; int b; }x,y; x.a = 10; y = x; printf("%d\n",y.a); return 0; }
C
/****************************************** * task name: oledDisplay * task inputs: void* pointer to a DisplayData struct (see tasks.h) * task outputs: Text to OLED display * task description: Takes strings from the displayData struct and outputs them to an OLED display * author: Ryan McDaniel ********************...
C
#ifndef __SLIST_H__ #define __SLIST_H__ typedef struct slist slist_t; slist_t *slist_alloc(void (*free)(void *)); void slist_free(slist_t *list); void slist_clear(slist_t *list); size_t slist_size(slist_t *list); void slist_reverse(slist_t *list); void slist_sort(slist_t *list, int(*compare)(void *, void *)); void s...
C
/* ** EPITECH PROJECT, 2019 ** Projet tek1 ** File description: ** lib function */ #include "../include/my.h" char *my_array_strcpy(char *str) { char *str1 = malloc(sizeof(char) * my_strlen(str)); int y = 0; for (; str[y] != 0; y++) str1[y] = str[y]; return (str1); }
C
#include <assert.h> #include <stdio.h> #include <unistd.h> #include <cutils/time.h> #include <cutils/timeout_list.h> // Test a timeout-list where retrieved entries are not older than 100ms #define TIMEOUT_MS 100 int main(void) { int err = 0; // Init a timeout-list with entry size of 8 bytes tolist_ctx_t...
C
#include "head.h" //使用多进程,实现多个客户端通信 int main() { pchild p =(pchild)calloc(NUMCLIENT,sizeof(child));//动态分配内存,初始化为零 create_child(p); int sfd = tcp_init(); int epfd = epoll_create(1); struct epoll_event* evs = (struct epoll_event*)calloc(NUMCLIENT+1,sizeof(struct epoll_event)); epfd_add(sfd,epfd); int i; for(i = ...
C
/* * probotype.c Jim Piper 17-10-86 * * * Use simple tests to decide probable type of object, * currently: NOISE, CHROMOSOME or COMPOSITE on basis of size * * Modifications * 30 Oct 1989 dcb/GJP/CAS Set plist->otype for CHROMOSOME as well as * returning the value */ #include <stdio.h> #include <wstruc...
C
#pragma once #include <brutal/base/macros.h> #include <brutal/base/std.h> #include <brutal/mem.h> struct alloc; void alloc_no_op(struct alloc *self, void *ptr); typedef void *alloc_acquire_t(struct alloc *self, size_t size); typedef void alloc_commit_t(struct alloc *self, void *ptr); typedef void alloc_decommit_t(s...
C
// Lossy Scheme: parser. // // Copyright 2013 Martin Pool #include <assert.h> #include "loss.h" lossobj *loss_cons_new(void) { lossobj *obj = calloc(1, sizeof *obj); assert(obj); obj->type = CONS; return obj; } lossobj *loss_cons_new_pair(lossobj *hd, lossobj *tl) { lossobj *c = loss_cons_new(...
C
#include <stdio.h> int main (int argc, char*argv[]) { FILE * pFile; char c; pFile=fopen(argv[1],"wt"); if (pFile==NULL) perror("fopen error"); for (c = 'A' ; c <= 'Z' ; c++) { putc (c , pFile); } putc('\n',pFile); fclose (pFile); return 0; }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* sastantua.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> #define MaxVertexNum 100 #define INFINITY 65535 typedef int Vertex; typedef int WeightType; typedef char DataType; typedef struct GNode * PtrToGNode; struct GNode { int Nv; int Ne; WeightType G[MaxVertexNum][MaxVertexNum]; DataType Data[MaxVertexNum]; // there a...
C
/* ************************************************************************** */ /* */ /* :::::::: */ /* utils.c :+: :+: ...
C
#include "books.h" #include "inttypes.h" #include "stdlib.h" #define COVER 1 #define INDEX COVER<<1 #define MISS_PAGES COVER<<2 #define BAR_CODE COVER<<3 #define SPINE COVER<<4 #define STAINED_PAGES COVER<<5 static char * zone[]={(char*)"KIDS", (char*)"HIGHSCHOOL", (char*)"ADULT", (char*)"COMICS", (char*)"DOCUMENT...
C
#include "header.h" void insert (node **front, node **rear, node *temp) { if (*rear) { (*rear) -> next = temp; *rear = (*rear) -> next; } else { *rear = temp; } if (NULL == (*front)) { *front = *rear; } }
C
// // schurNumberSaving.h // SchurNumber // // Created by rubis on 14/03/2020. // Copyright © 2020 rubis. All rights reserved. // // Ce fichier déclare les fonctions permettant la sauvegarde des résultats intermédiaires dans un fichier temporaire #ifndef schurNumberSaving_h #define schurNumberSaving_h #include <s...
C
#include "polinomio.h" /** * Funcao retorna um nodo do polinomio inicializado * com zero e ponteiro NULL * @return nodo */ p_nodo *getNodo(float coef, int expo) { p_nodo *nodo = (p_nodo*) malloc(sizeof(p_nodo)); nodo->coeficiente = coef; nodo->expoente = expo; nodo->proximo = NULL; return nodo; } l_po...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/wait.h> #include <signal.h> #include <sys/shm.h> #include <sys/sem.h> #include <sys/types.h> #include <sys/ipc.h> #include <unistd.h> #include <pthread.h> #include <msg.h> #define LEER 0 #define ESCRIBIR 1; #define ERROR -1 /** * @brief Defini...
C
#include <stdio.h> #include <stdlib.h> #include "farey_seq.h" int main() { int n; printf("Please enter n: "); scanf("%d", &n); node * head; head = farey_seq(n); if(head == NULL) printf("The linked list is empty"); delete_list(head); } node * farey_seq(int n) { /*You code goes here*/ } voi...
C
#define TamP 100 typedef int elem; typedef struct { int topo, total; elem itens[TamP]; } Pilha; // Cria uma pilha P void Create(Pilha *); // Esvazia uma pilha P void Empty(Pilha *); //Insere o elemento X na pilha P. Retorna 0 se no houver erro, Retorna 1 se algum erro acontecer int Push(Pilha *, el...
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 "task2.h" int GetCellMax(DP_cell* cell) { int max = cell->substitutionScore; if (cell->deletionScore > max) max = cell->deletionScore; if (cell->insertionScore > max) max = cell->insertionScore; return max; } DP_cell* FillInCell(int row, int col, int subScore, int delScore, int insScore, DP_cell* tab...
C
a#include<stdio.h> #include<stdlib.h> #define size 30 typedef struct stack { int top; int a[size]; }STACK; int push(STACK*,int); int pop(STACK*); int peek(STACK); int empty(STACK); int preceed(char); int main() { STACK s; s.top=-1; int i,j=0; char str[20],post[20],c; printf("enter the infix exprssion to get the post fi...
C
#include <stddef.h> #include <stdlib.h> #include <stdio.h> #include <stdbool.h> #include <string.h> #include <unistd.h> #include <signal.h> #include <sys/types.h> #include <sys/wait.h> #define CHAR_LENGTH 256 typedef struct { char parent[CHAR_LENGTH]; char name[CHAR_LENGTH]; int priority; int memory; }proc; type...
C
/* * GccApplication2.c * * Created: 4/20/2016 6:25:00 PM * Author : Andrew Kim Josh Alpert */ #include "avr.h" #include "lcd.h" #define DDR DDRB #define PORT PORTB #define RS_PIN 0 #define RW_PIN 1 #define EN_PIN 2 #define XTAL_FRQ 8000000lu #define SET_BIT(p,i) ((p) |= (1 << (i))) #define CLR_...
C
#include <stdio.h> #include <ctype.h> int main() { char caractere; while (1) { scanf("%c", &caractere); if (caractere == '@') { break; } else if (!isalpha(caractere)) { continue; } else { printf("%c ...
C
#include "log_space.h" double get_p(log_space ls) { if ( isfinite(ls) ) return exp(ls); else return 0; } log_space get_ls(double p) { if (p == 0) return -INFINITY; else return log(p); } // x*y log_space ls_multiply(log_space x, log_space y) { return (log_space)(x + y); } // x/y log_space ls_divide(log_s...
C
/* *Kory Bartlett *Atkinson 10:30 *Project 1: Counting the Number of Words *Thursday 2:15 *3 April 2014 * * *Program to read words from a text file and count the number of words in the text file */ #include<stdio.h> #include<stdlib.h> #define MAX_WORD_LENGTH 30 int main( int argc, char*argv[])//recieves arguem...
C
#include <stdio.h> #include <stdlib.h> int thirdBits(void) { int a = 0x49; int b = (a << 9); int c = b + a; return (c << 18) + c; // Steps 4 and 5 } int isTmin(int x) { return !(x+x)&!!(x); } int isNotEqual(int x, int y) { return(!!(x ^ y)); } int anyOddBit(int x) { return !!((x | (x >> 8) | (x >> 1...
C
#include <pthread_extra.h> #include <time.h> #include <stdio.h> #include <stdbool.h> /* //This is first prototype for two mutexes only, it is useful in order to understand how this all works //Currently it was replaced by macro with the same name int pthread_mutex_timedlock_two(pthread_mutex_t *a, pthread_mutex_t *b, ...
C
#include <stdio.h> #include <math.h> struct points { int x; int y; } two; float dist(struct points two){ return (sqrt(pow(two.x, 2) + pow(two.y, 2))); }; int main() { printf("Enter 1st coordinate points : "); scanf("%d %d", &two.x,&two.y); printf("\nThe distance between the points and origin ...
C
#include "Node.h" #define End -1 //处理输入文件中结尾 enum //默认构造整型变量 failed=0,success=1,startPoint=2 { failed, success }; /* @param all:保存所有节点的数组 start:为引用,入口节点id @function 初始化迷宫,并把出口信息标记在出口节点上 */ void initialMaze(vector<Node *> &all, int &start); /* @param cur:开始dfs的节点 all:保存所有节点的数组 @return 若找到出口返回success,否则返回fa...
C
#include <stdio.h> typedef unsigned int uint; struct list{ uint p; struct list * next; } struct lh{ struct list * next; } void list_add(struct lh *lh, struct list * list){ struct **nl; nl = &((*lh)->next); while(!(*nl)){ if((*nl)->p >= list->p) break; nl = &((*nl)->next); } list -> next = *nl; *nl =...
C
#include <stdio.h> #define MAXS 200 #define DIMFN 80 int main(int argc, char* argv[]){ char fn[DIMFN+1]; char c; FILE* fp; int i, maxN, minN, n, cRighe, cFrasi; scanf("%s", fn); fp = fopen(fn, "r"); if(fp){ maxN = n = cRighe = cFrasi = 0; minN = DIMFN; fscanf(fp, "%c", &c); while(...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_makestr.c :+: :+: :+: ...
C
/* Programa que concatena duas listas, a partir da lista l1. */ #include <stdio.h> #include <stdlib.h> typedef struct lista { int info; struct lista *prox; } TLSE; void imprimeLista(TLSE *l); TLSE* inicializa(void); TLSE* insereInicio(TLSE *l, int x); //Concatena L2 com L1. TLSE* junta_listas(TLSE *l1, TLSE *l2){...