language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include "holberton.h" /** * _strchr - locate character in string * @s: a pointer to the string to search * @c: the character to search for * * Return: If a match is found, return a pointer to it. * Otherwise, return NULL. */ char *_strchr(char *s, char c) { for ( ; *s; ++s) { if (*s == c) return (...
C
#define TIME struct Time #define TIME_GET_SECOND(time) ((time).second) #define TIME_GET_DECISECOND(time) ((time).decisecond) #define TIME_GET_MINUTE(time) ((time).minute) #define TIME_GET_HOUR(time) ((time).hour) #define TIME_SET_SECOND(time, value) ((time).second = (value)) #define TIME_SET_DECISECOND(time, value) ((t...
C
#define _CRT_SECURE_NO_WARNINGS 1 # include <stdio.h> # include<math.h> int main() { for (int i = 1; i<10; i++) { for (int j = 1; j <= i; j++) { int k = i*j; printf("%d*%d=%d ", i, j, k); } printf("\n"); } return 0; }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* exe_cmd.c :+: :+: :+: ...
C
/* * Definitions for a doubly linked list. */ #include "patricia.h" #include <stdlib.h> #ifndef __LIST_H__ #define __LIST_H__ /* List node structure*/ struct list_node { struct list_node *next; struct list_node *prev; patricia_node_t *patricia_node; }; typedef struct list_node list_node_t; /* Functio...
C
/* ==================================================== # Copyright (C)2019 All rights reserved. # # Author : Pandora # Email : pandora@github.com # File Name : linked_table.c # Last Modified : 2019-05-07 19:35 # Describe : # # ====================================================*/ ...
C
#include <stdio.h> #include <math.h> int main (){ int a, b ,c, sum, sum2; printf("Lutfen degerleri girinis : "); scanf("%d %d %d" ,&a,&b,&c); sum = (b*b)*c/(3-a); printf("ilk isleminizin sonucu : %d", sum); sum2 = (c*c*c)- log(b) + (a*a) / b; printf("\nikinci isleminizin sonucu : %d", sum2); re...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #include "gamelib.h" char titolo[] = "FORSENNAIT"; int main() { // inizializza rand time_t t; srand((unsigned) time(&t)); // inizializza automaticamente una scacchiera auto_scacchiera(); // stampa il titolo stampa_titolo(titolo); ...
C
#include "list.h" int Listlenght(const Item* i) { if (ListIsEmpty(i)) { return 0; } Item* tmp = i; int cont = 0; while (!ListIsEmpty(tmp)) { cont++; tmp = ListGetTail(tmp); } ListDelete(tmp); return cont; } /* int main(void) { ElemType e[] = { 2,3,4,5 }; Item* List = ListC...
C
/*Задача 11. Напишете програма, която умножава 2 числа, като използва пойнтер-и. Пойнтер-ите не са страшни. Дефинират се като тип *Х и се използват като *Х. Както променливите, но със * отпред (и 1 наум!). Продължение: Опитайте да умножите 2 променливи от различен тип, използвайки пойнтери.*/ #include <stdio.h> int ma...
C
#include<stdio.h> int main() { while (1) { printf("Enter the number of natural numbers you would like to be summed (0 to exit): "); int n; int r = scanf("%d", &n); if (r == 1) { if (n < 0) { printf("\nError: %d is a non-positive number", n); }...
C
#include<windows.h> #include<stdio.h> #include<conio.h> #include<stdlib.h> #include<string.h> #pragma comment(lib,"winmm.lib") //Ӿ̬ void play();// void sang(int m); void sing(const char* mci); char c ; char cmd[200]; char music[200]="LONOL LONOL LONO OOMMLLONOL LQPPO LONOM MMOTS PPRRQQ QQNPOONO ONOR ...
C
// Copyright(c) 2021 Jounayd Id Salah // Distributed under the MIT License (See accompanying file LICENSE.md file or copy at http://opensource.org/licenses/MIT). #pragma once #include "math/vector/coVec3_f.h" inline coFloatx4 coSquareDistancePointTriangle(const coVec3& p, const coVec3& a, const coVec3& b, const coVec3...
C
#ifndef UNMOUNT_H #define UNMOUNT_H #include "../var/globals.h" #include "../fileManager/manager.h" #include "../fileManager/mpartition.h" void exec_unmount() { if (strlen(values.id) < 0) { printf(ANSI_COLOR_RED "[e] Parámetros incompletos\n" ANSI_COLOR_RESET); return; } char id_i = v...
C
/* File : vector.c Author : Richard A. O'Keefe Updated: 04/20/99 Purpose: support for library(vector) Copyright (C) 1987, Quintus Computer Systems, Inc. All rights reserved. */ /* We currently support four kinds of vectors: CVECT : character vectors (char*) IVECT : integer vectors (long*) SVEC...
C
/** * @file main.c * @author typeR * @brief * @version 0.1 * @date 2018-11-03 * * @copyright Copyright (c) 2018 * */ /**************************************************************************//** * INCLUDE ****************************************************************************...
C
// https://leetcode.com/problems/wildcard-matching/ bool isMatch(char * s, char * p){ int slen = strlen(s), plen = strlen(p), str = -1, patt = -1, i = 0, j = 0; while(i<slen) { if(j<plen && (p[j] == s[i] || p[j] == '?')) i++,j++; else if(j<plen && p[j] == '*') { str = i; ...
C
#ifndef __GESTION_FICHIER_H__ #include "Arbre_binaire.h" #include "liste.h" #define __GESTION_FICHIER_H__ #define BLOCK_SIZE 4096 // 1 bloc sur disque = 4096 octets typedef struct { FILE* file; // identification du fichier char mode; // lecture 'r' ou criture 'w' unsigned char record[BLOCK_SIZE]; // tampon pour...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> void draw(int number) { int i = 0,j = 0,k = 0,space1 = 0,space2 = 0; for(i = 0;i<number;i++) { if(i == 0){printf("*");} for(j = 0;j<space1;j++) { printf(" "); } if(i != 0){ printf("*");} ...
C
#pragma once #include <stdint.h> #ifdef __cplusplus extern "C" { #endif uint32_t platform_time_ms(); void set_throttle_calibration(uint16_t min, uint16_t max); uint16_t get_throttle_adc(); uint8_t motor_disarm(); //returns armed state void motor_arm(); static inline void utils_step_towards(float *value, float goal...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAXBIT 10 #define MAXVALUE 1000 typedef struct{ int weight; int parent,left,right; }Hnode,*HTree; typedef char* *HCode; HTree HuffmanTree(int *w,int n){ int m,m1,m2,x1,x2,i,j; HTree ht; Hnode *p; if(n<=1) return NULL; m=2*...
C
// C implementation of fibonacci series #include<stdio.h> int fibonacci(int n) { if (n <= 1) return n; return fibonacci(n-1) + fibonacci(n-2); } int main () { int n = 10; printf("Fibonacci number of %d : %d", n, fibonacci(n)); return 0; }
C
#include <stdio.h> #include <stdlib.h> int main() { int mon_int = 12; int prix = 12000; char mon_char = 'A'; int* p_int = 0; //déclaration du pointeur p_int = &mon_int; //assignation de mon pointeur à p_int //représentation en décimale, mais on utilise plutot l'Hexadicimale pour représenter l'adresse pri...
C
/** Afisarea matricei de sudoku (in consola) **/ int show_matrix (int **matrix) { int i,j,k; for (i=0; i<9; i++) //parcurge linia { for (k=0; k<9; k++) // parcurgere pentru afisarea conturului { if (k<8) printf("----"); else printf("-----"); // if-ul a fost...
C
#include <string.h> #include <stdio.h> #include <stdlib.h> #define size_alocar 100 char *remove_spaces_initals(char *str); char *remove_space_final(char *str); char *remove_spaces_both_sides(char *str); char **split_string2(char *original, char *pattern); char *spliting_string(char *ptr, char *pattern, int length_pat...
C
#include<stdio.h> #include<stdlib.h> int main(void) { float a, b,BMI; printf("enter your height in meter and weight in kilogram\n"); scanf_s("%f %f", &a, &b); BMI = b / (a*a); printf("your BMI is %f\n", BMI); if (BMI < 18.5) { printf("Underweight"); } if (BMI >= 18.5&& BMI<24.9) { printf...
C
#ifndef _MESSAGEFORMAT_H_ #define _MESSAGEFORMAT_H_ #pragma pack(4) enum CMD { CMD_REGISTER, CMD_REGISTER_RESULT, CMD_LOGIN, CMD_LOGIN_RESULT, CMD_LOGOUT, CMD_LOGOUT_RESULT, CMD_CHATMESSAGE, CMD_HEART }; //消息头 struct DataHeader { int dataLength;//数据长度 CMD cmd; //具体是什么消息 }; struct R...
C
#include "holberton.h" /** * _abs - a function that computes the absolute value of an integer. * @n: The number * Return: Return the absolute value of an integer */ int _abs(int n) { int res; if (n < 0) { res = n * -1; } else { res = n; } return (res); }
C
/*** *file: "FirstPart.h" *synopsis: definitions functions for second part of the first lab *author: R. Neshta *written: 01/06/17 *last modified: 01/06/17 ****/ #include"SecondPart.h" /* The argz_create_sep function converts the null-terminated string into an argz vector (returned in argz and argz len) by splitting ...
C
#ifndef FILTER_ #define FILTER_ #define MULT_SCALE 100 //Filter API definition //Filter datatype, holds relevat info about a filter instance properties. f_ stands for filter typedef struct{ unsigned char f_Q; //Amount of past output values taken into account unsigned char f_P; //Amount of past input values taken in...
C
/* SPDX-License-Identifier: GPL-2.0+ */ /* * Copyright (C) 2014 Samsung Electronics * Przemyslaw Marczak <p.marczak@samsung.com> */ #ifndef _ERRNO_H #define _ERRNO_H #include <linux/errno.h> extern int errno; #define __set_errno(val) do { errno = val; } while (0) /** * errno_str() - get description for error nu...
C
#include <stdio.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <unistd.h> #include <memory.h> #include <stdlib.h> int main(int argc, char *argv[]) { char *addr = (argv[1]); int port = atoi(argv[2]); printf("start TCP Client to connect TCP Server: %s:%d ...\n", addr, port...
C
#include <stdio.h> #include <string.h> void delete_number(char *); int main() { int i = 0; char str1[100] = {0}; gets_s(str1,sizeof(str1)); delete_number(str1); return 0; } void delete_number(char *str1) { int i = 0; int j = 0; int number = 0; while(1) { printf(" ڿ ȣ ԷϽÿ : "); scanf("%d", &number);...
C
#include "islem.h" #include <stdio.h> #include <string.h> #include <stdlib.h> #include <jrb.h> #include <jval.h> #include <fields.h> JRB tmpTree; char *tmp; int komut_calistir(char** args,JRB tree){ tmp = malloc(sizeof(char) * 1024); memset(tmp,'\0',1024); if(strcmp(args[0],"add") == 0){ ...
C
#pragma once //Ľ #include"BiTree.h" void createBST(BiTree &T,int a[]) {//a[0]ų initTree(T); BiTree p = T; p->data = a[1]; // for (int i = 2;i <= a[0];i++) { p = T; BiTree s = (BiTree)malloc(sizeof(BiNode)); s->data = a[i]; s->lchild = NULL; s->rchild = NULL; while (p) { if (a[i] <= p->data) { if...
C
#include <unistd.h> #include <fcntl.h> #include <stdlib.h> #include <sys/wait.h> #include <assert.h> #define MAXLINE 80 int main(){ int n, fd[2]; pid_t pid; char line[MAXLINE]; if(pipe(fd)<0) exit(1); if((pid = fork()) <0) exit(2); if(pid>0){ close(fd[0]); write(fd[1], "hello world\n", 12); } else { ...
C
#include<stdio.h> int maximum(int a[5]); int deletion(int b[5],int index); int main() { int a[5],i; for(i=0;i<5;i++) {scanf("%d",&a[i]);} maximum(a); return 0; } int maximum (int a[5]) {int i,index=0,max; max=a[0]; for(i=0;i<5;i++) { if (max<a[i]) { max=a[i]...
C
/* ** EPITECH PROJECT, 2017 ** C_Object ** File description: ** list3.c */ #include <string.h> #include <stdlib.h> #include "cobject.h" #include "private_list.h" #include "list.h" __APPROVED_BY(Alexandre) int *list_front(list_t *this) { if (this->_size == 0) throw_list("list is empty"); return (this->_front->dat...
C
#include "time.h" #include "stdlib.h" #include "stdio.h" #include "math.h" #include "stdbool.h" #include "unistd.h" #include "pthread.h" #define DATA_SET_SIZE 50 typedef struct { int x; int y; int z; int label; } datum; typedef struct { datum* unknownData; datum* myData; int startPoint; int numCPU; } threadI...
C
/* ** EPITECH PROJECT, 2019 ** infinite sub source ** File description: ** source file for the infinite sub */ #include "my.h" #include "infinite.h" #include <stdlib.h> void set_mid(char *result, int to_sub, int max) { for (int k = max; k > 0; k--) { if (result[k] >= '1') { result[k] = result[...
C
#include "ustandard/ustandard_sys.h" #include "ustandard/udevelop.h" #include "ustandard/ump_simple.h" #define MIN_TOTAL (10*1024) #define DETAILS_USE_PERCENT (1) #define LEN_BORDER (4) struct ump_simple_node { size_t offset; size_t size_alloc; size_t size_free; }...
C
//Accepted #include<stdio.h> int main() { unsigned long long int i,sum[50003],x; sum[0]=0; for(i=1;i<=50000;i++) { sum[i]=i*i*i+sum[i-1]; } while(scanf("%llu",&x)!=EOF) { printf("%llu\n",sum[x]); } return 0; }
C
main (argc, argv) char **argv; { register void *p, *sp; int local; extern void *alloca (), *getsp (); printf ("&local = %P (%d)\n", &local, &local); sp = getsp (); printf ("sp antes = %P (%d)\n", sp, sp); if (argv[1]) p = alloca (atoi (argv[1])); else p = alloca (0); sp = getsp (); printf ("sp...
C
/* * knightrider.c * * Created: 03.10.2020 21:34:32 * Author : Michal */ /* Defines -----------------------------------------------------------*/ #define LED_RED1 PC0 #define LED_RED2 PC1 #define LED_RED3 PC2 #define LED_RED4 PC3 #define LED_RED5 PC4 #define BTN PD0 #define BLINK_DELAY 150...
C
/* ** EPITECH PROJECT, 2020 ** main ** File description: ** main */ #include "my.h" void usage(void) { my_putstr("\n =========================================================\n"); my_putstr("| Welcome to my_defender |\n"); my_putstr("| ...
C
#include <stdio.h> /* void turn(int (*p)[4]) { int brr[4][4] = {0,}; int i,j,k; for(j=3;j>=0;j--) { for(i=0;i<4;i++) { for(k=0;k<4;k++) brr[j][i] = arr[i][k]; } } } */ void doChange(int (*arr)[4], int (*brr)[4]) { int i, j; int k = 3; ...
C
#include "protocol.h" #include "ui.h" //ilość wyswietlanych wiadomosci posczegolnego typu int all_msg_num = 0; int priv_msg_num = 0; int room_msg_num = 0; //ilość wyświetatlanych kontaktow danego typu int room_cnt_num = 0; int ppl_cnt_num = 0; //liczba lini mozliwych do zadrukowania i iterator po tablicy z trescia d...
C
#include<stdio.h> int no_main(); void fun(){ // calling function to print no_main(); exit(0); } int no_main() { printf("printing wthout uisng main"); return 0; }
C
/* ļmail.cgi.c 汾v 1.01 ˵ύЧݣ e-mail ߣavatar liu 䣺liuwu@jltx.com ڣ20011111 */ #include <stdio.h> #include <string.h> #include "cgi-lib.h" #include "html-lib.h" #include "string-lib.h" #include "config-lib.h" #define WEBADMIN cgi_val(configs,"WEBADMIN") #define SENDMAIL cgi_val(configs,"SENDMAIL") #define TO cgi...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define SIZE 2001 int main(int argc, char * * argv) { int i=0;//counter for the loop // int ch=0; char oneline[SIZE]; int count=0; int count1=0; // FILE* fptr; for(i=1;i<argc;i++) { if(strcmp(argv[i],"--help")==0) { printf("\...
C
#include <stdio.h> #include "mythreadextra.h" int resource = 1; MySemaphore * s; MySemaphore * t; /* Output: t0 start t1 start t2 start t0 again t1 again t2 again t0 bye */ void t2(void * dummy) { printf("t2 start\n"); MySemaphoreWait(t); printf("t2 access critical section t\n"); MyThreadYield(); My...
C
/** * File: Sensors.c * Author: Sarah Masimore * Last Updated Date: 03/14/2018 * Description: Manages init'ing and updating sensors. */ #include "Simulator.h" /** * Init ports and relevant pins. */ void Sensors_Init(struct car * car); /** * Based on sensor value, determine and update voltage on its pin. ...
C
/* ** EPITECH PROJECT, 2019 ** Visual Studio Live Share (Workspace) ** File description: ** init_mob.c */ #include "entity.h" void set_mob(mob_s *element, sfVector2f pos, sfVector2f(stat), sfColor color) { element->sprite = sfSprite_create(); element->position = pos; element->state = 1; element->rect_...
C
/* MCP4922 - Conversor Digital-Analogico de 12-bits e 2 canais. Autor: Tiago Melo Blog: Microcontrolandos Compilador: MikroC PRO PIC Bibliotecas: Soft_SPI */ //Pinos do MCP4922. sbit SoftSpi_SDI at RB2_bit; sbit SoftSpi_SDO at RB2_bit; sbit SoftSpi_CLK at RB0_bit; sbit MCP4922_CS at RB1_bit; sbit SoftS...
C
#include<stdio.h> void main(void) { int a,b; int x,y,z; printf("a=\n"); scanf("%d",&a); printf("b=\n"); scanf("%d",&b); x=a | b; y=a & b; z=(x & b)+(y | a); printf("x=%d y=%d z=%d\n",x,y,z); }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> int matrix[0x400][0x400]; //store the path int ans[0x400];//store answer int queue[0x400]; int head,curr,flag; void toZero() { flag = 0; head = 0; curr = 0; memset(ans,0,sizeof(ans)); memset(queue,0,sizeof(queue)); memset(matrix,0,sizeof...
C
#include <curses.h> #include <unistd.h> #include <stdlib.h> #include <stdbool.h> #include "fire-engine.h" #include "fire-renderer.h" #include "fire-palette.h" static int useCustomColours; static int *pixelPalette = NULL; static int paletteSize = 0; static void init_colours(); static void init_custom_colours(); int p...
C
#pragma once #include "vector.h" struct Ray { Vector3 origin; Vector3 direction; Vector3 get_point(float t) const { return origin + direction * t; } bool operator==(const Ray& other) const { return origin == other.origin && direction == other.direction; } bool operator!=(c...
C
/* * crc32.c - calculate crc32 checksums of data * * Written in 2020 by Ayman El Didi * * To the extent possible under law, the author(s) have dedicated all * domain worldwide. This software is distributed without any warranty. * * You should have received a copy of the CC0 Public Domain Dedicati...
C
#include <stdio.h> int my_strlen (char *s); int main (int argc, char const *argv[]) { char str[1000]; scanf("%s", str); printf("%d\n", my_strlen(str)); return 0; } int my_strlen (char *s) { int i = 0; while(s[i] != '\0') i++; return i; }
C
#include "vm/page.h" #include "threads/vaddr.h" unsigned hash_key_func (const struct hash_elem *e, void *aux UNUSED){ const struct spte* spte = hash_entry(e,struct spte,elem); // return hash_bytes (&spte->upage, sizeof spte->upage); return hash_int(spte->upage); } bool hash_less_key_func (const struct h...
C
#include "server.h" #include <termios.h> /* Extern Definitions */ int socket_count = 0; struct pollfd socket_fds[MAX_SOCKETS]; table_entry_t *active_users[MAX_ROOMS] = {NULL}; short spam_message_count[MAX_SOCKETS]; //Spam message counters for each client short spam_timeout[MAX_SOCKETS]; //Spam timeout for e...
C
#include "genotype.h" #include "population.h" #include "random.h" #include <webots/supervisor.h> #include <webots/robot.h> #include <webots/emitter.h> #include <webots/display.h> #include <webots/keyboard.h> #include <webots/differential_wheels.h> #include <webots/distance_sensor.h> #include <webots/receiver.h> #incl...
C
// Write a method to replace all spaces in a string with '%20'. You may assume // that the string has sufficient space at the end of the string to hold // additional characters, and that you are given the length of the string. #include "4.h" void replace_space(char* s, int n){ int i = 0, count = -1, A[n]; ch...
C
#include "stdio.h" typedef struct { int data[50];//Ϊ int top; }seqstack; //ջijʼ void initstack(seqstack *s) { s->top=-1; } //жջǷΪ int empty(seqstack *s) { if(s->top==-1) return 1; else return 0; } //ջ void push(seqstack *s,int x) { if(s->top==49)//ջ±Ϊ0-49 printf("overflow!\n"); else { s->top++; s->d...
C
#include "pub.h" void init_memory_list(struct list *list_head) { int index; pData init_node; for(index=0; index<10; index++){ init_node = calloc(1, sizeof(sData)); init_node->size = 10; init_node->start_add = calloc(1, 10); init_node->end_add = init_node->start_add + 9; list_add_tail(list_head, &init_nod...
C
#include <stdio.h> float average(int a , int b){ float avg =(a+b)/2; return avg; } void getGrades(){ int grade1=0; printf("Enter your 1st grade: "); scanf("%d",&grade1); int grade2=0; printf("Enter your 2nd grade: "); scanf("%d",&grade2); printf("Your 1st grade: %d/100 \n", grade1); printf("Your 2nd grade: %d/100...
C
#include "miniasm.h" #define OP1(a) ((a & 0xff00) >> 8) #define OP2(a) ((a & 0xff0000) >>16) #define OP3(a) ((a & 0xff000000) >>24) #define REG(a) ctx->r[a].value #define MEM(a) ctx->heap[a] #define CONV(a) &(ctx->heap[a]) extern bool is_running; void check(uint32_t adr){ if(adr >=8192){ fprintf(stderr,"Invalid a...
C
#include<stdlib.h> #include<stdio.h> #include<omp.h> #define STB_IMAGE_WRITE_IMPLEMENTATION #include"stb_image_write.h" #define STB_IMAGE_IMPLEMENTATION #include"stb_image.h" #define MAX 512 /* **Author: Francisnei Bernardes Lima **Data: 17/11/20 **Projeto de processamento de imagens em paralelo **utilizando OpenMP ...
C
#include <stdio.h> #include <stdlib.h> int main() { int a[10] = {6,3,8,10,16,7,5,2,9,14}; for (int i=0;i<10;i++) { printf("%d ",a[i]); } printf("\n"); int k=10; int H[30]={0}; for (int i=0;i<10;i++) { if ((k-a[i])>=0 && H[k-a[i]]!=0) { printf("...
C
#include <stdio.h> #include <string.h> int main() { char text[50]; scnaf("%s", text); for(int i=0; i<strlen(text); i++){ text[i]=toupper(text[i]); printf("%c", text[i]); } }
C
/************************************************************************* * Compilation: javac Heap.java * Execution: java Heap < input.txt * Dependencies: StdOut.java StdIn.java * Data files: http://algs4.cs.princeton.edu/24pq/tiny.txt * http://algs4.cs.princeton.edu/24pq/words3.txt...
C
#include <stdio.h> int prime(int n); int main() { int count = 0; long int num; printf("Enter the number: "); scanf("%d", &num); for (int i = 1; i <= num; i++) { if (prime(i) == 3) { count++; printf("%d\n", i); } } printf("Total count: %d\n...
C
#include <stdlib.h> #include <string.h> #include <stdint.h> #include "flibs/compiler.h" #include "flibs/fmbuf.h" // mbuf, contain the two pointer: the header and tailer, let's see the basic // use cases: // 1. the mbuf is empty: when the header == tailer // 2. the mbuf is full: when the next location of tailer == hea...
C
#include "local.h" #include "userp_private.h" /* ## Userp Diagnostics ### Synopsis userp_diag d= userp_env_get_last_error(env); if (userp_diag_get_code(d) == USERP_EALLOC) ... else userp_diag_print(d, stderr); ### Description libuserp reports errors, warnings, and debug information via the ...
C
#include <stdint.h> #include <stdio.h> #include "platform.h" #include "writeUint64AsText.h" static char * uint64ToBasicText( uint_fast64_t a, char *p ) { int started; static const uint_fast64_t largeDecimalDivisors[11] = { UINT64_C( 10000000000000000000 ), UINT64_C( 1000000000000000000 ), ...
C
#include "AsmSem.h" int sem_create(int* sem, int start_val){ int output; asm("movl %2, %%eax\n" "xchgl %%eax, (%1)\n" "movl %%eax, %0" : "=r" (output) : "r" (sem), "r"(start_val) : "%eax"); return 0; } int sem_wait(int* sem){ int output; asm("1:\n" "...
C
/******************************************************************************* * @file ds3231.c * @author lcc * @version 1.0 * @date 13-Jun-2019 * @brief 封装 DS3231 时钟模块操作函数 *******************************************************************************/ /* Includes -----------------------------...
C
#include "func_2d.h" #include "mersenne_twister.h" #include <math.h> #include <stdio.h> int main(void) { const int seed = 12345; double x[2] = { -15.0, 3.0 }; const double dx = 0.1; const int n = 10000; const double tinit = 10; const double tfinal = 0.01; /* set seed of Mersenne-Twister p...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_drawcolle.c :+: :+: :+: ...
C
//Author: Michael Harrison //Lab 4: Filesystem Structures #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <math.h> //Size of... #define FS_SIZE 0xa00000 //10MB filesystem #define B_SIZE 512 //block size in bytes #define MF_SIZE 16384 //max file size in bytes #define NUM_INOD...
C
/* problem: 10115 - Automatic Editing */ #include <stdio.h> #include <string.h> #define Local 0 #define Len1 100 #define Len2 300 int testCases; char a[10][Len1]; char b[10][Len1]; char c1[Len2],c2[Len2]; void process(char *a, char *b){ char *p = c1; char *q = NULL; #if Local printf("a:%s - b:%s\n",a,b); #en...
C
#include<stdio.h> int pw(int b,int e){ if(e==0) return 1; return b*pw(b,e-1); } int main() { int b,e,p; scanf("%d",&b); scanf("%d",&e); printf("%d",pw(b,e)); return 0; }
C
/* * "Write a program that asks the user to enter a value for x and then * displays the value of the following polynomial: 3x^5+2x^4-5x^3-x^2+7x-6" */ #include <stdio.h> // This function only handles positive powers. But, since it is only used // with positive powers, it is sufficient. int intpow(int base, int exp...
C
#define e 2.71828 double Exp(int x) { double sum=1; int i=0; for(i=0;i<x;i++) sum*=e; return sum; } double Pow(double x,int y) { double sum=1; int i=0; for(i=0;i<y;i++) sum*=x; return sum; }
C
#include "test_runner.h" unsigned short int swap_bytes(unsigned short i) { return i << 8 | i >> 8; } int swap_bytes_test(void) { _assert(swap_bytes(0x1234) == 0x3412); _assert(swap_bytes(0xFF00) == 0x00FF); return 0; } int all_tests(void) { _run(swap_bytes_test); return 0; }
C
//#include <stdio.h> // //int main() //{ // int year; // printf("请输入一个年份:"); // scanf("%d", &year); // // if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) { // printf("闰年\n"); // } else { // printf("平年\n"); // } // // //从键盘输入一个年份和月份值 输出该年该月的天数 // int year1; // ...
C
int main() { int s,x,i,j,n,a1,a2,b1,b2; a1=0;a2=0;b1=0;b2=0; scanf("%d",&n); for (i=1;i<(n+1);i++) { for (j=1;j<(n+1);j++) { scanf("%d",&x); if ((x==0) && (a1==0)) {a1=i;a2=j;} if (x==0) {b1=i;b2=j;} } } s=(b1-a1-1)*(b2-a2-1); printf("%d\n",s); return 0; }
C
#include "Vec.h" #include <iostream> #include <iomanip> #include <cmath> using namespace std; Vec::Vec(int n, double val) : N(n), entries(new double[n]) { for (int i = 0; i < n; ++i) entries[i] = val; #ifdef DEBUG cout << __PRETTY_FUNCTION__ << endl; #endif } Vec::Vec(int n, double* pval) : N(n), entries(new ...
C
/* * Hash table operations * This hash table is an implementation of the Map ADT * (The distinction between a Map and a Dictionary is that the keys * in a Map form a Set - are unique, while in a Dictionary form * a Collection - the same key can appear multiple times) * There are additional methods to: * ad...
C
#include <stdio.h> int main() { int t1=0,t2=1,next; int n,i; scanf("%d",&n); next=t1+t2; printf("The Fibonacci Series %d %d", t1, t2); for(i=3;i<=n;i++) { printf(" %d",next); t1=t2; t2=next; next=t1+t2; } return 0; }
C
// Temp.c // 1. Include section #include "Temp.h" // 2. Variable declaration section uint32_t ui32_ADC0_vector; // Sample buffer (size = number of samples) static float f_TempCelsius; // Temperature variable static uint32_t ui32_temp_intpart; // Integer part of temperature static uint32_t ui32_temp_decpart...
C
#include "stack.h" struct stack{ element_type *a; size_t capacity; position base; position top; }; stack make_stack(size_t size) { stack p = (stack) malloc (sizeof(struct stack)); if(p == NULL) return (stack) p; element_type* tmp = (element_type*) malloc (size * sizeof(element_type)); if(tmp == NU...
C
#include <stdio.h> #include <stdlib.h> //find the smallest multiple //The lowest common multiple int gcd(int m , int n) { int t; while(n != 0){ t = n; n = m % n; m = t; } return m; } int main(int argc, char** argv) { int n; if(argc == 1) n = 20; else n = atoi(argv[1]); long long ans = 1;...
C
/* libppm1.c - ppm utility library part 1 ** ** Copyright (C) 1989 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copy...
C
#include <stdio.h> unsigned char f(float a) { return a; } int main(void) { printf("return value : %d\n",f(128.5)); return 0; }
C
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // INSTITUTO POLITCNICO DO CVADO E DO AVE // 2016/2017 // ENGENHARIA DE SISTEMAS INFORMTICOS // VISO POR COMPUTADOR // CDIGO AULAS // //++++++++++++++++++++++++++++...
C
/* * This file is part of the libemb project. * * Copyright (C) 2011 Stefan Wendler <sw@kaltpost.de> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or ...
C
#include<stdio.h> int main() { int c,t,b,n; t=b=n=0; while((c=getchar())!=EOF) { if(c=='\t') { t++; } else if(c=='\n') { n++; } else if(c==' ') { b++; } //putchar(c); printf("Blank = %d,Tab = %d,Newline = %d",b,t,n); } return 0; }
C
// // circle_list.c // struct_combine // // Created by 暴走的小钢镚儿 on 2018/3/21. // Copyright © 2018年 暴走的小钢镚儿. All rights reserved. // #include "circle_list.h" static int circle_list_count=0; circle_list_pnode circle_list_creat1(circle_list_pnode head) //尾插法创建链表,头结点为空 { circle_list_pnode p,q; p=head; w...