language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> #include "vector.h" int main() { vector v1; vector v2; vector z; vector a; printf("Ingrese x para vector1: "); scanf("%d",&v1.x); printf("Ingrese y para vector1: "); scanf("%d",&v1.y); printf("Ingrese x para vector2: "); scanf("%d",&v2.x); printf("Ingrese y para vector2:...
C
// C code file for a file ADT where we can read a single bit at a // time, or write a single bit at a time #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "bitfile.h" // open a bit file in "r" (read) mode or "w" (write) mode struct bitfile *bitfile_open(char *filename, char *...
C
#include <stdio.h> #include <math.h> #include <mpi.h> double f(double x,int n) { int i,j; double res; res = 0.0; for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { double r1 = sin( ((pow(x,i) + pow(x,j))/2) ); double r2 = 1 - cos( (pow(x,i) + pow(x,j))/2 ); res += r1 * ...
C
#include<stdio.h> #include<conio.h> int main() { int i,n; //clrscr(); scanf("%d", &n); for(i=1;i<=n;i=i+1); { printf("%d", i); } getch(); }
C
#include<stdio.h> #include<stdlib.h> #include<ctype.h> #include<math.h> struct node{ int key; struct node *back; }; typedef struct node Node; Node * getnode() { return (Node *)malloc(sizeof(Node)); } Node * push(Node * top, int a) { Node *temp; if(top==NULL) { top=getnode(); top->key=a; top->bac...
C
/* functions related to quadric error metrics */ /* compute the quadric error for a query position of a vertex */ starreal quadricerrorquery(struct tetcomplex *mesh, tag vtag, starreal v[3]) { struct quadric *q; starreal quad; /* fetch the quadric ...
C
#include "list.h" #include <stdlib.h> #include <string.h> /** * add_node_end - Add a new node to the end of a double circular linked list * @list: A pointer to the head of the linkd list * @str: the string to copy into the node * Return: pointer to the created node */ List *add_node_end(List **list, char *str) { ...
C
/** @file main.c * * kernel.c: Kernel main (entry) function * * Author: Satvik Dhandhania <sdhandha@andrew.cmu.edu> * Vallari Mehta <vallarim@andrew.cmu.edu> * * Date: 25th Nov 2015 */ //Given in src code #include <kernel.h> #include <task.h> #include <sched.h> #include <device.h> #include <assert....
C
// // ARGS: sort Algo, file to sort, -o, file to print to, -k, col to sort on, filesize // 0 1 2 3 4 5 6 #include "root.h" #include <sys/times.h> /* times() */ int sort_column; void swap(Record * a, Record * b) { Record tmp; tmp = *a; *a = *b...
C
/** * @brief It defines the die interpreter * * @file die.h * @author Ana Roa González * @version 1.0 * @date 06-03-2018 */ #ifndef DIE_H #define DIE_H #include "../include/types.h" typedef struct _Die Die; /** * @author Ana Roa González * @brief Crea un dado * @return Puntero a Die */ Die* die_create(); /...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_lstmap.c :+: :+: :+: ...
C
#include<stdio.h> void main() { int money; printf("ENTER THE SUM OF MONEY\n"); scanf("%d",&money); int denomination[9]; for(int i=0;i<9;i++) { denomination[i]=0; } int h=money%10; if(h>=5) { h=h-5; denomination[2]=1; } if(h%2==0) ...
C
/* ** list_rev.c for list_rev in ~/c/rendu/piscine/j6 ** ** Made by jean-daniel michaud ** Login <michau_j@epita.fr> ** ** Started on Tue Oct 2 21:03:41 2001 jean-daniel michaud ** Last update Thu Oct 4 02:04:49 2001 jean-daniel michaud */ #include "list.h" #include "dlist.h" void dlist_rev(t_dlist **dlist) {...
C
#include "push_swap.h" void ft_free_arr(char **arr) { int i; i = 0; while (arr[i]) free(arr[i++]); free(arr); arr = NULL; }
C
#include <stdio.h> /* tells the compiler to include information about the standard input/output library */ /* Exercise 1-7 Write a program to print the value of EOF */ main() { printf( "The value of EOF is %d\n" , EOF ); // Print the EOF value (numeric) }
C
#include <stdio.h> #include <string.h> int lowerToUpper(char []); int main(void) { char inputWord[40]; printf("Type a word in the lower case: "); scanf("%s", inputWord); if(lowerToUpper(inputWord) == 1){ printf("The word in the upper case: %s\n", inputWord); } return 0; } int lowerToUpper(ch...
C
#include<stdio.h> int main(){ int t,n,x,y; scanf("%d",&t); while(t--){ int ans=0; scanf("%d",&n); while(n--){ scanf("%d %d",&x,&y); if((y-x)>5) { ans++;} } printf("%d\n",ans); } }
C
#include <stdio.h> int main() { int m[6] = {2,1,3,4,5}; //数组初始化末尾不会赋值0 int n[6] = {5,6,7,8,9}; int *pm = m; int *pn = n; int tmp; int i; while(*pm) { tmp = *pm; *pm = *pn; *pn = tmp; *pm++; *pn++; } printf("After m exchange:"); for(i=0;i<5;i++) { printf("%d",m[i]); } printf("\n"); printf...
C
#include <stdio.h> #ifndef FLAG #define FLAG "" #endif static const char* flag = "the flag is in this binary, you'll never find it!\0" "Look at this photograph\n" "Every time I do, it makes me laugh\n" "How did our eyes get so red?\n" "And what the hell is on Joey's head?\n" "And this is where I grew up\n...
C
#include<stdio.h> #include<stdlib.h> #include<math.h> int main(int argc, char *argv[]) { double a=0, b=0, c=0, x=0, x1=0, x2=0, d=0; printf("Entrer les valeurs de a, de b et de c:\n"); scanf("%lf %lf %lf", &a, &b, &c); d=pow(b,2)-4*a*c; if (d>0) { printf("Il y a deux solutio...
C
#include <stdio.h> #include <stdarg.h> void print_integer(int num) { printf("%d", num); } void print_float(float fnum) { printf("%f", fnum); } int simple_printf(const char *format, ...) { va_list var_arg; char cvalue; char *svalue; va_start(var_arg, format); while (*format) { switch (*format) { case '%':...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "../include/database.h" #include "../include/venta.h" #include "../include/inventario.h" #include "../include/login.h" #include <stdbool.h> #if defined(__WIN32) //Windows detectado #include <windows.h> #include <conio.h> #elif defined(__linux__) //Lin...
C
#include<stdio.h> int n[100001]; int lsearch(int request, int len); int main() { int len,query; scanf("%d",&len); for(int i = 0; i<len ;i++) { scanf("%d", &n[i]); } scanf("%d", &query); printf("%d", lsearch(query, len)); return 0; } int lsearch(int request, int len) { for(in...
C
#include <stdio.h> int main() { int max = -1000000; int min = 1000000; for (int i = 0; i < 5; i++) { int k; scanf("%d", &k); if (k > max) max = k; if (k < min) min = k; } printf("%d\n%d", max, min); return 0; }
C
#include <stdio.h> #include <string.h> int main(){ char name[20], sign[20]; printf("Ingresa tu nombre: ");gets(name); printf("Ingresa tu signo: ");gets(sign); if(strcmp(sign, "aries") == 0){ printf("%s es aries.", name); } else{ printf("%s no es aries.", name); } return 0; }
C
/****************************************************************************** * * Module: PWM * * File Name: pwm-config.h * * Description: Config file for the AVR PWM driver * * Author: Kirollos Ashraf * *******************************************************************************/ #ifndef __PWM_CONFIG_...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_handle_wstr.c :+: :+: :+: ...
C
/* ** EPITECH PROJECT, 2020 ** fd ** File description: ** fd */ #include "my.h" int pipe_loop_ext(piping_t *piping, shell_t *shell, char **envp, pid_t pid) { int x = 0; int stock_stdin = dup(0); int stock_stdout = dup(1); dup2(piping->fd[0], 0); dup2(piping->fd[1], 1); x = my_function(shell, ...
C
/** * Mensajes * * Aquí están contenidos todos los mensajes de * información, error, etc. del programa */ #define INFO_HELP "TP1-Procesos - 1.0 - Alberto Fernández Martínez\nAsignatura Sistemas Operativos (UNED) - Curso 2011-2012\n\nusage: TP1-Procesos [arguments]\n\nArguments:\n\t-gui\t\tLoad up graphical user i...
C
#include "queue.h" static ComandQueue cmdQueue; uint8_t getNumberCmd() { return (cmdQueue.nextCmd > cmdQueue.firstCmd) ? cmdQueue.nextCmd - cmdQueue.firstCmd : cmdQueue.nextCmd - cmdQueue.firstCmd - (~((uint8_t) MAX_LENGTH_QUEUE)+1); } void addCommand(Command* cmd, uint16_t size) { if(cmdQueue.length...
C
/* fichero marathon.c */ /* Un marathon tiene 26 millas y 385 yardas. */ /* Una milla tiene 1760 yardas. */ /* Calcula la distancia del marathon en kilómetros. */ #include <stdio.h> void main(void) { int millas, yardas; float kilometros; millas=26; yardas=385; kilometros=1.609*(millas+yardas/17...
C
/* ** por compatibilidad se omiten tildes ** ================================================================================ TRABAJO PRACTICO 3 - System Programming - ORGANIZACION DE COMPUTADOR II - FCEN ================================================================================ funciones auxiliares para rutina...
C
#include <stdio.h> #include <stdlib.h> struct studentGrades { char name[20]; int grade; }; typedef struct studentGrades studentGrades; void bubbleSort1(studentGrades *a, int n); void bubbleSort2(studentGrades *a, int n); int main() { int *a; // dynamic array pointer int i, n; struct studentGrades *s; str...
C
#include<stdio.h> int main() { char a[1000],s; int i,j,t; printf("enter string \n"); gets(a); for(j=0;a[j]!='\0';j++); j--; if(j%2==0) t=j/2+1; else t=j/2; for(i=0;i<=t;i++) { s=a[i]; a[i]=a[j]; a[j]=s; j--; ...
C
#include<stdio.h> #include<stdlib.h> void merge(int* a,int l,int mid,int h){ int n = mid-l+1; int m = h-mid; int a1[n]; int a2[m]; for(int i=0;i<n;i++) a1[i] = a[l+i]; for(int i=0;i<m;i++) a2[i] = a[mid+1+i]; int i=0,j=0,k=l; while(i<n && j<m){ if(a1[i]<=a2[j]) a[k]=a1[i++]; else a[k]=a2[j++]; k++; } wh...
C
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> #include <tgmath.h> int main() { int cases; scanf("%d", &cases); int i; for (i=0;i<cases;i++){ long int nthterm; scanf("%ld", &nthterm); long long int modulo = pow(10, 9) + 7; printf("%lld\n", (long long int)powl((ntht...
C
#include <stdio.h> #include <sys/socket.h> #include <arpa/inet.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <netdb.h> #define RECV_SIZE 1024 #define PORT 14456 void dieWithError(char* message); unsigned long resolveName(char* name); void sendToServer(int sock, char* message); unsigned int...
C
/* * Remove Element * * Given an array and a value, remove all instances of that value * in place and return the new length. * * The order of elements can be changed. It doesn't matter what you * leave beyond the new length. * */ /* C solution */ int removeElement(int A[], int n, int elem) { // S...
C
/* * ASUS xtion color channel */ #include "xtion-color.h" #include "xtion-endpoint.h" #include "xtion-control.h" static inline struct xtion_color *endp_color(struct xtion_endpoint *endp) { return container_of(endp, struct xtion_color, endp); } static void color_start(struct xtion_endpoint* endp) { struct xtion_co...
C
#ifndef BCI_TUAFILTER_H_INCLUDED #define BCI_TUAFILTER_H_INCLUDED //Ten-unit average filter typedef struct TUAFilter_t { float components[10]; int index; } TUAFilter; /** * Initializes a ten-unit average filter * @param filter TUA filter to initialize */ void filter_Init_TUA(TUAFilter *filter); /** * Filters a...
C
#include <stdio.h> #include <time.h> #include <stdlib.h> #include <stdbool.h> #define NUM_SUITS 4 #define NUM_RANKS 13 #define NUM_CARDS 5 /* external variables */ int num_in_rank[NUM_RANKS] ; int num_in_suit[NUM_SUITS] ; bool straight , flush ,four ,three ; int pairs ; /*can be 0,1,or 2 */ //prot...
C
#ifndef _H8300_DELAY_H #define _H8300_DELAY_H #include <asm/param.h> /* * Copyright (C) 2002 Yoshinori Sato <ysato@sourceforge.jp> * * Delay routines, using a pre-computed "loops_per_second" value. */ static inline void __delay(unsigned long loops) { __asm__ __volatile__ ("1:\n\t" "dec.l #1,%0\n\t" ...
C
#include <stdio.h> typedef struct{ int blobsize; int *blob; }cpt_hdl; int disp_pkey(const int **blob){ printf("blob = %d\n", **blob); } int main(void){ cpt_hdl *pkey; cpt_hdl pkey_mem; int *keybuf; int *keybuf_addr; int *keybuf_addr_addr; int keybuf_addr_mem; int **keybu...
C
/* ------------------------------------- Author: Anshul Khatri ID: 193313680 Email: khat3680@mylaurier.ca Version 2020-06-25 ------------------------------------- */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include "process.h" Process* create_process(long pid, int ti...
C
#include<stdio.h> #include<stdlib.h> #include<ctype.h> #include<string.h> #define SIZE 100 char stack[SIZE]; int top = -1; void push(char item) { if(top >= SIZE-1) { printf("\nStack Overflow."); } else { top = top+1; stack[top] = item; } } char pop() { char item ; if(top...
C
#include<stdio.h> void swap(int a,int b,int arr[]) { int c = arr[a]; arr[a] = arr[b]; arr[b] = c; } void sink(int arr[],int i,int n) { if(i >= n-1) // if i == last element/size so return return; int current = i; int left = 2*i; // Left child of Parent int r...
C
#ifndef F_CPU #define F_CPU 1000000UL #endif #include <avr/io.h> #include <util/delay.h> #include <avr/eeprom.h> #include <avr/power.h> #include <avr/sleep.h> #include <avr/interrupt.h> #define LED_PIN0 (1 << PB0) #define LED_PIN1 (1 << PB1) #define LED_PIN2 (1 << PB2) #define KEY0 (1 << PB3) #define KEY1 (1 << PB4) ...
C
/************************************************************************************** * LED--ʾʵ * ʵس󣬰չڲƵߣLEDʾ ע뽫74HC595ģJP595̽Ƭ̽ӣ򲻻 ***************************************************************************************/ #include "reg51.h" //ļж˵ƬһЩ⹦ܼĴ #incl...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/msg.h> #include "util.h" #include "msgqueuelib.h" /** * Generate a unique key (unsigned int) from a name. Makes an XOR of all the * characters of the name. The key is used to create/link a shared me...
C
#include <stdio.h> /** * main - prints all possible combinations of single digit numbers * Return: returns 0 */ int main(void) { int Z; for (Z = '0'; Z <= '9'; Z++) { putchar(Z); if (Z < '9') { putchar(','); putchar(' '); } } putchar('\n'); return (0); }
C
#include <stdio.h> #define INF __INT_MAX__ int col; void printShortestpath(long long dist[][col], int size) { for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { if (dist[i][j] == INF) { printf("INF "); } ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* checker.c :+: :+: :+: ...
C
#include<GL/glut.h> #include<stdio.h> #include<math.h> #define Round(a)((int)(a+0.5)) float xc; float yc; float rx; float ry; void setpixel(float x,float y) { glBegin(GL_POINTS); glColor3f(0.0f,1.0f,1.0f); glVertex2f(x,y); glEnd(); glFlush(); } void init() { glClearColor(0.0f,0.0f,1.0f,1.0f); glMatrixMode(GL_...
C
#pragma once enum ShowWindowFlags : int { /// <summary> /// minimizes a window, even if the thread that owns the window is not responding. /// this flag should only be used when minimizing windows from a different thread. /// </summary> sw_forceminimize = SW_FORCEMINIMIZE, /// <summary> /// hides the window a...
C
#include <stdio.h> void sort(char let[5][4]) { int i, j, k, l, ret; char word1[4]; char word2[4]; for(k = 0; k < 4; k++) //this outter loop exists to run these 2 inner loops. the outter loop is basically { //required to make sure this bubble sort in the most inner lo...
C
#include <stdio.h> #include <locale.h> int main() { setlocale(LC_ALL, ""); int minhaIdade = 23; int maeIdade = 48; int paiIdade = 49; printf("Minha idade = %i.\n", minhaIdade); printf("Minha idade = %i.\nPai idade = %i.\nMe idade = %i.", minhaIdade, paiIdade, maeIdade); return 0; }
C
#include <stdio.h> int f(int x, int y) { return 10 * x + y; } int main(void) { int i, j; i = 0; j = f(++i, ++i); printf("%d\n", j); return 0; }
C
#include "PawnCmd.h" #include <string.h> static void PawnCmdSystem_Wait_Init(PawnCmdSystem_T * sys, PawnCmdData_Wait_T * cmd); static int PawnCmdSystem_Wait_Update(PawnCmdSystem_T * sys, PawnCmdData_Wait_T * cmd, float seconds); static void PawnCmdSystem_Move_Init(PawnCmdSystem_T * sys, PawnCmdData_Move_T * cmd); st...
C
#if 1 #include<stdio.h> #include<stdlib.h> #include<string.h> #include<netinet/in.h> #include<sys/types.h> #include<sys/socket.h> #include<pthread.h> #include<unistd.h> #include<arpa/inet.h> void Usage() { printf("usage: ./server [ip][port]\n"); } void ProcessRequest(int client_fd,struct sockaddr_in* client_addr) { ...
C
#include<stdio.h> int main() /*{ int n; printf("How many times you wanna print?\n"); scanf("%d", &n); for(int i=1; i<=n; i=i+1) { printf("Code Likha h...Count kr\n"); } return 0; }*/ /*{ int n, i=0; printf("How many times you wanna print?\n"); scanf("%d", &n); whi...
C
#include <stdio.h> #include <sys/fcntl.h> int main(void) { int dev; char c; dev = open("/dev/simple_sensor_dev", O_RDWR); scanf("%c", &c); close(dev); return 0; }
C
#include <stdio.h> int main() { int i = 0, c; while ((c = getchar()) != EOF) { /* code */ if (c != 10) { /* code */ ++i; } else { /* code */ break; } } printf("%d\n", i); return 0; ...
C
#include <stdlib.h> #include <stdio.h> #include "Prototypes.h" int testASCII() { int i =0; for(i=0; i<256; i++) { printf("%d = %c \n", i, (char)i); } return 0; }
C
#ifndef ANGLES_H #define ANGLES_H #include <stdbool.h> #include "inc/point.h" #define ANGLE_0 0 #define ANGLE_45 45 #define ANGLE_90 90 #define ANGLE_135 135 #define ANGLE_180 180 #define ANGLE_225 225 #define ANGLE_270 270 #define ANGLE_315 315 /** * @brief AngleCorrection * @param angle * @return */ ...
C
/* * iterador.c * * Created on: 7 de Mai de 2013 * Author: Antnio */ #include <stdlib.h> # include "iterador.h" #include "noSimples.h" // estrutura de dados necessria para iterador de vector struct _itVector{ void ** vector; int corrente; int numElems; }; // estrutura de dados necessria para iterador de...
C
#include<stdio.h> void main() { int a; a=7>15 & 4<6; printf("%d\n",a); }
C
#include <stdio.h> //Comparar edades int main(){ int edad=0; printf("Introduce tu edad [0-150]: "); scanf("%d",&edad); // 30 //operadores lógicos // AND -> && // OR -> || // NOT -> ! if (edad > 0 && edad <= 12){ // 1 - 12 printf("Eres generación alpha y tienes %d",edad); if(edad < 9){ prin...
C
#include "index.h" #include <fcntl.h> // gpio ϴ ϴ Ȯϴ° ߰ (2015.08.12) void gpioExport(char *gpioNumber) { int fp; char location[40]; strcpy(location, "/sys/class/gpio/export"); strcat(location, gpioNumber); fp = open("/sys/class/gpio/export", O_WRONLY); #ifdef DEBUG_OPEN if(fp ==...
C
#include<stdio.h> #include<stdlib.h> struct bst { int info; struct bst *lNode; struct bst *rNode; }*root=NULL,*temp=NULL,*t1,*t2; static int index; void insertNode(); void create(); void delete(); void deleteSearch(struct bst *t,int data) ; void delete1(struct bst *t) ; int smallest(s...
C
#include <stdio.h> int posOfFile(int *history, int lookup) { } int main(int argc, char const *argv[]) { int history[] = {1, 2, 3, 4, 5, -2, 6, 7, 8, 9, -3, 10, 11, -1, -2, 0}; int lookup = 1; printf("%d", posOfFile(history, lookup)); return 0; }
C
#include <stdio.h> #include <stdlib.h> #include "complexo.h" int main(){ Complexo_t *p, *q; bool x; x = Construtor(&p); if(x == false){ printf("Memoria nao foi alocada.\n"); exit(1); } x = Construtor(&q); if(x == false){ printf("Memoria nao foi alocada.\n"); ...
C
#include <stdio.h> #include <math.h> int main() { freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); float n, a, b,s1,s2; scanf("%f",&n); while(n--){ scanf("%f %f",&a,&b); s1=(a+b)/2;s2=(a-b)/2; if(s1!=(int)s1||s2!=(int)s2||s1<0||s2<0) printf("impossible\n")...
C
#include<iostream> #include<stdio.h> int main() { double a, b, c, x = 0, y = 0; char ch; while (1) { printf("请输入一元二次函数的系数(以空格隔开):"); scanf("%lf%lf%lf", &a, &b, &c); printf("你输入的函数为y=%gx^2%+gx%+g\n图像如下\n", a, b, c); do //外层循环控制Y坐标的象限 { if (y == 40) { printf("|---------|---------|-----...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* reverse.c :+: :+: :+: ...
C
// // main.c // Exe4.23 // // Created by Francesco Parrucci on 17/01/19. // Copyright © 2019 Francesco Parrucci. All rights reserved. // /* MODIFICA IL PROGRAMMA DELLA FIGURA 4.6 IN MODO CHE UTILIZZI SOLTANTO DEGLI INTERI PER CALCORARE L'INTERESSE COMPOSTO. (SUGGERIMENTO: TRATTATE TUTTE LE CIFRE MONETARIE COME QU...
C
// proc.c, 159 /* need to include "syscall.h" to call the new OS services program a void-returning Init that has no input loop forever: call get_time_call() to get current time in seconds convert time to a smaller time str call write_call to show time_str ... ... see demo run to issue...
C
#include <stdio.h> int main(int argc, const char * argv[]) { int x = 1, y = 2; x = x + y; printf("...%d.....%d\n", x, y); return 0; }
C
// Demonstrate basic pointer arithmetic #include <stdio.h> void print0_ptr(int *p){ // print int pointed at by p printf("%ld: %d\n",(long) p, *p); // address and 0th elem } int main(){ int x = 21; int *p; // declare a pointer int a[] = {5,10,15}; // declare array, auto ...
C
#include <stdio.h> int main() { /* 変数宣言 */ int n; /* 近似次数 */ double x, y = 1.0; /* 独立変数、従属変数 */ /* 途中の計算に必要な変数の宣言 */ int i; /* 繰り返し変数の宣言 */ double f = 1.0, p = 1.0; /* 階乗値,累乗値 */ /* データの読み込み(倍精度, 整数) */ scanf("%lf%d",&x,&n); for (i=1; i<=n; i++) { f *= (double)i; p *= x; y += ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_next_line_utils.c :+: :+: :+: ...
C
/* ** EPITECH PROJECT, 2019 ** corewar asm ** File description: ** manipulation of bytes */ #include <stdlib.h> #include <stdio.h> #include "operator_abstract.h" #include "corewar.h" int reverse_bytes(int nb) { int reversed_bytes = 0; int index = 0; int next_byte = 0; for (; index < 4; ++index) { ...
C
#define doller 20 //定义给定多少钱 #define price 1 // 定义每瓶的价格 #include <stdio.h> #include <stdlib.h> int Drink_Water(int arr[]){ int total = doller; int empty = doller; while (empty >= 2) { total += empty / 2; empty = empty / 2 + empty % 2; } return total; } int main(){ int arr[doll...
C
// find better solutions !!! use UNION FIND by which algorithms ???? // learn a lot from this !!! int _hash(char* s, int primer) { int i = 0; int c = s[i ++]; int t = 0; while (c) { t = ((t << 8) + c) % primer; c = s[i ++]; } return t; } void am_sort(int* n, int s, int e, ...
C
/* Given an input array a={1,2,3,6,2,8----} product of all numbers=p=a[0]*a[1]*---a[n-1] where n is size of array output arrau should be b={p/a[0],p/a[1],p/a[2]-----}. you should not use division operator.Time complexity should be less than o(n2). */ /* this one is simple you will need two array of same size solu...
C
/** @file input.c Documented input module. * * Julien Lesgourgues, 27.08.2010 */ #include "input.h" /** * Use this routine to extract initial parameters from files 'xxx.ini' * and/or 'xxx.pre'. They can be the arguments of the main() routine. * * If class is embedded into another code, you will probably p...
C
#include <stdio.h> #include <stdlib.h> #include "math.h" #include "mpi.h" //MPI kutuphanesi #define PI acos(-1) #define N 500000000 #define MASTER 0 double f(double x) { return 4 / (1 + x * x); // return 1 / (1 + pow(x, 2)); } int main(void) { int rank, size; MPI_Init(NULL, NULL); double t1, t2; t1 = MPI_W...
C
#include <stdlib.h> #include <stdio.h> #include "binary_trees.h" /** * binary_tree_is_bst-function that checks if a binary *tree is a valid Binary Search Treer * of a binary tree of a node in a binary tree *@tree: is a pointer to the root node of the tree to check *Return: always success. **/ int binary_tree_is_bst(con...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_next_line.c :+: :+: :+: ...
C
#include <stdio.h> int main(void) { int l,w,h; scanf("%d%d%d",&l,&w,&h); printf("%d",l*w*h); return 0; }
C
/** * Descripción: Define las funciones y estrucutras utilizadas para space * * @file space.h * @author Miguel Manzano * @version 1.1 * @date 11-02-2018 * @copyright GNU Public License * Comments: */ #ifndef SPACE_H #define SPACE_H #include "types.h" #include "set.h" typedef struct _Space S...
C
#include<stdio.h> #include<math.h> int main() { double x, y, angle, pi, radian; pi = 3.1415926; printf("x, y, angle="); scanf("%lf%lf%lf", &x, &y, &angle); radian = pi * angle / 180.0; printf("%lf\n", 0.50 * x * y * sin(radian)); }
C
// A. Matriz serpentina #define MAX 20 int main(){ int m[MAX][MAX]; int i=0,j=0,k=1,N,M,t, pos; scanf("%d%d", &N, &M); t=N*M; for (i=0;i<N; i++) for (j=0; j<M; j++){ pos = ((i+1)%2==0)?M-j-1:j; m[i][pos]=k++; } for (i=0;i<N; i++){ for (j=0; j<M; j++) printf("%d ",m[i][j]); prin...
C
/* vim: set sw=4 ts=4: * Author: Liu DongMiao <liudongmiao@gmail.com> * Created : Tue 14 Aug 2012 09:12:11 AM CST * Modified : Tue 14 Aug 2012 10:42:20 AM CST */ /* * Add a field-searching capability, so sorting may be done on fields within * lines, each field sorted according to an independent set of options. ...
C
/* ============================================================================ Programmname: DameHilfsfunktionenSteinSetzen.c Autor : Andreas Danek, Daniel Janen Datum : 18.03.2009 Thema : Projektarbeit Version : 1.0 Programmschnittstelle: Funktionen ======================...
C
#include <stdio.h> int main() { int i,j; char c[2]="01"; for(i=1;i<=6;++i) { for(j=0;j<i;++j) { printf("%s",c); } printf("\n"); } return 0; }
C
#include<stdio.h> int main() { int a[10]={1,2,3,4,5,6,7,8,9,10}; int i,sum=0; for(i=0;i<9;i++) { sum=sum+a[i]; } printf("sum of elements is %d",sum); return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <assert.h> #include <getopt.h> #include "getline.h" uint8_t codelen(uint8_t s); uint8_t shortnote(uint8_t s); uint8_t longnote(uint8_t s); void decode(void); void encode(void); void printcode(uint8_t c); void usage(FILE *out); int reverse = 0; char *...
C
//C Primer Plusp318 10.13.13 #include <stdio.h> #define ROWS 3 #define COLS 5 void scan_arr(double arr[][COLS]); double row_average(double row[]); double all_average(double arr[][COLS]); double max_element(double arr[][COLS]); int main(void) { double arr[ROWS][COLS]; scan_arr(arr); int row; for (row = 0; row <...
C
#include<stdio.h> #include<stdlib.h> int main(int argc, char *argv[]){ int arg; for(arg=0;arg<argc;arg++){ if(argv[arg][0]=='-'){ if(argv[arg][1]=='n') printf("option = %s value = %s\n","n",argv[arg]+2); else printf("option = %s \n",argv[arg]+1); } else printf("argument = %d : %s\n",arg,argv[arg]); } e...
C
// Problem #17 --- Number of letters written numbers one, two..one thousand #include <stdio.h> int main() { int ones_column[] = {0, 3, 3, 5, 4, 4, 3, 5, 5, 4, 3, 6, 6, 8, 8, 7, 7, 9, 8, 8}; int tens_column[] = {0, 0, 6, 6, 5, 5, 5, 7, 6, 6}; int total = 8984; // 891*10 + 9*7 + 11 is "hundred and" and "hun...