language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> #include <sys/socket.h> #include <netinet/in.h> #include <netinet/tcp.h> #include <errno.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #define SA struct sockaddr struct data { int count; char buf[64]; int flag; }; int main(int argc, const char *argv[]) { int tcp_socket; struct s...
C
#include<stdio.h> void recur(int); void main(){ recur(5); } void recur(int a){ if(a == 0){ return; } recur(a - 1); printf("%d\n", a); }
C
#include <stdio.h> #include <stdlib.h> #define tamanho 10 int procuraVetor(int vetor[], int procurado, int tam); int procuraVetor(int vetor[], int procurado, int tam){ for(int k = 0; k < tam; k++){ if(vetor[k] == procurado){ return vetor[k]; } } return -1; } int main(int argc, ...
C
#include<stdio.h> char firstchar1 (/*@null@*/char *s) { return *s; } /*char firstchar2 (char *s) { if (s == NULL) return '\0'; return *s; }*/ int main() { char *ptr; firstchar1(ptr); // ch=firstchar2(ptr); // return 0; }
C
/**************************************************** * port_io.c ***************************************************/ #ifndef __DISPLAY_H__ #define __DISPLAY_H__ #define VIDEO_ADDRESS 0xb8000 #define MAX_ROWS 25 #define MAX_COLS 80 //colour schemes #define DEFAULT_COLOUR_SCHEMA 0x0f //white on black //display I/O...
C
#include <unistd.h> #include <stdbool.h> #include <stdio.h> #include <sys/socket.h> #include <sys/types.h> #include <arpa/inet.h> #include <string.h> #include <stdlib.h> bool drukowalne(const void *buf, int len); int main(int argc,char* argv[]){ if(argc!=3){ printf("Wrong numberr of arguments"); printf("\n%s ip po...
C
/*17. Write a C program to convert a given integer (in seconds) to hours, minutes and seconds. Go to the editor Test Data : Input seconds: 25300 Expected Output: There are: H:M:S - 7:1:40 */ #include<stdio.h> int main() { int a,b,c,d; printf("Input seconds :"); scanf("%d",&a); b=a/3600; c=(a%3600)/60; d=(a%3600...
C
#include <assert.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include "lang.h" #include "string.h" #define ASSERT_HEAP_LEN_AND_CAPACITY( STR ) \ assert(STR->len == strlen(STR->str)); \ assert(STR->cap >= strlen(STR->str) + 1) #define ASSERT_STACK_LEN_AND_CAPACITY( STR ) \ assert(STR.len == str...
C
#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> #include<stdlib.h> #include<string.h> int main() { char *p = "abcdef"; printf("%d\n", sizeof(p));//64 printf("%d\n", sizeof(p + 0));//14 printf("%d\n", sizeof(*p));//1ȷ1 printf("%d\n", sizeof(p[1]));//1 printf("%d\n", sizeof(&p));//4 printf("%d\n", sizeof(&p + ...
C
#include<stdio.h> struct emp{ int eno; char ename[20]; float esal; }; int main() { char *cp; int *ip; struct emp *point; printf("size of char * is:%d\n",sizeof(cp)); printf("size of int * is:%d\n",sizeof(ip)); printf("size of struct emp * is:%d\n",sizeof(struct emp *)); printf("size of struct emp * is:%d\n",s...
C
#ifndef __SERVO_H_ #define __LED_DIM_H_ #include <libopencm3/stm32/timer.h> /** * Prescale 24000000 Hz system clock by 24 = 1000000 Hz. */ #define PWM_PRESCALE (23) //as in "Discovering STM32...", values 0..23 are 24 values /** * We need a 50 Hz period (1000 / 20ms = 50), thus devide 100000 by 50 = 20000 (us). *...
C
#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { float a,b; scanf("%f %f",&a,&b); if( b >0.0) { printf("%f\n",a/b); } // end zero check else { printf("poss div by zero\n"); } }
C
/* * File: main.c * Author: Forest Davis-Hollander and Chunliang Tao * * Created on November 14, 2019 * * This program uses UART2 to communicate with a workstation using an external Matlab script. The program receives a series of ASCII values corresponding to either "Overdamped" or Underdamped," and then it a...
C
/****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. Code, Compile, Run and Debu...
C
#include <stdio.h> int main() { int n; scanf("%d", &n); printf("fact(%d) = %d \n", n, fact(n)); return 0; } int fact(int i) { if (i == 1) return 1; else return(i*fact(i - 1)); }
C
#include "BeeT_behaviortree.h" #include "BeeT_DBG_behaviortree.h" // Forward delcarations void StartBehavior(BeeT_BehaviorTree*, BeeT_Node*, ObserverFunc); void StopBehavior(BeeT_Node*, NodeStatus); void Update(BeeT_BehaviorTree*); BEET_bool Step(BeeT_BehaviorTree*); BeeT_BehaviorTree* BeeT_BehaviorTree__Init(const B...
C
#include <windows.h> #include <Wincrypt.h> #include "hash.h" #define MD5_LEN 16 #define SHA1_LEN 20 #define SHA256_LEN 32 CHAR g_rgbDigits[] = "0123456789abcdef"; BOOL md5_hash ( BYTE* data, DWORD len, CHAR md5[MD5_HASH_LEN] ) { BOOL retVal = FALSE; HCRYPTPROV hProv = 0; HCRYPTHASH hHa...
C
/* Program to demonstrate how to run machine code from C */ #include<stdio.h> /* 400078: b8 01 00 00 00 mov $0x1,%eax 40007d: bb 02 00 00 00 mov $0x2,%ebx 400082: cd 80 int $0x80 */ char shellcode[] = "\xb8\x01\x00\x00\x00" "\xbb\x02\x00\x00\x00" ...
C
#include <stdio.h> #include "omp.h" #define ITER 10 int main(){ float a; int id=-1,i; printf("hola mundo serial \n"); #pragma omp parallel private(i,id) { id = omp_get_thread_num(); for(i=0;i<ITER; i++) printf("Hola Mundo paralelo %d PID=> %d\n",i,id); } printf("hola mundo serial %d \n",id); return 0;...
C
/* Written by Krzysztof Kowalczyk (http://blog.kowalczyk.info) The author disclaims copyright to this source code. Handling of bencoded format. See: http://www.bittorrent.org/protocol.html or http://en.wikipedia.org/wiki/Bencode or http://wiki.theory.org/BitTorrentSpecification */ #include "base_util.h...
C
#include <stdio.h> #include <stdlib.h> /*Perfect number ȫ*/ /*int main() { int n,i,s=0; printf("жϻDzȫ:"); scanf("%d",&n); for(i=1;i<n;i++) //ע⣺iԵn { if(n%i==0) s=s+i; } if(s==n) printf("Perfect number!\n"); else printf("Not perfect number\n"); ret...
C
#include "time.h" #include <NeoPixelBrightnessBus.h> // instead of NeoPixelBus.h #ifdef __AVR__ #include <avr/power.h> // Required for 16 MHz Adafruit Trinket #endif // Which pin on the Arduino is connected to the NeoPixels? // On a Trinket or Gemma we suggest changing this to 1: #define LED_PIN 4 // How many Neo...
C
// // main.c // 14-二分查找 // // Created by Ne on 2018/11/10. // Copyright © 2018年 Ne. All rights reserved. // #include <stdio.h> #pragma mark --二分查找 int binSearch(int *arr,int low,int high,int find) { int mid; while (low <= high) { mid = (low+high)/2; if (arr[mid] == find) { retu...
C
#include <stdio.h> #include <conio.h> int main() { int i, n, j, num, arr[10]; clrscr(); printf("\n Enter the number of elements in the array : "); scanf("%d", &n); for(i=0;i<n;i++) { printf("\n arr[%d] = ", i); scanf("%d", &arr[i]); } printf("\n Enter the number to be del...
C
/* * assert.h * * Created on: Jan 14, 2015 * Author: wladt */ #ifndef __PFS_BITS_ASSERT_H__ #define __PFS_BITS_ASSERT_H__ #include <pfs/bits/config.h> EXTERN_C_BEGIN void pfs_assert (const char * file, int line, const char * text); void pfs_backtrace (const char * file, int line, const char * text); void...
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
// // Demonstration of some constant expressions. These are required for the // labels on a swtich, and in some other, probably more common places we // haven't learned about yet. // #include <stdio.h> #include <stdbool.h> int main( void ) { int val; printf( "Enter a value: " ); scanf( "%d", &val ); int thr...
C
/** * @file activity3.c * @author KarishmaSavant * @brief PWM assignment as per ADC values read * @version 0.1 * @date 2021-04-29 * * @copyright Copyright (c) 2021 * */ #include <avr/io.h> #include <util/delay.h> //delay function #include "activity3.h" /** * @brief Initialization of PWM ports and registers ...
C
#include <stdio.h> #include "stack.h" int main() { sStack *stack=NULL; int status=0; stack=StackInit(); if(!stack) { printf("初始化栈失败\n"); } status=StackEmpty(stack); if(status) { printf("栈为空\n"); } else { printf("栈不为空\n"); } status=Push(stac...
C
#include <stdio.h> #include "math/AnuraMath.h" int main() { Vec2 v = {5.3, 2.2}; Vec2 w = {1.2, 2.6}; Mat2 m = { v, w }; Mat2 n = { { 1.0, 0.0 }, { 0.0, 1.0 } }; printf("%f\n", Vec2_length(v)); printf("%f\n", Mat2_get_index(&m, 0, 0)); Vec2_print(v); printf("----\...
C
#include "algoritmos_de_planificacion.h" void planificar(){ if(!strcmp(ALGORITMO_PLANIFICACION,"FIFO")){ FIFO(); }else if (!strcmp(ALGORITMO_PLANIFICACION,"RR")){ RR(); }else if (!strcmp(ALGORITMO_PLANIFICACION,"SJF-CD")){ SJF_con_desalojo(); }else if (!strcmp(ALGORITMO_PLANIFICACION,"SJF-SD")){ SJF_sin_...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include "common_types.h" #include "osapi.h" #include "osal-core-test.h" /* OS Constructs */ int TestTasks (void); void InitializeTaskIds (void); void InitializeQIds (void); void InitializeBinIds(void); void InitializeMutIds(void); int TestQueues(void); int...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <errno.h> #define INIT_STACK_SIZE 5 #define STACK_EXTEND_SIZE 5 // typedef struct elemType // { // int data; // char name; // } elemType; typedef int elemType; typedef struct stack { elemType *top; elemType *base; int stackSize; } ...
C
// |oled_driver.c|: Implementation of the OLED Display Drivers // // @author: Joe Gibson // @author: Adam Luckenbaugh #include "oled_driver.h" //Initialize OLED Display Driver void oled_d_init(void) { //Initialize OLED Display RIT128x96x4Init(1000000); } //Print at 0,0 with full brightness void oled...
C
#ifndef NCMLIB_COPY_CMDARG_H_ #define NCMLIB_COPY_CMDARG_H_ #include <stdio.h> #include <stdlib.h> #include "nk/log.h" static inline void copy_cmdarg(char *dest, const char *src, size_t destlen, const char *argname) { ssize_t olen = snprintf(dest, destlen, "%s", src); if (olen <...
C
#include "graph.h" void add_edge(graph* curr_graph, edge* new_edge) { } void edge_swap(edge* a, edge* b) { edge c = *a; *a = *b; *b =c; } int main() { return 0; }
C
//Peter's smoke #include<stdio.h> int main() { int a,n,k; while(scanf("%d %d",&n,&k)==2) { a=n; while(n>=k) { a=a+(n/k); n=(n/k)+(n%k); } printf("%d\n",a); } return 0; }
C
#include "misc.h" #include <stdio.h> #include <string.h> #include <stdlib.h> int main(int argc, char* argv[]) { if(argc > 3) { printf("Usage: [PROGRAM NAME] [FILE NAME] [USE LARGE]\n"); return 0; } else if(argc == 3) { // initialize file name unsigned int fnlen = str...
C
#include <stdlib.h> int reverse(int x) { int digit; int result = 0; int prev_result = 0; while (x != 0) { digit = x % 10; prev_result = result; result = result * 10 + digit; if (((result - digit) / 10) != prev_result) /*overflow*/ return 0; x = x / 10; } return result; }
C
#include "lists.h" /** * add_dnodeint_end - function that adds a new node at the end of a list_t list * @head: input header pointer * @n: input int value * Return: the address of the new element, or NULL if it failed */ dlistint_t *add_dnodeint_end(dlistint_t **head, const int n) { dlistint_t *newNode; dlistin...
C
#include "Stack.h" /* Push data to the stack */ void* push(Stack* stack, void* data) { // Argument validation. if (stack == NULL || data == NULL) return NULL; Node* newNode = initializeNewNode(); newNode->data = data; newNode->next = stack->head; stack->head = newNode; stack->size++; return data; } /* Pop ...
C
/*********************************************************************************** Xinzhan: This header file: 1),defines the shape that used to fit signal, and supply this shape to TMinuit. 2), contains the fcn global function that TMinuit will minimize. **********************************************...
C
#include <stdio.h> #include "myBank.h" #define ROW 50 #define COL 2 #define Close 0 #define Open 1 double Bank_account[ROW][COL] = {0}; void Create_new_account(){ int number_account = 901; int i = 0; while(i < 50){ if(Bank_account[i][0] == Close){ double amount; printf("enter amount: "); ...
C
/*****************************************************************************/ /* Mikko Majamaa */ /*****************/ /* this file contains the code related to reading and handling the data of the name files */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "name_list.h" #define LEN 80 Name *Em...
C
/************************************************************** 1090번 jongtae0509 C 정확한 풀이코드 길이:182 byte(s) 수행 시간:0 ms 메모리 :1120 kb ****************************************************************/ #include<stdio.h> int main() { long long int a,r,n,i; long long int nn; scanf("%lld %lld %lld",&a,&r,&n); nn=n-1; f...
C
/* Sắp xếp chèn : Di chuyển các phần tử có giá trị lớn hơn giá trị key về sau một vị trí so với vị trí ban đầu của nó */ #include<stdio.h> #define MAX 100 void nhap(int a[],int n) { for(int i=0;i<n;i++) { scanf("%d",&a[i]); } } void xuat(int a[],int n) { for(int i=0;i<n;i++) ...
C
#include "tree.h" #include <string.h> #include <stdio.h> #include <stdlib.h> #include "lmalloc.h" struct tnode *newNode(void) { struct tnode *retnode = 0; retnode = (struct tnode *)lmalloc(sizeof(struct tnode)); // Initialize fields: retnode->dtype = NULL_TYPE; retnode->data = NULL; retnode->lson = NULL; ...
C
/* * File: x14-1main.c * Application of the module to operate on polygons * The application expects a text file as input, which contains polygons. The * file is of the form: * degree * coefficient1 coefficient2 ... coefficientN */ #include <assert.h> #include <stdio.h> #include <stdlib.h> #includ...
C
#include "holberton.h" /** * times_table - check the code for Holberton School students. * * Return: Always 0. */ void times_table(void) { int init = 0, i, j, fd, ld; for (i = 0; i <= 9; i++) { for (j = 0; j <= 9; j++) { if (init < 10) { _putchar(init + '0'); } else { fd = init / 10; ...
C
#ifndef MATRIX_METHODS_H_INCLUDED #define MATRIX_METHODS_H_INCLUDED void invert_matrix(double mat[3][3],double M[3][3]); /** *@fn void invert_matrix (double mat[3][3],double M[3][3]); *Invert a 3x3 matrix. *@param[in] mat: The matrix. *@param[in/out] Yb: The inverted matrix. */ void matrix_product(double MG[3][3],doub...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_split.c :+: :+: :+: ...
C
#include "lista_LSE.h" int main(void) { char *vetor_INPUT[] = {"joao do pulo", "pedro bandeira", "anita garibaldi", "maria luiza"}; int Q = 4; system("clear"); printf("\n VETOR %d elementos\n", Q); /** cria um PONTEIRO PARA UMA lista **/ NOH_tipo_LSE * L; L = N...
C
#include <stdio.h> #include <stdlib.h> #include <limits.h> #include <assert.h> #include "dump-bits.h" unsigned get_clear_mask(int p, int n) { return (~(~0 << n)) << p; } /* Exercise 2-6. Write a function setbits(x,p,n.y) that returns x ith the n bits that begin at position p set to the rightmost n bits of y, leavi...
C
#include <stdio.h> #include <stdlib.h> /* array= arreglo de datos ORDENADO. vARIABLE QUE TIENE un conjunto de variables en su interior (ordenadas) definicion int c; | int NOSE[5]; c=28 escribo la variable; | NOSE [3] posicin 4 (porque empieza de cero). Toma el valor que hay ah k=c le...
C
#include <stdio.h> #include <string.h> #include "CuTest.h" #include "../src/hashtable.h" #include "../src/scope.h" void test_create_scope(CuTest *tc) { CuAssertIntEquals(tc, 0, scope_numbers()); scope_new(); CuAssertIntEquals(tc, 1, scope_numbers()); scope_reset(); } void test_reset_should_have_no_s...
C
/*====================================================================* * * void _setbuf(FILE *fp, char *buffer); * * _stdio.h * * assign a special buffer to the file control block addressed by the * FILE pointer argument; if the buffer argument is NULL then assign a * one-byte buffer; * * a custo...
C
#include <obj/obj.h> #include <obj/stb_zlib.h> implement(Data) Data Data_with_bytes(Class cl, uint8 *bytes, uint length) { Data self = auto(Data); self->bytes = bytes; self->length = length; return self; } Data Data_with_size(uint length) { Data self = auto(Data); self->bytes = (uint8 *)mallo...
C
#include <stdio.h> #include <stdlib.h> #include "sins_types.h" #include "sins_const.h" #include "box.h" #include "primitives.h" #include "primitives_utils.h" #include "gc.h" #include "bytefield.h" #include "bytefield_utils.h" char *line = "===============================================================================...
C
#include <stdio.h> #include <stdlib.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int find(int decimal_number,int base) { if (decimal_number == 0) return 0; else return (decimal_number % base + 10 * find(decimal_numbe...
C
#include <stdio.h> int main(void) { long long int s=0,i,n,j; scanf("%lld",&n); long long int arr[n],t; for(i=0;i<n;i++) scanf("%lld ",&arr[i]); for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ if(arr[i]<arr[j]){ t=arr[i]; arr[i]=arr[j]; arr[j]=t;}}} for(i=0;i<n;i++){ s=s*10+arr[i]; } printf("%lld",s); ...
C
#include<stdio.h> #include<math.h> #include<stdlib.h> #define f(x) (1/(1+(x*x))) void trapezoidal(void); void simpson(void); int main() { int c,count=0; float s=0.0,s1=0.0; while(1) { if(count==0){ printf("\t\t\tWelcome to Integrator:"); printf("\n\t\t\tPlease Select from the following methods:");} printf("\n\n \t\t\t\...
C
#include "test.h" #include "matching.h" char *utest_matching_match_offset() { Label l1 = label_full("test"); Label l2 = label_full("abctest"); Label l3 = label_full("te"); Label l4 = label_full("abctestabc"); Matching m0 = match(l1, l2); mu_assert("No offset #1", match_type(m0) == NONE); ...
C
/************************** * Jordan Simmons 10743844 * 3600.001 Group 3 * Reverse *************************/ #include "major1.h" void reverse(unsigned int num) { int temp = num; unsigned int reverse_num = (num & 1); unsigned int count = 31; char binary[32]; printf("\nThe number is: %u\n", num); for (int i...
C
int copia_string(char dest[], char fonte[]) { // Recebe: o endereco da string dest e o endereco da string fonte. // Retorna: a quantidade de caracteres copiados de fonte para dest. int i; for (i = 0; dest[i] != '\0'; i++) { dest[i] = fonte[i]; } return i; }
C
#include <stdio.h> void forEachForString(char *str, void (*f)(char *)); void changeMe(char *character) { int ascii = *character; int diff = 32; if (ascii >= 97) printf("%c\n", *character - diff); else printf("%c\n", *character + diff); } int main() { char *mystr = "asdf"; forEachForStrin...
C
/* $Id: transforms.c,v 1.1 2006/11/22 20:31:50 observe Exp $ */ #ifndef lint static char vcid[] = "$Id: transforms.c,v 1.1 2006/11/22 20:31:50 observe Exp $"; #endif /* lint */ /*********** Coordinate transformation routines *************/ /* All angles assumed to be in radians upon input */ #include "orbfit.h" /*...
C
#include <stdbool.h> #include <stddef.h> #include <stdint.h> typedef struct{ uint16_t* subpalette; uint8_t size; uint8_t order;//définit l'ordre dans la palette finale. Insérer plusieurs sous-palettes avec le même ordre provoquera une erreur. uint8_t offset;//où commence la subpalette dans le tableau }Subpalette;...
C
/* ** EPITECH PROJECT, 2018 ** PSU_2018_malloc ** File description: ** show_alloc_mem.c */ #include "../include/malloc.h" static void my_putstr(char *str) { int len = 0; while (str && str[len]) len++; write(1, str, len); } static void show_pointer(void *ptr) { char *base = "0123456789ABCDEF"...
C
#include<stdio.h> #include<string.h> #define length 1000 int inputs[length]; char file[] = __FILE__; int main() { char *filename = strtok(file, "."); strcat(filename, ".in"); FILE *fin = fopen(filename, "rb"); int x, n = 0; // n equals inputs.size - 1 while(fscanf(fin, "%d", &x) == 1 && x != 0) {...
C
#ifndef _TABLA_H #define _TABLA_H #include <stdbool.h> #include <stdio.h> #include "def.h" typedef FILE *tTabla; void encabezado(void); /* * imprime el titulo del juego * aunque no tenga nada que ver con la tabla, los tads que lo usan importan este tad */ tTabla abrirTabla(void); /* * si existe abre la tabla...
C
// Write a function reverse(s) that reverses the character string s. // Use it to write a program that reverses its input a line at a time. // Revise the main routine of the longest-line program so it will correctly // print the length of arbitrary long input lines, and as much as possible of the text. #include...
C
#include "holberton.h" /** * _prompt - Print prompt ($ ) and call fun for to split a string * @argv: name of program * Return: never returns */ char **_prompt(char **argv) { int bytes_rd = 0, inputcounter = 1; size_t n_bytes = 1024; char *str = NULL, *newstr, **command; signal(SIGINT, sighandler); while (1...
C
#include<stdio.h> #include<string.h> //𰸴󣿣why int main(){ char a[60],b[60],c[60],d[60]; int i,j; int m,day,t; scanf("%s\n%s\n%s\n%s",a,b,c,d); for(i=0;i<strlen(a)&&i<strlen(b);i++){ if((a[i]==b[i])&&a[i]>=65&&a[i]<=90){ m=a[i]; break; } } ...
C
#include "convertions_operations.h" #include<stdio.h> #include<string.h> #include<math.h> long int Bin_to_Dec(long int bin) { int rem,sum=0,i=0; while(bin!=0) { rem=bin%10; bin=bin/10; sum=sum+rem*pow(2,i); i++; } printf("\nEquivalent Decimal Nu...
C
#include<stdio.h> #include<math.h> int main() { int n, a[500], s, g; printf("Enter size of array: "); scanf("%d", &n); printf("Enter numbers: "); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); if (i == 0) { s = a[i]; g = a[i]; } if (a[i] < s) { s = a[i]; } if (a[i] > g) { g = a[i]; } } ...
C
/** 题目意思是给一堆木棍,每个木棍的两个端点都涂上颜色,问能否将这堆木棍彼此相连组成一根大木棍, 相连的条件是:如果两个小木棍有颜色相同的端点,那么可以通过颜色相同的端点将他们连接起来。比如题目给的例子: blue red red violet cyan blue blue magenta magenta cyan 可以这样连起来(blue magenta)(magenta cyan)(cyan blue) (blue red)(red violet)。 不难发现,在最终组成的大木棍中,除了首尾两个端点的颜色的出现次数可能是奇数外,其他任意一种颜色出现的次数必定是偶数,因为中间的每种颜色都是成对出现的。...
C
/* $Id: hanoi_ll.c,v 1.4 2006/02/28 20:57:26 mmr Exp $ <mmr@b1n.org>, 2004-05-31 Hanoi Tower Inocent Implementation */ /* Include */ #include <stdio.h> #include <stdlib.h> #ifdef __APPLE__ #include <OpenGL/gl.h> #include <OpenGL/glu.h> #include <GLUT/glut.h> #else #include <GL/gl.h> #include <GL/glu.h> ...
C
#include <mctop.h> #include <mctop_internal.h> #include <mctop_profiler.h> #include <math.h> const size_t mctop_prof_correction_stdp_limit = 8; static ticks mctop_prof_correction_calc(mctop_prof_t* prof, const size_t num_entries) { dvfs_scale_up(1e6, 0.95, NULL); size_t std_dev_perc_lim = mctop_prof_correction_s...
C
#include "../main.gen.h" //PUBLIC void console_clear(void) // PUBLIC; { printf("\e[;H\e[2J"); } view_size console_size(void) // PUBLIC; { view_size view_size; view_size.width = 0; view_size.height = 0; struct winsize ws; if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) != -1) { view_size.width = ws.ws_col; ...
C
#include "funciones.h" #include <stdio.h> /** \brief sumar dos numeros * \param A variable float a sumar * \param B variable float a sumar * \return total de la suma * */ float suma(float A, float B) { float total; total=A+B; return total; } /** \brief restar dos numeros * \param A variable float a r...
C
/* * Harness based test for the OBC flash memory. * * Tests functionality of writing and reading memory at the byte level, writing to and reading from eeprom, * writing and reading headers and fields from memory sections. * * NOTE: See mem.c notes on flash memory architecture - generally need to do an erase befor...
C
#include <stdlib.h> #include <comp421/hardware.h> #include <comp421/yalnix.h> /** * Forks a child process which then goes and calls Exec() and runs another * process. The parent returns. * * Expected Output: * Will print a starting message, then either parent or child prints. If the * child executes first o...
C
/* * ===================================================================================== * * Filename: Communication.c * * Description: * * Version: 1.0 * Created: 10/10/12 22:51:16 * Revision: none * Compiler: gcc * * Author: (), * Company: ND...
C
#include <stdio.h> #include <stdlib.h> int bill(int units) { int bill, totalbill; if (units < 30) { bill = units*8; } else if (units < 60) { bill = (29*8) + (units-30)*15; } else if (units < 90) { bill = (29*8) + (29*15) + (units-60)*20; ...
C
#include <stdio.h> #include <stdlib.h> #include <signal.h> #include <sys/types.h> #include <unistd.h> int ctrl_c_counter = 0; unsigned int time_passed = 0; void handler_sigint(int signum) { printf("Passaram %u segundos\n", time_passed); ctrl_c_counter++; } void handler_sigquit(int signum) { printf("Cli...
C
#include "../minishell.h" static void ft_dollar_start(int *i, char **str, t_struct *env, int *flag) { int start; int finish; start = 0; finish = 0; if (!(*flag) && (*str)[*i] == '\'') *flag = 1; else if ((*flag) && (*str)[*i] == '\'') *flag = 0; else if (!(*flag) && (*str)[*i] == '$' && !ft_isspace((*str)[...
C
#include <stdio.h> int weight(int n, int w, int t[]){ if (w == 0){ return 1; } if (n == -1){ return 0; } return (weight(n-1,w-t[n],t) || (weight(n-1,w+t[n],t) == 1) || (weight(n-1,w,t) == 1)); return 0; } int main(){ int n,w; scanf("%d %d\n",...
C
/** * @author : Niculescu Mihai Alexandru */ #include "utils.h" /** * implementarea pentru strdup, deoarece functia nu este in standard-ul C */ char *my_strdup(const char *string) { char *duplicat; int i, len = 0; while (string[len] != '\0') { ++len; } duplicat = (char *) malloc((len ...
C
#include<stdio.h> #include<conio.h> #include<string.h> void main() { char a[100],b[100]; int l,t,p=0,k=0,i,j,flag=0,count=0; scanf("%s %s",a,b); l=strlen(a); t=strlen(b); while(p<l) { if(a[p]==b[k]) { count=0; for(i=p,j=0;i<p+t,j<t;i++,j++) { if(a[i]==b[j]) { count++; } } if(count==t) { printf("ye...
C
#include<stdio.h> int main() { int i,j,n; printf("Enter the number : "); scanf("%d",&n); printf("\n"); for(i=n;i>0;i--) { for (j=1;j<=n;j++) { if(j<i) { printf(" "); } else { printf(" |*|"); } } printf("\n"); } return 0; }
C
#ifndef _IBAARD_STRIP_H #define _IBAARD_STRIP_H /** @file * Functions to strip some characters from strings */ #if (defined _WIN32) || (defined _BROKEN_IO) #include <stdio.h> #endif /** Strip \\n from the end of a string * * @param buf the string to strip * @return a pointer to buf */ char *stripn(char *buf); ...
C
#include <stdio.h> #include <stdlib.h> struct node { int info; struct node *link; }; struct node *create(struct node *start); void compare(struct node *start); struct node *addtobeg(struct node *start, int data); struct node *addatend(struct node *start, int data); void compare(struct node *start) { struct node *p...
C
#include<stdio.h> #include<string.h> int main() { char a[10]; int n,i,j,count=o; scanf("%s",s); n=strlen(a); for(i=0;i<=n;i++) { for(j=i+1;j<=n;j++) { ifa[i]=b[i] { count=1; break; } else { continue; } } } if(count==0) { printf("yes...isogram") } else { printf("no"); } return 0; }
C
// code.h Stan Eisenstat (09/23/08) // // Interface to putBits/getBits #include <limits.h> // Write code (#bits = nBits) to standard output. // [Since bits are written as CHAR_BIT-bit characters, any extra bits are // saved, so that final call must be followed by call to flush...
C
#include<stdio.h> int main() { int stack[5], top=-1, value, operation; printf("Enter 1 for push, 2 for pop, 3 to show the top.\n"); printf("-1 venge dite\n"); while(1) { printf("Choice koren: "); scanf("%d", &operation); if(operation ==-1) { printf("Ven...
C
#include "../globals.h" void setup_Boss() { Problem.Periodic[0] = Problem.Periodic[1] = Problem.Periodic[2] = false; Problem.Boxsize[0] = 0.032; //5e16 cm in parsec Problem.Boxsize[1] = 0.032; Problem.Boxsize[2] = 0.032; sprintf ( Problem.Name, "IC_Boss" ); const double rho = 56458.857; // 3...
C
/* Ficheiro: fork.c Autor: João Caldeira / Knuckles / SaucyGoat (which one?) Este programa demonstra algumas operações básicas sobre processos. */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> // para o fork() e o sleep() #include <sys/wait.h> // para o wait() #define MAX_ITER 3 /* RESUMO DO PRO...
C
/* This is free and unencumbered software released into the public domain. */ /** * Compatibility shim for the GNU Multiple Precision Arithmetic Library (GMP). * * @author Arto Bendiken * @see https://drylib.org/xref/gmp.html * @see https://gmplib.org/repo/gmp/file/default/mini-gmp/mini-gmp.h */ #pragma once /...
C
#include <math.h> #include "const.h" //general functions void mdelay(int milli_seconds); int a_gt_b(float a,float b); float max(float a,float b); float k_model(float speed,float throttle,float brake); void sevenseg_simulate(char bcd[8]); float calc_speed(long double time); long double calc_time(float speed); float sm...