language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
/* * * File: valen /players/valen/area/catacombs/rooms/dungeonc2.c * * Function: room * * Author(s): valen@Nirvana * * Copyright: Copyrigh...
C
#include <stdio.h> int x; int sqr(int x){ int res = x * x; return res; } int main(){ x = 10; printf("%d\n", sqr(x)); return 0; }
C
#include<stdio.h> void main(){ int a[10]={23,43,1,6,2,44,3445,23,54,6}; int i,j; int x; for(i=1;i<10;i++){ j=i-1; x=a[i]; while(j>=0 && a[j]>x){ a[j+1]=a[j]; j=j-1; a[j+1]=x; } } for(i=0;i<10;i++){ printf("%d\n",a[i]); } }
C
#include "q1.h" #include <errno.h> /* Errors */ #include <stdio.h> /* Input/Output */ #include <stdlib.h> /* General Utilities */ #include <fcntl.h> #include <string.h> //#include <unistd.h> /* Symbolic Constants */ //#include <sys/types.h> /* Primitive System Data Types */ //#include <sys/wait.h> ...
C
#include <ESP8266WiFi.h> #include "secret.h" WiFiClient client; int joinAP(int retry){ char ipaddr[20]; IPAddress ip; logline(0, 1, "Connecting"); WiFi.mode(WIFI_STA); WiFi.begin(MYSSID, MYPASSWD); while ( ( WiFi.status() != WL_CONNECTED ) && ((retry--) > 0) ) { delay(500); Serial.print("."); ...
C
#include <stdio.h> #include <stdlib.h> struct array_stack{ int top,capacity; int *arr; }; struct array_stack* create_stack(int cap){ struct array_stack *stack; stack=(struct array_stack*)malloc(sizeof(struct array_stack)); stack->capacity=cap; stack->top=-1; stack->arr=(int*)mallo...
C
#include <stdio.h> /** * main- Aprogram that prints the alphabet *in lowercase, followed by a new line. * Return: 0 **/ int main(void) { int i = 97; for (i = 97; i <= 122; ++i) { if (i != 101 && i != 113) { putchar(i); } } putchar('\n'); return (0); }
C
#include<stdio.h> void inverte_string(char *v); int main(){ char v[100]; printf("Digite uma string: "); scanf("%[^\n]", v); printf("Inversa da string: "); inverte_string(v); return 0; } void inverte_string(char *v){ if(*v){ inverte_string(v+1); } else { return; } printf...
C
#include"apue.h" #include<dirent.h> #include<limits.h> typedef int Myfunc(const char*, const struct stat*, int); static Myfunc myfunc; static int myftw(char*, Myfunc*); static int dopath(Myfunc*); static long nreg, ndir, nblk, nchr, nfifo, nslink, nsock, ntot; int main(int argc, char* argv[]) { int ret; i...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "LinkedList.h" #include "Employee.h" /** \brief Parsea los datos los datos de los empleados desde el archivo data.csv (modo texto). * * \param path char* * \param pArrayListEmployee LinkedList* * \return int * */ int parser_EmployeeFromTex...
C
#include <stdio.h> #include <stdlib.h> #include <errno.h> #include <sys/types.h> #include <mqueue.h> #include <fcntl.h> #include <sys/stat.h> #include <unistd.h> #include <signal.h> #include <string.h> #include <time.h> #include "chat.h" mqd_t serverQueue; int lastClientIndex = 0; mqd_t clientsQueues[MAX_CLIENTS]; int...
C
#pragma once #include "Utils.h" struct Timer { LARGE_INTEGER freq; LARGE_INTEGER startTicks; Timer() { QueryPerformanceFrequency(&freq); } void start() { QueryPerformanceCounter(&startTicks); } int64 getElapsedTime() { LARGE_INTEGER stopTicks; QueryPerformanceCounter(&stopTicks); LARGE_INTEGER ela...
C
// // Created by Daria Miklashevskaya on 31/10/2018. // #include <stdio.h> #include <sys/mman.h> #include <sys/stat.h> #include <fcntl.h> #include <string.h> #include <unistd.h> #include <stdlib.h> int main(){ char * addr; int fd; //file descriptor off_t size; struct stat s; fd = open("ex1.txt"...
C
#include<stdio.h> #include<assert.h> #define MAX(a,b) (a>b ? a : b) #define MIN(a,b) (a>b ? b :a) float median(int *arr, int size){ if(size & 0x01) return arr[size>>1]; return (arr[size>>1]+arr[(size>>1)-1])/2.0f; } float find_median(int *arr1, int *arr2, int size){ if(size <= 0) return -1; if(size == ...
C
#pragma once #include "Public.h" void Partition(int arr[], int start, int end) { if(start < end) { int l = start, r = end; int pivot = arr[l+(r-l)/2]; while(l <= r) { while(l <= r && arr[r] > pivot) { r--; } while(l <= r && arr[r] < pivot...
C
#ifndef NODE_H #define NODE_H #include <stdio.h> #include <stdlib.h> #include "node.h" typedef enum types {TYPE_STRING, TYPE_INT} l_type; typedef struct lNode { int value; struct lNode * next; struct lNode * prev; } l_node; l_node * newListNode(int value); l_node * addListNode(char * value, l_node * f...
C
#include<stdio.h> int main() { int marks,count,i; int d[15]={58,65,89,78,56,54,52,58,69,96,78,96,67,58,51}; for(marks=50;marks<=100;marks++){ count=0; for(i=0;i<15;i++){ if(d[i]==marks) count++;} printf("Marks:%d\t count:%d\n",marks,count);} }
C
#include <stdio.h> #include <stdlib.h> struct Node { int data; struct Node *next; }*first, *last, *secound; void create(int arr[], int n) { struct Node *temp, *last; int i = 0; first = (struct Node*)malloc(sizeof(struct Node)); first->data = arr[i]; first->next = NULL; last = first; ...
C
#include "tracking.h" u8 trackStatus=0; void tracking_init(void) { GPIO_InitTypeDef GPIO_InitStructure; //PG4 PG8 PG6 GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING; GPIO_InitStructure.GPIO_Pin=GPIO_Pin_4|GPIO_Pin_8|GPIO_Pin_6; GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz; GPIO_Init(G...
C
#ifndef M2_REAL_H #define M2_REAL_H //--------------------------------------------------------------------------- #include "math2d.h" #include <float.h> #define m2Pi 3.1415926535897932f #define m2HalfPi 1.5707963267948966f #define m2TwoPi 6.2831853071795865f #define m2RealMax FLT_MAX #define m2RealMin FLT_MIN #...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> typedef struct contagem { char c; int count; } Item; void intercala(Item *vetor, int l, int meio, int r) { Item *aux = malloc(sizeof(Item) * (r - l + 1)); int a = l, b = meio + 1, c = 0; while (a <= meio && b <= r) { if (vetor[a].count <= ve...
C
#include "reverse.h" int main(int argc, const char** argv){ if(argc != 2){ fprintf(stderr, "Usage: reverse <string>\n"); return 1; } int len = strlen_hs(argv[1]); char str[len+1]; memset(str, 0, len+1); memcpy(str, argv[1], len); reverse_string(str); printf("[%s]\n", str); return 0; }
C
#include<stdio.h> #define dim 20 #define len 200 #include<string.h> typedef struct magasin { char nome[dim]; int quantita; int anno; }reg; main(){ reg registro1[len]; int data[len]; reg scaduti[len]; int i=0; int b,d,c=0; int oggi; char ris[dim],ris1[dim], ris3[dim]; do { printf("\n prodotti da clasific...
C
#include <stdio.h> #include <math.h> #include <stdlib.h> #include <time.h> void automorphicNumbers(void); void randCustom(void); void maxThree(void); void avrPositive(void); void existsOdd(void); void divide(void); void fromSquareToCube(void); void checkmate(void); void exchange(void); //int main(int argc, const char...
C
#include "holberton.h" /** * print_line - function that draws a straight line in the terminal * Description: Function that draws a straight line in the terminal * @n: number of times the character _ us printed * Return: void (successful) */ void print_line(int n) { int i; for (i = n; i > 0; i--) { _putchar...
C
#pragma once #include <stdbool.h> typedef void* thread_t; typedef void ( *thread_fnc_t )( void* ); typedef void* mutex_t; thread_t thread_create( thread_fnc_t callback, void* argument ); bool thread_join( thread_t thr ); mutex_t mutex_create(); void mutex_lock( mutex_t m ); void mutex_unlock( mutex_t m ); ...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <sys/socket.h> #include <sys/types.h> #include <pthread.h> #include <unistd.h> #include <netinet/in.h> #include <arpa/inet.h> #include "list.h" #include "listFd.h" int current_fd; int main(int argc, char **argv) { //Variables for the arguments a...
C
/* ** alias.c for 42sh in C:\Users\gambin_l\42SH\sources\builtins ** ** Made by Gambini Lucas ** Login <Lucas Gambini@epitech.net> ** ** Started on Sun Jun 05 14:04:29 2016 Gambini Lucas ** Last update Mon Jun 6 19:40:28 2016 boris saint-bonnet */ # include "42.h" char *just_concate(char *base, char *add) { ...
C
/* ** EPITECH PROJECT, 2021 ** zappy ** File description: ** main */ static void try_move(world_t *world, player_t *player, int *x, int *y) { switch (player->_o) { case (UP): *x = player->_x; *y = (0 < (player->_y - 1)) ? world->_y - 1 : player->_y - 1; case (DOWN): *x...
C
#include <stdio.h> /* [description] C(1≤C≤50) 정사각형의 수 n (1≤n≤100) 가로에 블럭이 하나의 그룹으로 되어야 한다 print result % 10,000,000 */ #define FOR(i,j) for(i=0; i<(j); ++i) #define FORP(i,j) for(i=1; i<=(j); ++i) #define MAX_BLOCKS (100) #define DIVIDER (10000000) #define debugf // polyomino_count[UP_COUNT][CURRENT_ROW_COUNT] int ...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> main() { char a = '1' ; char a1 = "1" ; int i ; i = atoi(a1) ; printf( "kkkkkkkkkkk : %s ",a1 ) ; printf( "kkkkkkkkkkk : %d ",i ) ; }
C
#include<stdio.h> struct dist { int km; int m; }d1,d2,d3; struct dist add(struct dist a,struct dist b) { struct dist temp; temp.km=a.km+b.km; temp.m=a.m+b.m; while(temp.m>=1000) { temp.km++; ttemp.m-=1000; } return temp; } int main() { scanf("\n%d%d",&d1.km,&d1.m); scanf("\n%...
C
/* ** get_port.c for epitech in /home/chapuis_s/rendu/ ** ** Made by chapui_s ** Login <chapui_s@epitech.eu> ** ** Started on Mon Apr 6 04:15:57 2015 chapui_s ** Last update Thu Apr 16 00:04:03 2015 chapui_s */ #include "server.h" int get_port(t_server *server, int argc, char **argv) { int port; port = DE...
C
#include<stdio.h> #include<conio.h> void main() { int num1,num2,temp; printf("Enter first number"); scanf("%d",&num1); printf("Enter second number"); scanf("%d",&num2); if(num1>num2) { temp=num1; num1=num2; num2=temp; } if((num2%num1)==0) {...
C
#include <stdio.h> int a[100001]; int main(void) { int n, i; while(1) { ReadNewInput: scanf("%d", &n); if(n) { for(i = 1; i <= n; i++) scanf("%d", a + i); for(i = 1; i <= n; i++) if(i != *(a + *(a + i))) { printf("not ambiguous\n"); goto ReadNewInput; } printf("ambiguous\n"...
C
#include "test_helpers.h" #include "interface.h" #include <string.h> #include <stdlib.h> void initGameState(int players, struct gameState* state) { memset(state, 0, sizeof(struct gameState)); state->numPlayers = players; state->numActions = 1; state->numBuys = 1; state->whoseTurn = 0; stat...
C
#include "oled.h" #include "hardi2c1.h" #include "oledfont.h" #include <stdio.h> /* 128*64 128 64Уÿֽڿһе8УܹҪ8ֽ Ŀǰֻ֧16壨ĸ8*1616*16ʽ Ϊ߶16Ļֻʾ4 һʾӢַ16 ֻʾ8 2020-04-05 */ static uint8_t OLED_GRAM[8][128]; //8*8*128 int8_t OLED_WR_data(u8 *dat,uint16_t len,u8 mode) { retu...
C
#include <iot/threadpool.h> #include <iot/iot.h> #include <CUnit.h> #include "scheduler.h" static atomic_uint_fast32_t sum_test; static atomic_uint_fast32_t infinity_test; static atomic_uint_fast32_t sum_work1, sum_work2, sum_work3; static atomic_uint_fast32_t counter; static iot_logger_t *logger = NULL; static void ...
C
/** * Assignment 1 hy345 c shell * * @author csd3319 * @version 0.1 02/03/2018 */ #include "funcs.h" int main() { pid_t bg[10]; pid_t pid; pid_t tpid; int status; char** array; char* command; char* arg1; char* arg2; char* out; char* in; char* ena; char* dyo; char* tria; cha...
C
/* Given a string s, return the longest palindromic substring in s. Time: O(n^2) Space: O(1) */ char* longestPalindrome(char * s){ int pos=0; int lenmax=1; for (int i=0; s[i]!='\0'; i++){ int g=i, d=i; while (g>=0 && s[d]!='\0' && s[g]==s[d]){ g-=1; d+=1; ...
C
// Elabore uma função recursiva que calcule a sequência: // 1 + 1/2 + 1/3 + 1/4 + ... + 1/n // Pablo Cecilio 172050108 #include <stdio.h> float FATORIAL(float s); float SOMA(int n); int main(void) { float n; printf("N= "); scanf("%f", &n); printf("Soma: %.2f\n", SOMA(n)); } float FATORIAL(float ...
C
#include<stdio.h> #include<string.h> int main() { int dia=0; char mesNasci[25]; //Entrada de Dados printf("Enter dia de nascinento: "); scanf("%d", &dia); printf("Enter the Mes Nascimento: "); scanf("%s", &mesNasci); //Teste e condição if(mesNasci == "setembro") { printf("Primavera"); } ...
C
/* ************************************************************************** */ /* LE - / */ /* / */ /* ai.c .:: .:/ . .:: ...
C
/** * @file memmanager.c * * @brief Memory Allocation for C * * @note Mentioned in Memory Allocation in C in Embedded Systems Programming, Aug. 89. * https://www.embedded.com/memory-allocation-in-c/ * * @note Original produced by Programming ARTS (8/18/88) * Programmers: Les Aldrid...
C
#include<stdio.h> void main() { int num1; printf("Check whether a number is negative, positive or zero.\n"); scanf("%d", &num1, printf("\nEnter a number: ")); if(num1 > 0) { printf("\n%d is positive number.\n", num1); } else if(num1 < 0) { printf("\n%d is negative number....
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> #include <assert.h> #define MIN(a,b) ((a)<(b)?(a):(b)) #include "jazlib/common.h" #include "jazlib/gen_hash_reset.h" #define GH_DEBUG #define GEN_HASH_HASH_FUNC hash_djb2 #define GEN_HASH_KEY_CMP strcmp // #define GEN_HASH_KEY_COP...
C
#include "holberton.h" #include <stdio.h> #include <stdlib.h> /** * str_concat - function to concatenated 2 string * @s1: string 1 * @s2: string 2 * Return: string concatenated **/ char *str_concat(char *s1, char *s2) { unsigned int a, b, c, d; char *conc; if (s1 == NULL) { s1 = ""; } if (s2 == NULL) { s2 = ""...
C
#include <func.h> int main(int argc,char* argv[]) { printf("真实用户ID:%d\n真实组ID:%d\n有效用户ID:%d\n有效组ID:%d\n", \ getuid(),getgid(),geteuid(),getegid()); return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #include <unistd.h> #include <sys/stat.h> char memFrobByte (const char current) { return (current ^ 42); } int frobcmp (char const* first, char const* second) { while (1) { //Null bytes need to be skipped but are accepted as va...
C
#include <unistd.h> #include "42sh.h" void pipe_exit(t_tree *tree, t_param *param) { static int exit_value = 1; exit_value = exit_value ? g_last_exit : 0; if (param == tree->param->prev) { g_last_exit = exit_value; exit_value = 1; } } int start_pipe(int pipe_fd[2][2], int *k, t_data *data)...
C
#include <stdio.h> int main(int argc, char const *argv[]) { double data[4] = {5.0,-2.0,2.0,0.0}; data[1] *= 2.0; printf("%lf\n", --data[1]); typedef struct matrix { size_t m; size_t n; double **A; } matrix_t; matrix_t mat_arr[10]; (mat_arr+1)->m = 4; for (size_t i = 0; i < 10; i++) { printf("%lu\n",...
C
#include "dog.h" #include <stdio.h> #include <stdlib.h> int _strlen(char *s); char *_strcpy(char *dest, char *src); /** * new_dog - function that creates a new dog. * @name: name of the dog * @age: age of the dog * @owner: owner of the dog * Return: pointer to the new dog */ dog_t *new_dog(char *name, float age, ...
C
#include <stdio.h> int main(){ int i = 10,j=0; while(i>0){ j+=i; i--; } printf("the sum of first 10 natural numbers is : %d", j); return 0; }
C
/* ** SCCS ID: @(#)cio.h 2.2 3/10/20 ** ** File: cio.h ** ** Author: K. Reek ** ** Contributor: ** ** Based on: c_io.c 1.13 (Ken Reek, Jon Coles, Warren R. Carithers) ** ** Description: Declarations and descriptions of console I/O routines ** ** These routines provide a rudimentary capability for printing to ** the scr...
C
/* 二叉搜索树 */ /* 1、二叉搜索树的查找操作Find(尾递归法) */ Position Find(ElementType X,BinTree BST){ if(!BST){ return NULL; //查找失败 } if(X>BST->Data){ return Find(X,BST->Right); //在右子树中继续查找 } else if(X<BST->Data){ return Find(X,BST->Left); //在左子树中继续查找 else ...
C
/** \brief mostrar menu * * \param [] char recibe un mensaje * \return int retorna una opcion * */ int menu(char []); /** \brief pide el ingreso de un dato. * * \param [] char recibe un mensaje para mostrar * \param [] char recibe un dato para guardar * \return void sin nada a retornar * */ v...
C
// 17 june 2014 #include "simplesale.h" #include <sqlite3.h> #include "dbschema.h" // files: // - accounts: [ { "name": name, "password": [ bytes ] }, ... ] // - items: name\nprice\nname\nprice\n... // - orders: concatenation of { "time": unixtime, "customer": customerName, "amountPaid": price, "items": items } #defi...
C
/****************************************************************************** * Project: hpsdr * * File: buffer.h * * Description: implement a simple buffer pool manager to avoid allocs/deallocs * during operations. Alos used to minimize blocking IO time for USB * * Date: Mon 25 Feb 2013 * * $Revision:$...
C
// converts RGB file to GIF (prints it to stdout) // #include <stdio.h> #include <stdlib.h> #include <gif_lib.h> static void rgb_to_gif(const char *filename, int width, int height) { FILE *in = fopen(filename, "r"); if (!in) { fprintf(stderr, "Error: could not open %s\n", filename); exit(1); ...
C
#ifndef VideoModule_h #define VideoModule_h #include <stdint.h> #include "ClockFont.h" typedef struct { uint8_t Red; uint8_t Green; uint8_t Blue; } Colour; /*Given an array containing a certain time and a colour(using the colour structure), it shows on screen a digital real time clock, by using calls to...
C
#include "S32K144.h" /* include peripheral declarations S32K144 */ void delay (void) { unsigned long i=1000000; do{}while (--i); } int main(void) { //Activate clock PCC register description PCC_PORTD Chapter 29 page 633 PCC->PCCn[PCC_PORTD_INDEX]=0x40000000; //Select port ( // Mux) PORT_PCR Chapter 12 PORT_PCR...
C
#include<stdio.h> void main(){ int arr[10],n,position,value; printf("enter the no. of elements of the array: "); scanf("%d",&n); for (int i = 0; i < n; i++) { printf("\nenter the %d element of array\n",i+1); scanf("%d",&arr[i]); } printf("enter the value and...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include "UDPCookie.h" #define ERRLEN 128 int isNotEqual(int x, int y) { return !!(x^y); } int main(int argc, char *argv[]) { int msgLen = 0; if (argc != 2) // Test for correct number of...
C
#define GL_SILENCE_DEPRECATION #include <GLUT/glut.h> #include <unistd.h> #include <stdlib.h> #include <string.h> static const GLint windowWidth = 640; static const GLint windowHeight = 640; static const GLfloat windowRatio = (float)windowWidth / windowHeight; static const GLint leftCorner = -windowWidth / 2; static...
C
#include <stdio.h> int in_word(int n); int main(){ int n; scanf("%d",&n); in_word(n); return 0; } int in_word(int n) { int rem,quo; rem=n%10; quo=n/10; if(n==0) return 0; in_word(quo); switch (rem) { case 1: printf(" one "); ...
C
/* ** EPITECH PROJECT, 2018 ** attacks_arrow ** File description: ** arrow attacks */ #include "rpg.h" void punch_arrow(window_t *win, game_t game, menus_t **menus) { size_t inc = 0; timef_t time = init_time(); game.charac2.rect.top = 113; game.charac2.rect.left = 910; game.charac2.rect.width += 30; game.chara...
C
#include <stdio.h> int main(){ int array[100], maximum, size, c; printf("Enter the number of elements in array: "); scanf("%d", &size); printf("Enter %d integers:\n", size); for (c = 0; c < size; c++){ scanf("%d", &array[c]); } maximum = array[0]; for (c = 1; c < size; c++){ i...
C
#include <stdio.h> #include <sys/mman.h> #include <seccomp.h> int get_file_size(FILE *fp) { fseek(fp, 0L, SEEK_END); int sz = ftell(fp); fseek(fp, 0L, SEEK_SET); return sz; } void init_syscall_filter() { // allow only four syscalls: open, read, write and exit // the process is killed on execution of any other ...
C
void main(){ int i; for(i=0;i<5;i+=1){ print i; } }
C
#include <stdlib.h> #include <stdio.h> int main() { char data = "01/06/2015"; int iDia; int iMes; int iAno; char sDia[3]; char sMes[3]; char sAno[5]; int i; for (i = 0; data[i] != '/'; i++){ sDia[i] = data[i]; if (i > 1) return 0; //NO MAXIMO 2 NU...
C
/* ***************************************************************************** * freqmeasure.c * See atmegaclib2.h header for the copyrights... * ***************************************************************************** */ #ifndef F_CPU #define F_CPU 16000000UL //required by Atmel Studio 6 #endif #include <av...
C
#ifndef STACK_H_INCLUDED #define STACK_H_INCLUDED #define STACK_SIZE 100 int TOP=-1; int STACK[STACK_SIZE]; int PUSH(int element) { if(TOP==STACK_SIZE-1) { printf("OVERFLOW"); return -1; } else{ STACK[++TOP]= element; return 1; } } int PEEK() { return STACK[T...
C
#pragma once #include "Lights/Light.h" struct PointLight : public Light { Vector position; Color Lout; PointLight() : position(Vector(0.0f, 0.0f, 0.0f)), Lout(Color(0.0f, 0.0f, 0.0f)){}; virtual ~PointLight(){}; PointLight(Vector position_init, Color Lout_init) : position(position_init), Lout(L...
C
# include <stdio.h> int main() { int a,b,quatient,remainder; printf("Finding quatient and remainder"); scanf("%d %d", &a,&b); quatient = a / b; remainder = a % b; printf("%d %d\n", quatient,remainder); return 0; }
C
#include <stdio.h> #include <stdlib.h> int main(void) { int i; char s[2]; s[0] = '$'; s[1] = '3'; i = atoi(s); printf("%d\n", i); return (0); }
C
//分三步走,1.复制next节点放在原链表后面2.复制随机节点,按照原链表的顺序3.把两个链表分开 RandomListNode* Clone(RandomListNode* pHead) { //1 RandomListNode* currentNode = pHead; while(currentNode) { RandomListNode *node = new RandomListNode(currentNode->label); node->next = currentNode->next; cur...
C
#include<stdio.h> #include<conio.h> void main() { int i; char c[6] = "hello\0" ; clrscr(); printf("%s\n",c); /* method 1*/ for(i=0; i<=5; i++) { printf("%c",c[i]); } /*method 2 */ for(i=0; i<=5; i++) { printf("%c",i[c]); } /*method 3*/ for(i=0; i<=5; i++) { printf("%c",*(c+i)...
C
#include <stdio.h> #include <unistd.h> __attribute__((constructor)) void setup(void) { setbuf(stdin, NULL); setbuf(stdout, NULL); } int main() { char buf[0x20]; read(0, buf, 0x100); puts("Bye!"); return 0; }
C
// 程序填空,不要改变与输入输出有关的语句。 // 输入一个正整数 repeat (0<repeat<10),做 repeat 次下列运算: // 将一笔零钱(大于8分,小于1元, 精确到分)换成5分、2分和1分的硬币。 // 输入金额,问有几种换法?针对每一种换法,每种硬币至少有一枚,请输出各种面额硬币的数量和硬币的总数量。 // 要求:硬币面值按5分、2分、1分顺序,各类硬币数量依次从大到小的顺序,输出各种换法。 // 输出使用语句:printf("fen5:%d,fen2:%d,fen1:%d,total:%d\n",fen5, fen2, fen1, fen5+fen2+fen1); // 输入输出示例:括号内为说明 //...
C
#include <limits.h> #include <stdio.h> void bit_print(int); int main(void){ bit_print(45692); printf("\n"); return 0; } void bit_print(int a){ int i; int n = sizeof(int) * CHAR_BIT; int mask = 1 << (n - 1); for (i = 1; i <= n; ++i){ putchar(((a & mask) == 0) ? '0' : '1'); a <<= 1; if (i % CHAR_BIT == 0...
C
#include <stdio.h> #define M 10 void main() { static int a[M] = {-9, -5, -3, 0, 1, 5, 7, 14, 20, 43}; int n, min, mid, max, found; min = 0; max = M - 1; printf("Please enter your search number: \n"); scanf("%d", &n); while (1) { mid = (min + max) / 2; if (min > max) ...
C
#include "multiq.h" MultiQ* createMQ(int num){ MultiQ* mq = (MultiQ*)malloc(sizeof(MultiQ)); mq->q = (Queue*)malloc(sizeof(Queue)*num); for (int i=0; i<num; i++){ mq->q[i] = newQ(); } mq->size = num; return mq; } MultiQ* addMQ(MultiQ* mq, Task* t){ if(t->pr > mq->size){ return mq; } Element* node = (Elem...
C
// // prog2.c // prog2 // // Created by ENZE XU on 2021/9/25. // #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <signal.h> #include <time.h> #include <sys/types.h> #include <sys/wait.h> #include <pwd.h> #define MAXN 10000 void quitHandler(int); char * getMainPath(void); ch...
C
#ifndef PLAYER_H #define PLAYER_H #include <stdarg.h> #include "gl_kyl.h" /* * sprite struct containing ALL information about a sprite, like location, velocity, whether it is jumping * or grounded, whether it is shielding and for how long, whether the character is knockbacked and for * how long, whether the sprit...
C
/* * Modify the problem written previously, so that the function returns the address * of the character string containing the propery day to be displayed * */ #include <stdio.h> int GetDay(char **days, int x); int main() { int input = 0; char *days[7] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thur...
C
#include "MPU9250_header.h" #include "mpu9250_methoden.c" float sum = 0; uint32_t sumCount = 0; char buffer[14]; int main(){ printf("main startet...\n\r"); int data; // Read the WHO_AM_I register, this is a good test of communication int status = i2c_readByte(0, MPU9250_ADDRESS, WHO_AM_I_MPU9250,...
C
#include <fs/myfs/file.h> #include <fs/myfs/inode.h> #include <device/ata.h> #include <thread/thread.h> #include <fs/myfs/fs_types.h> #include <fs/myfs/dir.h> #include <fs/myfs/utils.h> #include <mm/kvmm.h> #include <string.h> #include <thread/process.h> #include <kprintf.h> #include <common/utils.h> static file_t fil...
C
#include <stdio.h> #include <time.h> #include <stdlib.h> #include <pthread.h> #include <unistd.h> #include <stdint.h> #include "file.h" #include <sys/stat.h> #include <sys/mman.h> #include <fcntl.h> #include <string.h> void make_file(char* filename, int amount){ FILE* file = fopen(filename,"w"); srand(time(NU...
C
int substr( char dst[], char src[], int start, int len): { int dst_index, src_index; dst_index = 0; if(start >= 0 && len > 0) { for( src_index = 0; src_index < start && src[src_index] != '\0'; src_index++) while ( len > 0 && src[src_index] != '\0') { dst[dst_index] = src[src_index]; ...
C
#include <stdio.h> #include <stdlib.h> #include <sys/socket.h> #include <sys/types.h> #include <error.h> #include <netinet/in.h> #include <string.h> #include <arpa/inet.h> #include <unistd.h> #include <pthread.h> #include <sys/ipc.h> #include <sys/sem.h> #include <sys/shm.h> int semid; int shmid; union semun{ int...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> typedef double real; void vector_project(real *input, real angle, real *output){ angle = angle*3.1415956/180.; output[0]=input[0]*cos(angle)+input[1]*sin(angle); output[1]=-input[0]*sin(angle)+input[1]*cos(angle); } int main(){ real...
C
#include "tipo.h" #ifndef PILHA_H #define PILHA_H #define STACK_NULL_PTR -5 #define STACK_EMPTY -4 typedef struct stack stack; /** * Cria uma pilha inicialmente vazia e retorna o endereço de memória alocado para a pilha. * @return: um ponteiro para pilha. */ stack *stack_create(void); /** * Libera o espaço...
C
// // Created by pioter on 20.05.2020. // #ifndef BOMBERMAN_CLIENT_ENEMY_H #define BOMBERMAN_CLIENT_ENEMY_H #include <SDL2/SDL.h> #include "board.h" #include "bomb.h" #include <pthread.h> typedef struct Enemy{ SDL_Texture *texture; // enemie's texture SDL_Rect image; // bounding box of enemy int x; // cu...
C
#include <stdio.h> void itoa(int n, char s[]){ int i, sign; //sign: positive or negative number if((sign = n) < 0) n = -n; i = 0; do{ s[i++] = n%10 + '0'; //'0' show will ascii value of 0(48) then we can add any number to find out their ascii value }while((n/=10)>0); ...
C
#include "../includes/libshell.h" int is_symbol(char c) { char **symbols; int i; i = 0; symbols = ft_split(SYMBOL_LIST, ':'); while (symbols[i]) { if (symbols[i][0] == c) return (1); i++; } return (0); } int is_quote(char c, char type) { if (c == type) return (1); return (0); } void p_putchar_st...
C
#ifndef _LINKED_STRUCTURES_BASE_H_ #define _LINKED_STRUCTURES_BASE_H_ #define LINKED_MALLOC malloc #define LINKED_FREE free #include <stdio.h> #include <string.h> #include <inttypes.h> #include <stdlib.h> typedef struct Object_vtable Object_vtable; typedef struct Comparable_vtable Comparable_vtable; typedef struct C...
C
#include "symboltable.h" #include "syntaxtree.h" #include "y.tab.h" #include <stdlib.h> #include <stdio.h> #include <string.h> Gsymbol *head = NULL; Gsymbol *tail = NULL; Lsymbol *LsymbolHead = NULL; Lsymbol *LsymbolTail = NULL; paramStruct* paramHead = NULL; //for parameters paramStruct* paramTail = NULL; int nex...
C
/** This function will trim a string by eliminating the spaces from * the start and the end of the string. */ void trim(char *s) { int origLen, len; char *sCopy; int start, end; origLen = strlen(s); sCopy = strdup(s); if (sCopy != NULL) { len = strlen(sCopy); for (start=0; start= 0; end--) { if (!isspa...
C
/*Author: Kartik Jagdale */ #include<stdio.h> #define MUL(a, b) ((a)*(b)) /*Putting everything in Paraenthesis is is good practice */ #define MAX(a, b) ((a)>(b) ? (a) : (b)) int main(int argc, char**argv){ int a = 10; int b = 20; printf("A value is %d, B Value is %d and A * B is %d\n",a, b, MUL(a, b) ); ...
C
#include <stdlib.h> #include <assert.h> #include <string.h> #include "dfa.h" #include "mpool.h" #include "node.h" dfa_trie_t *dfa_trie_create() { dfa_trie_t *trie = (dfa_trie_t *) malloc(sizeof(dfa_trie_t)); if (NULL == trie) return NULL; trie->mp = mpool_create(0); trie->root = dfa_node_creat...