language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "hash.h" #include "header.h" //********** Functions *********** int *procCigar(char *cigar, int *cigs){ char *num; int pos=0; cigs[0]=0; num=malloc(20*sizeof(char)); // printf("%s\n", cigar); for(int t=0; t<strlen(cigar...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <arpa/inet.h> #define PORT 4444 const int NUM_INTERFACE = 2; struct control{ char interface[50], alias[50], mode[50]; }; struct lan{ char interface[50], rul...
C
/* Demo code to toggle the Nth bit of given integer */ #include <stdio.h> int main() { //declaration of variable int num,num2; int toggle; char choice; do { unsigned mask = 1 << ((sizeof(int) << 3) - 1); unsigned mask2 = 1 << ((sizeof(int) << 3) - 1); //prompt the user to enter the number printf("Enter...
C
#include "lists.h" /** * add_dnodeint - new node at the beginning * @head: double pointer to head * @n: value * Return: pointer of node */ dlistint_t *add_dnodeint(dlistint_t **head, const int n) { dlistint_t *nNode; dlistint_t *tmp = *head; nNode = malloc(sizeof(dlistint_t)); if (!nNode) { dprintf(2, "Er...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> #define MAX_NUM 51 int arr[MAX_NUM]; int main(int argc, char **argv) { int i, n, sum, avg, total, tests=0; while(scanf("%d", &n)!=EOF && n!=0) { sum = total = 0; for(i=0; i<n; i++) { scanf("%d", arr+i); sum += arr[i]; } avg = sum/n; for(i=0; i<n...
C
//#include <stdio.h> //#include <stdlib.h> //#include <conio.h> //int main(void) //{ // char c; // while (1) // { // c=_getch(); // ʾҪзŵġ̨ϲʾϢ // printf("%c\n",c); // } // system("pause"); // return 0; //}
C
/* ** EPITECH PROJECT, 2019 ** MUL_my_defender_2018 ** File description: ** free_turrets */ #include <SFML/Graphics/CircleShape.h> #include <stdlib.h> #include "my_defender.h" void free_turret(turret_t *turret) { sfSprite_destroy(turret->sprite); sfTexture_destroy(turret->texture); sfCircleShape_destroy(tu...
C
#include <stdio.h> #define SIZE 10 void quicksort(int *a, size_t n); int main() { int i; int a[SIZE] = { 4, 6, 10, 6, 90,8, 1 , 34,77, 40 }; for(i=0; i<SIZE; i++) { printf("%d ", a[i]); } printf("\n"); quicksort(a, SIZE); for(i=0; i<SIZE; i++) { printf("%d ", a[i]); } ...
C
/* C program to find the inverse of a square matrix where the 2D matrix is given as 1D arrar*/ #include <stdio.h> #include <stdlib.h> void cofac(int A[],int i, int j, int tmp[], int n) { int p,q,l,k; p=0; q=0; for(k=0;k<n;k++) { for(l=0;l<n;l++) { if(k!=i && l!=j) { ...
C
#include <stdio.h> #include <string.h> int main(int argc, char **argv) { char input[1024]; // read a line of standard input. use fgets() - use "man fgets" for reference // the "stream" to read from is standard input, 'stdin' // read 1023 characters into 'input'. fgets(input, 1023, stdin); // no...
C
#include <stdio.h> #include <stdlib.h> int main() { int num1; double result; scanf("%d",&num1); result=num1*num1*3.14; printf("%.2lf",result); }
C
#include "binary_trees.h" /** * binary_tree_balance - balance factor * @tree: pointer to root * Return: 0 if tree is NULL, otherwise balance factor */ int binary_tree_balance(const binary_tree_t *tree) { if (tree) return (binary_tree_height(tree->left) - binary_tree_height(tree->right)); return (0); } /** * b...
C
#include "watchdog.h" void set_LED_RED(){ GPIOF->DATA |= LED_RED; } void clear_LED_RED(){ GPIOF->DATA &= ~LED_RED; } void set_LED_GREEN(){ GPIOF->DATA |= LED_GREEN; } void clear_LED_GREEN(){ GPIOF->DATA &= ~LED_GREEN; } void clear_LED(){ GPIOF->DATA &= ~(LED_GREEN | LED_RED); } void delay_miliseconds(unsigne...
C
#include <stdio.h> #include "date.h" void main() { Date *date1 = create_date(12, 10, 2000); print_date(date1); Date *date2 = create_date(14, 8, 2000); print_date(date2); Person *pierrick = create_person("Dossin", "Pierrick", date2); print_person(pierrick); printf("%d %d\n", compare_date(dat...
C
/* Author: Marc Lee (Changhwan) duckid: clee3 Title: CIS415 project2 threadfxn for part2/3 This is my own work. */ #ifndef TFXN_C #define TFXN_C #include "threadfxn.h" void init() { pthread_mutex_init(&plock, NULL); pthread_mutex_init(&slock, NULL); } void* publisher(void* param) { ...
C
#ifndef _DICTIONARY_H_INCLUDE_ #define _DICTIONARY_H_INCLUDE_ #include<stdio.h> typedef struct LinkedListObj* LinkedList; typedef struct NodeObj* Node; Node newNode(int x); LinkedList newLinkedList(void); void freeLinkedList(LinkedList* pS); void addNode(Node N, LinkedList S); void printList(LinkedList S); voi...
C
/* * biblioteca.h * * Created on: 19 de nov de 2018 * Author: amanda.oliveira */ #ifndef BIBLIOTECA_H_ #define BIBLIOTECA_H_ //Macros e constantes #define RANDOMICO rand() //Estruturas e novos tipos struct dados{ int codigo; struct dados *anterior; struct dados *proximo; }; typedef s...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <pthread.h> #include <stdarg.h> #include "rfifo.h" #include "julog.h" int runloop = 0; static rfifo fifo; #define RET_DATA_SIZE 10 #define MAX_CHUNK_NUM 6 static unsigned short frame_no = 0; static unsigned int cid = 0; #define...
C
#include <stdio.h> #include <string.h> #include <unistd.h> #include <sys/wait.h> #include <stdlib.h> static char *sort_location = "AllSorts"; void run(char *file, char *run, char *stat, char *k) { chdir(sort_location); char *args[] = {"make", file, NULL}; if (fork() == 0) { execvp(args[0...
C
#include <stdio.h> //standard input output #include <stddef.h> //the difference of pointer data type ptrdiff_t #include <limits.h> //INT_MIN limits #define MAXLEN 100 #define HELP "Options:\n"\ "1.Copy\n"\ "2.Concatenate\n"\ "3.Compare\n"\ //length of a string int ...
C
#include <stdio.h> #include <stdlib.h> int binom_coeff(int n, int k) { /* if (k == 0) return 1; */ /* if (n == 0) return 0; */ /* return binom_coeff(n-1, k) + binom_coeff(n-1, k-1); */ int D[n+1][k+1]; for (int j = 0; j < k+1; j++) { D[0][j] = 0; } for (int i = 0; i < n+1; i++) { D[i][0] = 1; } for (int ...
C
#include <stdio.h> #include <stdlib.h> int main(int argc, char * argv[]) { printf("The number of args: %d\n", argc); printf("%s\n%s\n", argv[0], argv[1]); printf("As int: %d\n", atoi(argv[2])); return 0; }
C
// challeng simulating loops with goto // it's supposed to look like garbage #include <stdio.h> void print_first_row (int rows); void print_middle_rows (int num_rows); void print_middle_row (int row_num, int num_rows); void print_last_row (int num_rows); void print_char_n_times (char c, int n); int main (void) { ...
C
#include "idobata_meeting.h" #define MESSAGE_BUFSIZE MESG_BUFSIZE+L_USERNAME+6 /* 発言メッセージサイズ */ static char Buffer[MESSAGE_BUFSIZE]; /* パケットの種類=type のパケットを作成する パケットのデータは 内部的なバッファ(Buffer)に作成される */ //各種のパケットを作成する関数 char *create_packet(u_int32_t type, char *message ){ switch(type){ case HELLO: snprintf( Buf...
C
/***************************************************************************//** @file +Nombre del archivo (ej: template.h)+ @brief +Descripcion del archivo+ @author +Nombre del autor (ej: Salvador Allende)+ ******************************************************************************/ #ifndef _...
C
#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <linux/netlink.h> #include <linux/rtnetlink.h> #include <sys/ioctl.h> #include <linux/if.h> #include <errno.h> #define BUFLEN 4096 int if_link_status(const char *if_name) { int fd...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_check_line.c :+: :+: :+: ...
C
/* narnia1 */ #include <stdio.h> int main(){ int (*ret)(); if(getenv("EGG")==NULL){ printf("Give me something to execute at the env-variable EGG\n"); exit(1); } printf("Trying to execute EGG!\n"); ret = getenv("EGG"); ret(); ...
C
#include<stdio.h> #define N 50 int main(void){ int i; char s[N][128]; for(i=0;i<N;i++){ scanf("%s",s[i]); if(s[i]=={"$$$$$"}){ break; } } for(i=0;i<N;i++){ printf("%s",s[i]); } }
C
/* * menu_framework.c * * Created: 27.09.2017 14:05:47 * Author: andrholt */ #include <stdlib.h> #include <string.h> #include <util/delay.h> #include <stddef.h> #include "OLED_driver.h" #include "menu_framework.h" #include "UART_driver.h" #include "game.h" int current_page = 1; menu* display_menu; static menu...
C
#include <ell/ell.h> #include <stdbool.h> #include "adapter.h" typedef struct { const char* name; const char* signature; union { void *value; void **vector; } ref; // This is a pointer to the related property in adapter model } property_t ; static property_t vproperty[] = { { "Address", "s" , { .vector = (vo...
C
#include<stdio.h> int main() { int num,rev=0,rem,t; printf("Enter the number"); scanf("%d",&num); t=num; while(t>0) { rem=t%10; rev=(rev*10)+rem; t=t/10; } if(num==rev) { printf("%d is an palindrom number",num); } else { printf("%d is an Not palindrom number",num); } }
C
#include <u.h> #include <libc.h> #include <thread.h> #include <draw.h> #include <mouse.h> #include "dat.h" #include "fncs.h" Click click[128]; Click *next; int size; enum{ MIN, CIN, ROLL, }; Click* findpoint(Point xy) { int i; for(i=0;i<size;i++) if(ptinrect(xy, click[i].r)) return click+i; return nil; }...
C
/** * @file * @brief POSIX dirent functions on Windows. * @author 王文佑 * @date 2016.06.30 * @copyright ZLib Licence * @see http://www.openfoundry.org/of/projects/2419 */ #ifndef _GEN_WINDIRENT_H_ #define _GEN_WINDIRENT_H_ #ifndef _WIN32 #error This module can be used on Windows only! #endif #i...
C
/* file: es76.c */ /* comando head */ #include <stdio.h> #include <fcntl.h> #include <unistd.h> #include <string.h> #include <stdlib.h> int main(int argc, char **argv) { char c, *filename; int lines = 0, fdin = 0, fdout = 1, i = 0, n = 10; for (i = 1; i < argc - 1; i++) { /* controllo -n X */ if (strcmp(argv[i...
C
#include <stdio.h> #include <stdlib.h> #include "linerseq.h" /* 设计一个算法,将顺序表中的所有元素逆置 */ void swap(ElemType *a, ElemType *b){ ElemType temp = *a; *a = *b; *b = temp; } void reverse(SqList *L){ ElemType *pa = L->elem; ElemType *pa_last = L->elem+L->length-1; while (pa < pa_last) { ...
C
/*Programa para el manejo del Teclado Matricial * Objetivo: Ingresar una clave digital y verificar si es 5050 * Se requiere agregar los archivos "keypad.h" y "keypad.c" * Se requiere agregar los archivos "lcd.h" y "lcd.c" * El PORTC utilizando 6 pines del RC0 al RC5 para el LCD * El PORTB utilizando los 8 pines RB...
C
int gcd(int a,int b){ int temp; if(a<b){/*交换两个数,使大数放在a上*/ temp = a; a = b; b = temp; } while(b! = 0){/*利用辗除法,直到b为0为止*/ temp = a%b; a = b; b = temp; } return a; } // greatest common divisor (GCD) or greatest common factor (GCF) or Highest commo...
C
#include <stdio.h> #include <stdlib.h> struct Queue { int front,rear,size; unsigned capacity; int *arr; } struct Queue* createQueue(unsigned capacity) { struct Queue* queue=(struct Queue*)malloc(sizeof(struct Queue)); queue->capacity=capacity; queue->front=queue->size=0; queue->rear=capacity-1; queue->array=(...
C
#include "ch.h" #include "hal.h" #include <chprintf.h> #include <usbcfg.h> #include <leds.h> #include <main.h> #include <camera/po8030.h> #include <process_image.h> static int target_position = 0; //angular position given in pixels with //mode 0: target found, mode 1: target not found static uint8_t mode = 1; #def...
C
/* 1.Create a function for get on the bus. The number of new passengers should be passed as a parameter. 2.Create a function for getting off the bus. The number of passengers who are getting off should be passed as a parameter. 3.Each time these functions are called, they should print out the current capacity. ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_face_s.c :+: :+: :+: ...
C
#define F_CPU 16000000L #include <avr/io.h> #include <util/delay.h> void SPI_Init() { // making SCK, MOSI, SS' as outptut DDRB |= (1<<DDB2) | (1<<DDB3) | (1<<DDB5); // making MISO as input DDRB &= ~(1<<DDB4); // making SCK, MOSI, as low PORTB &= ~(1<<PORTB3) & ~(1<<PORTB5); // making SS' as...
C
/* * Copyright 2016 Christopher Zell <christopher.zell@camunda.com>. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless re...
C
#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> //ͳƶ1ĸ int Count_Byte1(const int* x) { int count = 0; int tmp = *x; while (tmp) { tmp = tmp & (tmp - 1); count++; } return count; } //вͬλĸ //ͬλ0ͬλ1Ȼͳ1ĸ int Count_Byte(const int* x, const int* y) { int count = 0; int tmp = (*x) ^ (*y); Count_Byte1(&tmp)...
C
#include <stdio.h> #include "timing.c" #include <omp.h> int main(){ int** table = NULL; table = (int **)malloc(sizeof * table * 2000); for(int i = 0; i < 2000; i++){ table[i] = (int *)malloc(sizeof * table[i] * 250000); } for(int i = 0; i < 2000; i++) { for(int j = 0; j < 2...
C
#include<stdio.h> struct student { char id[100], name[100]; double cgpa; }; int main() { struct student s[3]; int i; for(i=0;i<3;i++) { printf("Input ID, Name and Cgpa of student %d: ",i+1); scanf("%s%s%lf",s[i].id, s[i].name, &s[i].cgpa); } printf("\n"); for(i=...
C
#include <stdio.h> int main(void) { int a = 0; printf("%d\n", ++a); int x = 0, y = 0, z = 0; z = x++ + y; printf("%d\n", z); printf("%d\n", x); return 0; }
C
//Accepted #include<stdio.h> int main() { int a,b,ans1,ans2,min; while(scanf("%d %d",&a,&b) && (a!=-1 || b!=-1)) { if(a>b) { ans1=a-b; ans2=b+100-a; } else if(b>a) { ans1=b-a; ans2=a+100-b; } ...
C
#include<stdio.h> #include<string.h> #define maxsize 10 int stack[maxsize],top=-1; void push(char); char pop(); int isempty(); int isfull(); main() { char str[maxsize],rev[maxsize]; int len,i,j,k,r=0; printf("Enter the string : "); scanf("%s",str); len=strlen(str); for(i=0;i<len;i++) push(str[i]); for(j=...
C
#include "main.h" #include "parse.h" //external handlers extern TIM_HandleTypeDef htim2; extern TIM_HandleTypeDef htim4; extern TIM_HandleTypeDef htim8; //it is required to calibrate all current senses at two points uint32_t Parse_Current(uint32_t raw, uint32_t channel, uint32_t active) { uint32_t calculated=0; /...
C
#ifndef _OBJECTA_H #define _OBJECTA_H #include "Token.h" #include "Object.h" #ifndef _EXPRARRAY #define _EXPRARRAY typedef struct _ExprArray ExprArray; extern void delete_ExprArray(void* array); #endif typedef struct _ObjectArray ObjectArray; struct _ObjectArray { Object ** Objects; int size; int...
C
#ifndef LEVELGENERATOR_H #define LEVELGENERATOR_H #include "enemyclass.h" #define MW 1500 //Tile map width #define MH 1500 //Tile map height #define TS 64 //Tile square size #define ROOMSIZE 15 //Width and height of tiles per room (ROOMSIZE x ROOMSIZE) extern int map[MW][MH]; //Defe...
C
#ifndef MAIN_H #define MAIN_H #define _CRT_SECURE_NO_DEPRECATE #include <windows.h> #include <d3d9.h> #include <d3dx9.h> #include <stdio.h> #include <string.h> /////////////// // // /////////////// #define ERR -1 // ó ڵ -1. #define SCREEN_WIDTH 800 // ȭ ũ. #define SCREEN_HEIGHT 600 // ȭ ũ. #d...
C
#include<stdio.h> #include<string.h> int main(){ int l; char S[130]; double ans,temp; int i,j; while(scanf("%d%s", &l, S) != EOF){ ans = 0; for(; l<=strlen(S); l++){ for(i=0; i <= strlen(S)-l; i++){ temp = 0; for(j = i; j < i+l;...
C
#define _POSIX_C_SOURCE 200809L /* get flockfile */ #include <stdio.h> #include <stdarg.h> #include <stdint.h> #include "dmalloc_common.h" int is_logging = 0; void dmalloc_log_protect() { flockfile(stderr); /* prevent output corruption from concurrency */ is_logging = 1; /* prevent output corruption from reent...
C
#include <stdio.h> #define MAXCHAR 1000 int isSpecialChar(char c); int main() { char str[MAXCHAR]; int index = 0; int c; int newIndex = 0; printf("\nFill the str array\n"); while (((c = getchar()) != EOF) && (c != '\n')) { str[index++] = c; } str[index] = '\0'; printf("\nThe entered array: %s\t and index...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* aizen.c :+: :+: :+: ...
C
#ifndef __DISPLAY_H #define __DISPLAY_H /* Video types for mode in which machine is currently running. */ enum video_type { VIDEO_TYPE_NONE = 0x00, VIDEO_TYPE_COLOR = 0x20, VIDEO_TYPE_MONOCHROME = 0x30 }; /* Available VGA colors for a display. */ enum vga_color { VGA_COLOR_BLACK = 0, VGA_COLOR_BLUE = 1, VGA_COL...
C
#include "ds/buffered_string.h" void print_str_with_indexes(String* str) { printf("Indexs for str4: \n"); for (int i = 0; i < str->length; i++) printf("%4d", i); printf("\n"); for (int i = 0; i < str->length; i++) printf("%4c", str->buffer[i]); printf("\n"); for (int i =...
C
#include "queue.h" #include <stdlib.h> int isEmpty(Node *head) { return (head == NULL); } Node *newNode(TREENODE *d, int p) { Node *temp = (Node *)malloc(sizeof(Node)); temp->data = d; temp->priority = p; temp->next = NULL; return temp; } void enqueue(Node **head, TREENODE *d, int p) { ...
C
/* * Módulo: cliente.h * Data: 03/06/2016 * Descricao: ficheiro .h do TAD do cliente * Autores: Miguel Real e Tomas Martins */ #ifndef CLIENTE_H_ #define CLIENTE_H_ typedef struct _cliente * cliente; /*********************************************** criaCliente - Criacao da instancia da estrutura ass...
C
// swapping of two numbers using call by reference #include <stdio.h> void swap_two_no(int* , int*); void main(){ int first,second; printf("Enter the first number ="); scanf("%d",&first); printf("Enter the second number = "); scanf("%d", &second); printf("Before swapping the numbers are : first %d and sec...
C
/* * arrayLength has to be within main; if a function is used we will have only the pointer/array head as reference * O(n) = O(N) */ #include <stdio.h> #include <stdlib.h> #define SIZE 10 void reverse(int *, int); int main(int argc, const char *argv) { int myArray[] = { 0, 1, 2, 3, 4}; int arrayLeng...
C
#include <stdio.h> void ft_swap(int *a, int *b) { int a_temp; a_temp = *a; *a = *b; *b = a_temp; } /* int main() { int a = 5; int b = 10; ft_swap(&a, &b); printf("a = %d\nb = %d\n", a, b); return (0); } */
C
/* fichier : ipc.h * 18/06/2014 * Florian CAULET Johann NOVAK * florian.caulet@utbm.fr johann.novak@utbm.fr * Fichier qui regroupe toutes les constantes (car c'est le fichier que tous les autres header incluent), les variables globales, les structures liées aux ipc, et les prototypes des fonctions du fichier ipc...
C
/* Eloisa Silva de Morais - 1960881 Turma A 20) Um hotel cobra R$ 50,00 reais a diária e mais uma taxa de serviços. A taxa de serviços é de: • 15,30 por dia, se número de diárias <15 • 10,00 por dia, se número de diárias =15 • 8,50 por dia, se número de diárias >15 Faça um programa que lê a quantidade d...
C
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <string.h> #include <conio.h> // for _getche() #include <stdlib.h> // for system(), exit() #include <Windows.h> // for Sleep() #include <time.h> // for time() #define MaxWord 1000 #define MaxWLen 20 #define MaxMLen 50 #define MaxSLen 160 #define Delay...
C
#include "holberton.h" /** * _strlen - Computes length of a string * @s: The string in question * * Return: The length of said string * */ int _strlen(char *s) { int len = 0; while (*s) { len++; s++; } return (len); }
C
#include<stdio.h> #include<stdlib.h> struct twoints{ int a; int b; }; int main(){ struct twoints* p = (struct twoints*) malloc(100*sizeof(struct twoints)); (*(p+2)).a = 6; free(p); int a; a = 5; printf("%d",a); }
C
/* *Created by Deangeli Gomes Neves * * This software may be freely redistributed under the terms * of the MIT license. * */ #ifndef _COMMON_H_ #define _COMMON_H_ #include <stdlib.h> #include <stdio.h> //#include <malloc.h> #include <math.h> #include <string.h> #include <limits.h> #include <time.h> #include <st...
C
#include <semaphore.h> #include <stdio.h> #include <stdlib.h> #include <sys/mman.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #include <wait.h> #include <time.h> #include <string.h> #define CHILDS 2 #define ITERATIONS_TO_TEST 30 #define NUMBER_OF_VALUES 10...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_print_number.c :+: :+: :+: ...
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
/* ** EPITECH PROJECT, 2020 ** B-CPE-200-RUN-2-1-matchstick-yann.joubert ** File description: ** change_map.c */ #include "my.h" #include "matchstick.h" sticks_s *change_map(sticks_s *stick) { int i = my_strlen(stick->map[stick->line]); int compt = 0; for (; stick->map[stick->line][i] != '|'; i--); f...
C
/* ** EPITECH PROJECT, 2019 ** CPE_BSQ_2019 ** File description: ** check_number_first_ligne */ #include "my.h" char *recup_number(char *str); int check_number_first_ligne(char *str) { int y = my_strlen(recup_number(str)); for (int i = 0; str[i] != '\n' && str[i] >= '0' && str[i] <= '9'; i++) if (y == i...
C
#include <stdio.h> #include <stdint.h> #include <unistd.h> #include <string.h> #include <openssl/md5.h> void grant_shell() { printf("Welcome back superuser!\nHere's your shell:\n"); setuid(geteuid()); char *const args[] = {"/bin/sh", NULL}; execv(args[0], args); } uint8_t valid_hash[] = {193, 179, 14...
C
// 顺序结构模拟俄罗斯轮盘赌博 #include <stdio.h> #include <stdlib.h> #include <time.h> #include <stdbool.h> typedef struct line { int No; struct line *next; } line; // 初始化链表 void initLine(line **head, int n); // 输出链表 void display(line *head); int main() { line *head = NULL; srand((int)time(0)); int n, shoot...
C
#include <allegro5/allegro.h> #include "common.h" #ifndef ELEMENT_H #define ELEMENT_H // Element structure typedef struct { ALLEGRO_BITMAP *bitmap; // Alegro bitmap for drawing the element ALLEGRO_COLOR color; // Element color int height; // Element height int width; // Element width int y; // El...
C
#include <stdlib.h> #include <stdio.h> #include "Affiche_Jeu.h" /* -------------------------------------------------------- */ void affiche_quadrillage(Plateau P) { int i; /* NB : En soi on pourrait combiner les deux vu qu'on a forcément ligne = colonne, mais au cas où on change les options */ /* Lignes verticale...
C
#include "helpers.h" #include "../src/base.h" #include "../src/core/region.h" #include "../src/core/growable.h" struct list { int elem; struct list* next; }; static struct list* from_array(struct region* rgn, int* a, size_t n) { struct list* la = NULL; for (size_t i = 0; i < n; i++) { struct l...
C
/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ struct ListNode* removeNthFromEnd(struct ListNode* head, int n) { /*Two pointer*/ if(!head || !n) return head; struct ListNode* dummy = (struct ListNode*)malloc(sizeof(struct ListNode)); du...
C
// // htab_foreach.c // IJC2 // // Created by Radek Pistelak on 24.04.2015. // Copyright (c) 2015 Radek Pistelak. All rights reserved. // // Email: xpiste04@stud.fit.vutbr.cz // Compiler: Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn) // Last modified date: 28.4.2015 // #include <stdint.h...
C
include <stdio.h> int Walk(int altar) { if (altar == 1) return 1; else if (altar == 2) return 2; else return Walk(altar - 1) + Walk(altar - 2); } int main(void) { int n; printf("How many steps(n = ?): "); scanf_s("%d", &n); printf("Totally has %d ways to get on the stairs.", Walk(n)); return 0; } //ques...
C
#include <iostream> #include <utility> #include <tuple> #include <vector> #include <algorithm> const int jobCnt = 10; // Job start times const int startTimes[] = { 2, 3, 1, 4, 3, 2, 6, 7, 8, 9}; // Job end times const int endTimes[] = { 4, 4, 3, 5, 5, 5, 8, 9, 9, 10}; using namespace std; int mai...
C
#include <pthread.h> #include <time.h> #include <string.h> #include <fcntl.h> #include <sys/select.h> #include <stdio.h> #include <stdlib.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <unistd.h> #include <netdb.h> #define nullptr NULL #define BUFFER_SIZE 4096 #define HTTP_VERSION...
C
#include <stdio.h> #include <stdlib.h> int isPrime (long q); int main () { const long multiple = 600851475143; long primeFactor = 1; int i; for (i = 2; i < multiple; i++) { if( multiple % i == 0 && isPrime(i) ) printf ("prime factor : %i\n",i); } /* for (i = 2; i < 25; i++) printf ("%i : %i\n", i, i...
C
//This changes all letters to lowercase and last letters of word to upper case. //Run this like ./a.out "This is a test" --> thiS iS A tesT #include <unistd.h> #define TOLOWER(c) (c | ' ') #define TOUPPER(c) (c & '_') void ft_putchar(char c) { write(1, &c, 1); } int ft_isspace(char str) { if (str ...
C
#include <stdio.h> #include "mixed.h" int main() { sMixedNumber a, b, ans; mixed_set(&a, 0, 13, 24); mixed_set(&b, 0, 17, 24); mixed_print(a); mixed_print(b); mixed_add(&ans, a, b); mixed_print(ans); mixed_sub(&ans, a, b); mixed_print(ans); mixed_set(&a, 9, 9, 10); mix...
C
#pragma once // STRING extern char* iniReadStr(char* Section, char* Key, const char* DefaultString); extern void iniWriteStr(char* Section, char* Key, const char* ValueString); // INT extern int iniReadInt(char* Section, char* Key, int DefaultInt); extern void iniWriteInt(char* Section, char* Key, int Val...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* fil_parse.c :+: :+: :+: ...
C
/* archivo 'aritReal.h' es almacenado en el directorio 'miIncludes' */ /* función que suma dos números. */ float suma(float a, float b); /* función que resta 'b' a 'a' */ float resta(float a, float b); /* función que multiplica dos números */ float multiplica(float a, float b); /*función que divide 'a' por 'b'*/...
C
#include "hongyulib.h" #include "ESF.h" /****************************************************************** * This is a c script for determine the ONSET and ENDSET of each record * * The ONSET is determined by using the stretched_ES_win * * Changes: * the one period window has been changed to be: * [peak_t...
C
#include <stdio.h> #include <unistd.h> #include <signal.h> #include <string.h> /* signal() */ void (*exit_func)(int); void sig_handler01(int signum) { printf("signal() : %d\n", signum); signal(SIGINT, exit_func); // or signal(SIGINT, SIG_DFL); } /* sigaction */ // volatile 키워드 : 읽기/쓰기를 위해 메모리 액세스 필요. static volatil...
C
#include <stdio.h> int main(int argc, char *argv) { int a = 0; int b = 0; //右移后,最低8可以放的下,否则会出错, //换句话说, 必须是连续在一起的8bit数据才是有效的 __asm__ __volatile__( "mov r0, #0x1100 \n" "mov %0, r0 \n" :"=r"(a) : :"r0","r1" ); printf("%#x\n", a); return 0; }
C
/* C89 compatible atomics. Choice of public domain or MIT-0. See license statements at the end of this file. David Reid - mackron@gmail.com */ /* Introduction ============ This library aims to implement an equivalent to the C11 atomics library. It's intended to be used as a way to enable the use of atomics in a mostl...
C
#include <cs50.h> #include <stdio.h> int mult(int n); int main (void) { printf("Dame un numero "); int x = get_int(); printf("Esto es lo que sale %i\n",mult(x)); } int mult(int n) { n = n * n; return n; }
C
# include<cs50.h> # include<stdio.h> # include<string.h> # include<ctype.h> #include<stdlib.h> int main( int argc, string argv[]) { // check input at command line argument if (argc != 2) { printf ("Valid Key is not entered\n"); return 1; } // check key to be positive int key ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_s_specifier.c :+: :+: :+: ...
C
#include "head.h" #include "get_conf_value.c" #ifdef DEBUG #define DBGprint(...) printf(__VA_ARGS__) #else #define DBGprint(...) #endif #define BUFFER_SIZE 1024 #define FILE_SIZE 512 #define INS 3 static pthread_mutex_t mutex[INS + 1] = PTHREAD_MUTEX_INITIALIZER; struct mypara { const char *s; int num; }; int co...