language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> #include <math.h> float roundInteger(float num); float roundTenth(float num); float roundHundreth(float num); float roundThousandth(float num); int main() { char str_num[15]; float num; while(1) { printf("Enter a number:\n"); fgets(str_num, 14, stdin); if (sscanf(str_num,...
C
/* Comp 222 - Spring 2020 Oscar Cansino Assignment #1: Measuring Performance */ #include <stdio.h> #include <stdlib.h> void printMenu(); void enterParameters(); void printPerformance(); void calculatePerformance(); void exit_program(); //Variables int numberOfClasses; float ghz = 0; int *cpi_i...
C
#include<stdio.h> #include<stdlib.h> int n; void swap(int array[],int firstItemIndex,int lastItemInde) { int tmp=array[firstItemIndex]; array[firstItemIndex]=array[lastItemInde]; array[lastItemInde]=tmp; } void heapify(int heap[],int i,int max) { int index, leftChild, righChild; while(i<max) { ...
C
#include <stdio.h> #include <stdlib.h> void func (); int main() { int x,y,*ptx,*pty; ptx = & x ; pty = & y; func(ptx , pty); printf("x=%i\n",x); printf("y=%i\n",y); return 0; } void func(int *x , int *y) { *x = 5; *y=10; }
C
/** * Arquivo contendo a implementação das funções referentes a entidade jogador * * @author Luís Augusto Weber Mercado */ void definirPadroesDoJogador( Jogador *jogador ) { jogador->vidas = JOGADOR_NUMERO_VIDAS; jogador->direcaoMovimento = DIRECAO_NULA; jogador->nivelAtual = 1; jogador->pontuacao...
C
#include <stdio.h> #include <pthread.h> static void * experiment ( void * a ) { pthread_attr_t tattr; size_t size; int ret = pthread_attr_getstacksize(&tattr, &size); printf ( " ret = %d,size=%u\n" ,ret , size ) ; } int main( int argc , char * argv[] ) { pthread_t thr; int arg = 123 ; pthread_cre...
C
#define TOTAL (10) typedef struct category Category; // For Destination categories typedef struct info Information; // For database of current program typedef struct currentUser CurrentUser; // For current user's info typedef struct salesReport SalesReport; // For sales report typedef struct files D...
C
#pragma once enum class SoundQuality { Unknown = 0, Low = 1, High = 2, Lossless = 3, LosslessHd = 4 }; inline bool operator < (SoundQuality lhs, SoundQuality rhs) { return static_cast<int>(lhs) < static_cast<int>(rhs); } inline bool operator <= (SoundQuality lhs, SoundQuality rhs) { return static_cast<int>(lhs)...
C
#include<stdio.h> int main() { int a; char ch; for(a=1;a<=52;a++) { scanf("%c",&ch); printf("%d\n",ch); } return 0; }
C
//Nazwa: Zad5L2.c //Autor: Jakub Filistyński #include <stdio.h> #include <stdbool.h> bool NWD(int a, int b) { int q = a%b; while(q != 0){ a = b; b = q; q = a%b; } if(b == 1) return true; return false; } void spr(int n, int *licznik) //liczby ile jest par liczb względnie pierwszych { (*licznik)++; for(...
C
#include <unistd.h> #include <error.h> #include <stdio.h> // rm :removes the argument files given by calling unlink int main(argc, argv) int argc; char* argv[]; { while( --argc) { printf("removing ...%s\n",argv[argc]); if(unlink(argv[argc]) == 0) printf("%s :removed !\n",argv[argc]); else perror(argv[ar...
C
/* * 矩阵的加减乘除还有转置 * 矩阵的形式:row,col,value;使用三元表的形式定义一个矩阵,尤其是对于这个矩阵是 * 稀疏矩阵,节省空间。 * * 三元表:[0].row:代表矩阵总的行数 * [0].col:代表矩阵总的列数 * [0].value:代表矩阵的非零项的个数 */ #include <stdio.h> // 构建最大的矩阵大小为15*15 #define MAX 15 #define MAX_RANK 15 #define RANK 15 #define IS_MAX(x,y) ((x)>(y)?x:y) typedef struct{ int row; int ...
C
#include "ft_printf.h" #define REMOVE_FLAG(F) ((*specs).flags &= ~F) static void preprocess(t_spec *specs, char *arg) { REMOVE_FLAG(FLAG_PLUS); REMOVE_FLAG(FLAG_HASH); REMOVE_FLAG(FLAG_SPACE); (void)arg; if ((*specs).width < 0) { (*specs).flags &= FLAG_MINUS; (*specs).width = twos_complement((*specs).widt...
C
#include <stdio.h> #include <stdlib.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ void main() { float x,y; float op; char z; printf("please enter the operator\n"); scanf("%c",&z); printf("please enter Number_1\n"); scanf("%f",&x); printf("please...
C
#include <stdlib.h> #include <stdio.h> /** * A node of the binary tree containing the node's integer value * and pointers to its right and left children (or null). */ struct Node { struct Node *left; struct Node *right; int value; }; /** * Create a new node with no children. */ struct Node* create (i...
C
/* ** fix24.c ** ** fix24 functions moved here from fix.c ** ** see fix.c for descriptions ** ** $Header: r:/prj/lib/src/fix/rcs/fix24.c 1.1 1994/08/11 12:12:11 dfan Exp $ ** $Log: fix24.c $ * Revision 1.1 1994/08/11 12:12:11 dfan * Initial revision * */ #include <fix.h> #include <trigtab.h> fix24 fix24_pyth_d...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* algo.c :+: :+: :+: ...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdint.h> // uint64_t #define max(a,b) ((a) > (b) ? (a) : (b)) #define min(a,b) ((a) > (b) ? (b) : (a)) int get_int2(int *a1, int *a2) { scanf("%d %d", a1, a2); return 0; } // <arr[0]> <arr[1]> .. <arr[size-1]> int fget_array(int *arr, int size...
C
#include <stdio.h> int contapessoas(int lugs[50]) { int i; int npess=0; for (i=0;i<50;i++) { npess=npess+lugs[i]; } return npess; } int main() { int lugar[50],n,m; int i,lugactual; int psaltadas; do{ printf("Digite o numero de Pessoas N\n"); scanf("%d",&n); ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* asm_getters2.c :+: :+: :+: ...
C
/* rand all is too large, so rand each step if size > 13 */ /* /\* idea copy form 46 permutations, 47 permutations II *\/ */ typedef struct { int size; int all; int* ori; } Solution; Solution* solutionCreate(int* nums, int size) { Solution* s = malloc(sizeof(Solution)); s->all = 0; s->size = si...
C
//get user input #include <stdlib.h> #include <stdio.h> #include "../includes/getIt.h" char *getIt(){ char *input = malloc(sizeof(char) * 100); printf("Enter the values for a, b and c of the quadratic equation [q to quit program]: "); fgets(input, sizeof(char) * 100, stdin); return input; }
C
/* * task_add.c * * Created on: 2015114 * Author: kohill */ #include <stdint.h> #include <stdlib.h> #include "task.h" typedef struct { uint32_t r0; uint32_t r1; uint32_t r2; uint32_t r3; uint32_t r4; uint32_t r5; uint32_t r6; uint32_t r7; uint32_t pc; } InitialStack; uint32_t task1_stack[STACK_SIZE...
C
//Description: Find Area and Perimeter of Ring //Date: 23/09/2021 //Author : Shubham Lodha #include<stdio.h> #define Pi 3.14 void Ring(int a,int b) { int ans=0; ans=Pi*(a*a-b*b); printf("Area of Ring is %d\n",ans); ans=2*Pi*(a+b); printf("Perimeter of Ring is %d\n",ans); } int...
C
#include <stdio.h> //Compiler version gcc 6.3.0 int main() { int a,b; printf("enter two numbers"); scanf("%d", &a); scanf("%d", &b); printf("%d", a); printf("%d", b); printf("\n"); a=a+b; b=a-b; a=a-b; printf("%d", a); printf("%d", b); }
C
/* ** EPITECH PROJECT, 2019 ** Dante_generator ** File description: ** Dante_generator */ #include "include/my.h" #include "generator.h" int random_between(int minimun, int maximum) { return (rand() % (maximum - minimun + 1) + minimun); } int *count_unvisited_sq(gen *lab, int i, int j) { int *coord; if (...
C
/* ============================================================================ Name : crc_example.c Author : Marcin Version : Copyright : Your copyright notice Description : crc example in C, Ansi-style ============================================================================ */ #include ...
C
/* c: jarowinkler.c * Copyright (C) 2011 Miguel Serrano * * 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 * (at your option) any later version. * * Th...
C
#include<stdio.h> #include<stdlib.h> #include<pthread.h> #include<unistd.h> #include<stdbool.h> int biglietti_c = 30; pthread_mutex_t m1 = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t m2 = PTHREAD_MUTEX_INITIALIZER; void *casse(void* argv){ int biglietti; if(pthread_mutex_lock(&m1) == 0){ printf("CA...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_printf.c :+: :+: :+: ...
C
#include<stdio.h> #include<conio.h> void main() { float n=5.6; float *p; p=&n; printf("\nAddress of n is : %u",&n); printf("\nAddress of n is : %u",p); printf("\nValue of p is : %f %f %f",n, *p, *(&n)); getch(); }
C
typedef struct heap_entry heap_entry; #define NULL ((void*) 0) struct heap_entry{ int size; void* addr; heap_entry* next; }; heap_entry *free_head = NULL; heap_entry *alloc_head = NULL; heap_entry alloc[1000]; heap_entry* mmlist_next_slot() { int i = 0; while(1) { if(!alloc[i].addr) { return ...
C
#ifndef FLIB__H #define FLIB__H #include <stdlib.h> #include <stdio.h> //return a pointer to an array of c strings, the last element should be zero // this will list the name of each file in the path char** fl_list(const char* path); //same as fl_list except the files returned must start with prefix // and end with su...
C
/*------- Question-[01] : Program for create student record -----*/ #include<stdio.h> #include<string.h> struct student { struct { char fname[20]; char mname[10]; char lname[10]; }name; int roll_no; int marks_obtained; }arr[10]; int main() { int n; printf("...
C
// activar en casos de debug #define DEBUG_INSERTAR FALSE Nodo obtener_raiz() { return leer_nodo(rtree_root); } /** Busca un nodo hoja según el rectángulo rect. Ocupado en @insertar(Nodo, Rectangulo) */ Nodo encontrar_hoja(Nodo nodo, Rectangulo rect) { // Si el nodo es un nodo hoja (i.e. si sus MBR apu...
C
#include <stdio.h> #define P(func, args...) {\ printf ("%s = %d\n", #func, func(args));\ } int binary_search1(int *num, int n, int x) { int head = 0, tail = n - 1, mid; while (head <= tail) { mid = (head + tail) >> 1; if (num[mid] == x) return mid; if (num[mid] < x) head = mid + 1;...
C
#include "roybit.h" uint64_t roy_uint_set_bits(uint64_t * dest, uint64_t src, size_t position, size_t count) { return *dest = (*dest & ~(~(~0ULL << count) << (position + 1 - count))) | ( src & ~(~0ULL << count) << (position + 1 - cou...
C
#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> #include <stdlib.h> #define N 3 void print_arr(int *arr) { int i, j; for (i = 0; i < N; i++) { for (j = 0; j < N; j++) { printf("%d ", arr[i*N + j]); //i*+j } printf("\n"); } } void find(int arr[][N],int *px,int *py,int num ) { while (*px ...
C
#include <stdio.h> #define MAX_NUM 100 #define MIN_NUM 1 int main(void) { // creating veribals int num = 0; // do block asks for a num //and after thet while block that will work if num is incorect do { printf("Please enter number between 1-100:\n "); scanf("%d", &num); } ...
C
/* * Description: This file is create for testing mbedtls(2.1.1) * DES encryption algorithm on 32-bit linux */ #include "mbedtls/des.h" #include <stdio.h> #include <stdlib.h> //#define CADL_DEBUG int main(int argc, char **argv) { unsigned char key[8] = {0x13, 0x34, 0x57, 0x79, 0x9b, 0xbc, 0xdf, 0xf1}; unsi...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.c :+: :+: :+: ...
C
#include<stdio.h> int main() { float a; int count=0,i; for(i=0; i<6; i++) { scanf("%f",&a); if(a>0) count++; } printf("%d valores positivos\n",count); return 0; }
C
#include <stdio.h> #include <stdlib.h> /* observed component */ typedef struct { int listener_count; /* array of function pointers */ void (*listener_list[10])(unsigned,unsigned); } Button; void button_Init( Button *pButton ) { pButton->listener_count = 0; } void button_RemoveClickListener( Button *pButton, ...
C
#include <stdio.h> #include <stdbool.h> int ehprimo(n) { int i; for (i=2; (i<n) && (n%i != 0);i++) ; return (n>1 && i>=n); } int main() { long n, i=1, cont=0; printf("Informe o numero de ordem do primo: "); scanf("%d", &n); while (cont < n) { i++; if (ehprimo(i)) cont++; ...
C
/* ** EPITECH PROJECT, 2020 ** my_convertbase.c ** File description: ** convert base */ #include <stdarg.h> #include "includes/my_print.h" int convert_hexa(va_list *ap) { unsigned int nb = va_arg(*ap, unsigned int); int count = 0; count = count + convert(nb, "0123456789abcdef"); return (count); } i...
C
//Set the position of the sonar servo void setServo(const int angle) { long dutyCycle = map(angle, 0, 180, 1675, 8050); ledcWrite(10, dutyCycle); } // the main function to be run to call the ultrasound void Navigation() { long currentTime; static long lastTime; const int USinterval = 100; //how of...
C
#include <stdio.h> #define N 20 typedef struct Stack{ int value[N]; int top; }Stack; int isFull(Stack *s) { if(s->top==N) return 1; else return 0; } int isEmpty(Stack *s) { if(s->top==0) return 1; else return 0; } void push(Stack *s,int x) { if(!isFull(s)) { s->va...
C
/* * csvreader.c * * * Created by W. Ross Morrow on 7/2/13. * Copyright 2013 Iowa State University. All rights reserved. * */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <vecLib/cblas.h> #include "csvreader.h" #define BUFFER_SIZE 1024 void CSVReader(char * fnm...
C
#include <stdbool.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h> #include <sys/time.h> #define CPX_USE_LONG_DOUBLE #include "complex.h" #define SDL_MAIN_HANDLED #include <SDL2/SDL.h> //#include "SDL2/SDL_thread.h" // ------------------------------------------------------------------...
C
/* map.c */ #include <SDL.h> #include "../log.h" #include "map.h" #include "map_mzm3.h" int map_size_x = -1; int map_size_y = -1; map_tile_t *map_data = NULL; SDL_bool map_load(char* filename) { FILE *f; SDL_bool result = SDL_FALSE; f = fopen(filename, "rb"); if(f == NULL) return result; /* Look through the...
C
#include "platform.h" #define DEF_SERIALPORT "/dev/ttyS1" int serialport_open2(const char* name,int flags){ if(!name) name = DEF_SERIALPORT; return open(name,flags); } int serialport_open(const char* name){ return serialport_open2(name,O_RDWR | O_NOCTTY | O_NDELAY); } int serialport_close(int fd){ if(fd>0) cl...
C
#include <stdio.h> printd(n) /* print n in decimal (recursive) */ int n; { int i; if (n < 0) { putchar('-'); n = -n; } if ((i = n/10) != 0) printd(i); putchar(n % 10 + '0'); }
C
#include <stdio.h> #include <stdlib.h> struct Stack { int size; int top; int *A; }; void push(struct Stack *st, int x) { if (st->top == st->size - 1) { printf("Stack Overflow!"); return; } else { st->top++; st->A[st->top] = x; } } int pop(struct Sta...
C
#include "stack.h" #include <stdlib.h> #include <assert.h> extern Stack stack_new(int elementSize) { Stack s = list_new(elementSize); return s; } extern void stack_destroy(Stack *stack) { assert(stack && *stack); list_destroy(stack); free(*stack); *stack = NULL; } extern void* stack_push(Stack stack, voi...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/typ...
C
/** Header file for IR Generator * ======================================================================== * * Defines functions used to generate the intermediate representation based * off the parse tree * * When describing the parse tree, the description for a 3 level parse tree * graphically represented ...
C
#define BUILDING_FDSP 1 #include <stdint.h> #include <stdlib.h> #include <string.h> #include <math.h> #include "fdsp.h" typedef union _f32 { float f; uint32_t i; } _f32; FDSP_EXPORT void vector_fmul_c(float *dst, const float *src0, const float *src1, unsigned int len) { unsigned int i; for (i = 0; i <...
C
/* ======================================================== * Copyright (C) 2014 All rights reserved. * * filename : dp.c * author : liuzhiqiang01@baidu.com * date : 2014-12-08 * info : dtw and lcss * ======================================================== */ #include <stdlib.h> #include...
C
#include<stdio.h> #include<stdlib.h> #include<stdio.h> #include "fs_main.h" int main(){ char data[8]; FILE *file = NULL; char * env_path = "./test.txt"; int result; // file = mul_fs_fopen(file,env_path,"w+"); // mul_fs_fwrite(file,env_path,"Environment = "); // mul_fs_fwrite(file,env_pat...
C
// // main.c // OS_Project2 // // Created by JongEun Kim on 2021/04/19. // #include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, const char * argv[]) { int p_num = 0; // 프로세스 개수 int r_type_num = 0; // 리소스 종류 개수 int tmp = 0; // 임시 int blockcheck = 0; // 0 = block, 1 = u...
C
#include<stdio.h> int main() { int i[10],j=0,num=0,sum=0,temp,k=0; float av; printf("Please enter a number\n"); while(1) { scanf("%i",&i[j]); if(i[j]<=0) break; else { num++; sum = sum+i[j]; } j++; } av = (float)sum/num; printf("Number = %d\n",num); printf("Average = %f\n",av); while(k<n...
C
// 8. Faça um programa em C que leia dois números inteiros e imprima a subtração deles. #include <stdio.h> int main() { int firstNumber = 0, secondNumber = 0, subtractionResult = 0; printf("Enter the first integer: "); scanf("%d", &firstNumber); printf("Enter the second integer: "); scanf("%d", &secondNum...
C
#include <stdio.h> #include <stdlib.h> #include "17_queueADT.h" #define INIT_CAPACITY 100 struct queue_type{ Item *contents; //배열 <- 포인터 선언했다는 건, 이 배열도 동적메모리 할당으로 받는다는 의미 int front; int rear; int size; //저장된 데이터 개수 int capacity; //배열 content의 크기 }; void terminate(const char *message){ print...
C
/*****************************************************************************/ /** * * @file xpmon_be.h * * This file contains the data required for the interface between the * xpmon GUI and the xdma driver. * * The Xilinx Performance Monitor GUI (xpmon) contacts the DMA driver (xdma) * in order to start/stop a packet...
C
/* * ICT1002 Assignment 2, 2018-19 Trimester 2. * * This file implements the chatbot's knowledge base. * * knowledge_get() retrieves the response to a question. * knowledge_put() inserts a new response to a question. * knowledge_read() reads the knowledge base from a file. * knowledge_reset() erases all of the ...
C
#define LOCAL #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #define MAXN 1010 int map[MAXN][MAXN]; int n; int max_in_3 (int row, int col){ int max = -MAXN; for(int i = row; i < row+3; i++) { for(int j = col; j < col+3; j++) { if(map[i][j] > max) ...
C
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <semaphore.h> #include <unistd.h> #include <string.h> sem_t mutex; struct info { char* filename; char* interface; }; void * capture(void* parameter) { struct info *p =parameter; char command1[100], command2[100]; strcpy(command1, "sudo ...
C
#include "holberton.h" /** * flip_bits - # of bits you would need to flip to get fr one # to another * @n: takes in an integer * @m: takes in the 2nd integer to compare * Return: number of bits */ unsigned int flip_bits(unsigned long int n, unsigned long int m) { int con, index; unsigned long int num; index = ...
C
#include<stdio.h> main() { int n,i,t1=1,t2=1,t; scanf("%d",&n); for(i=1;i<=n;i++) { printf("%d",t1); t=t1+t2; t1=t2; t2=t; } }
C
//Mohamed Insaf #include <stdio.h> void main() { int i; void *pFrom="Hello",*pTo[10]; copy(pFrom,pTo,4); } void copy(void *pFrom, void *pTo, int nBytes) { int i; for(i=0;i<nBytes;i++) { *(pTo+i)=*(pFrom+i); } }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_create_group.c :+: :+: :+: ...
C
#ifndef __UTILS_H__ #define __UTILS_H__ char *puts( const char* s ); char *gets( char *s ); int putchar( const int c ); int getchar( void ); int printf(const char* format, ...); int strlen(const char *s); char *strcpy(char *s1, const char *s2); char *strcat( char *dst, char *src); int strncmp(const char *str1, const c...
C
#include <stdio.h> int main() { int a; scanf("%i", &a); if (a > 1000) printf("Big\n"); }
C
#include<stdio.h> #include<conio.h> #include<math.h> #include<float.h> #include<stddef.h> #define pi 3.142 main() { int radius,area,circ; printf("enter the radius of circle:\n"); scanf("%d",&radius); area=pi*radius*radius; circ=2*pi*radius; printf("area = %d\ncircumference = %d ",area,circ); getch(); re...
C
/* * File: node.h * Author: mederic * * Structure and methods for a theory graph node * * Created on 18 novembre 2011, 16:03 */ #ifndef NODE_H #define NODE_H struct Node { int id; /* value of the node */ int tag; /* id of a connected graph */ int x; ...
C
#include<stdio.h> #define N 10 int q[N]; int a[N]; int top=-1; int f=-1; int r=-1; void enqueue(int val) { if(r>=N-1) printf("Queue overflow\n"); else if(r==-1 && f== -1) { f=r=0; q[r]=val; } else { r++; q[r]=val; } } int dequeue() { int tmp=0; if(f==-1) printf("queue underflow\n"); tmp=q[f]; i...
C
// put implementations for functions, explain how it works // put your names here, date #include <stdint.h> #include "tm4c123gh6pm.h" void ADC_Init(void){ volatile uint32_t delay; SYSCTL_RCGCGPIO_R |= 0x10; // 1) activate clock for Port E while((SYSCTL_PRGPIO_R&0x10) == 0){}; GPIO_PORTE_DIR_R &= ~...
C
#include"headFile.h" void souMaskInit(struct source *sou,int nPos, int iPos) { unsigned int iSou; int NX; int NY; int NZ; NX = sou[iPos].NX; NY = sou[iPos].NY; NZ = sou[iPos].NZ; sou[iPos].souMask = (int *)malloc(sizeof(int)*NX*NY*NZ); for(iSou = 0; iSou < NX*NY*NZ; iSou ++) ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* st_B_markirovka.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/fcntl.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/types.h> #include <sys/uio.h> #include <unistd.h> #include <netinet/in.h> #include <netdb.h> #include <arpa/inet.h> #include <time.h> #include "my_protocol.h" #include <errno.h>...
C
// // Created by ali on 28.12.2020. // #include "math_operations.h" void div_by_scalar(const fp_t *input_channel, const uint16_t height, const uint16_t width, const fp_t denominator, fp_t* output_channel){ // a division by scalar layer for (int i=0; i<height*width; i++) output_channel[i] = input_chann...
C
// This code does not translate properly without the relooper int switch_val(int val) { switch (val) { case 1: return 2; case 2: return 4; default: return val + 1; } }
C
#include<stdio.h> void hanoi(int n,char x,char y,char z){ if(n==1){ printf("%c->%c\n",x,z); } else{ hanoi(n-1,x,z,y); printf("%c->%c\n",x,z); hanoi(n-1,y,x,z); } } int main(void){ int n; printf("请输入dish数目:"); scanf("%d",&n); hanoi(n,'A','B','C'); retur...
C
#include "function_pointers.h" /** * int_index - search for an integer * @array: the array to search * @size: the number of elements in the array * @cmp: the function to use to compare values (returns non-zero upon a match) * * Return: If no match is found or size is less than 1, or if array is NULL or * cmp is...
C
#include <math.h> void rotar_c ( unsigned char *src, unsigned char *dst, int h, int w, int src_row_size, int dst_row_size ) { unsigned char (*src_matrix)[src_row_size] = (unsigned char (*)[src_row_size]) src; unsigned char (*dst_matrix)[dst_row_size] = (unsigned char (*)[dst_row_size]) dst; int i, j, ...
C
#ifndef STACK_H #define STACK_H typedef struct tagStack { char cKey; //value tagStack* pNext; //pointer to the next element } Stack; Stack* InitStack(); void RemoveStack( Stack** pStack ); void push( char c, Stack** pStack ); char pop( Stack** pStack ); char top( Stack* pStack ); void del( Stack** p...
C
/* * Performance testing version * 04Apr2012 * */ #ifndef __CUDA__ #define __NO_CUDA__ #endif //===========================Include code====================================== #include "rainbow.h" #include "table_utils.h" #include "freduce.h" #include "fname_gen.h" #include "md5.h" #include <math.h> #include <st...
C
#include <iostream.h> // main: generate some simple output int main () { cout << "Hello, world." << endl; // output one line cout << "How are you?" << endl; // output another return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include "except.h" Except_T Allocate_Failed = { "Allocation failed" }; void *allocate(unsigned n) { void *new = malloc(n); if (new) return new; RAISE(Allocate_Failed); assert(0); } int main() { char *buf; ...
C
#include <stdio.h> int main() { int length, width, area; printf("Enter the length : "); scanf("%d", &length); printf("Enter the width : "); scanf("%d", &width); area = rarea(length, width); printf("The area of the rectangle : %d", area); } int rarea(int length, i...
C
#include <stdio.h> #include <stdlib.h> char matrix[3][3]; char smbfua; char smbfub; void at_the_first() //To initialize matrix with all Zeors { int r=0,t=0; for(r;r<3;r++) { t=0; for(t;t<3;t++) { matrix[r][t]='0'; } } } //End of ititializeing...
C
#include <stdio.h> #define DEV DEV; void quickSort(int numberArray[], int left, int right); void swap(int *a, int *b) { int temp = *a; *a = *b; *b = temp; } int partition(int numberArray[], int left, int right) { int pivotIndex = left; int pivot = numberArray[pivotIndex]; printf("ǹ : %d\n", pivot); ++left; /...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> int main(){ char cadeia[51]; // Variavel para armazenar a cadeia de caracteres int qtd, // Variavel para armazenar a quantidade de caracteres num, // Variavel para armazenar o numero aleatorio i; // Conta...
C
#include <stdio.h> int main() { char q1, q2, q3, q4; int acertos = 0; scanf("%c\n%c\n%c\n%c", &q1, &q2, &q3, &q4); if(q1 == 'd') { acertos++; } if(q2 == 'a') { acertos++; } if(q3 == 'c') { acertos++; } if(q4 == 'd') { acertos++; } switch(acertos) { case 0: printf...
C
//aom #include<stdio.h> void main() { int i,j,a,num,aom; system("clear"); printf("In put :"); scanf("%d",&num); printf("\n"); for(i=num;i>=1;i--) { for(j=num;j>=i;j--) { if(j>i) { printf(" "); } else { aom=num...
C
#include <stdio.h> //main函数的标准写法二 //argc是通过命令行传递的参数的个数 //argv是指向argv[0](它的类型是char*)的元素的指针,它的类型是char** int main(int argc, char *argv[]) { printf("argc = %d\n", argc); int i = 0; for (; i < argc; i++) { printf("argv[%d] = %s\n", i, *(argv + i)); } return 0; }
C
#include <stdbool.h> #include <stdio.h> #include "validator.h" bool validateRange(Validator *p, int val) { RangeValidator *pThis = (RangeValidator *)p; return pThis->min <= val && val <= pThis->max; } bool validatePrevious(Validator *p, int val) { PreviousValueValidator *pThis = (PreviousValueValidator *)...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* arg_hex.c :+: :+: :+: ...
C
/* Function that checks if a string contains only upper-case alphabetical characters */ #include "my_functions.h" int string_upper(char *s) { int i; i = 0; while(s[i] != '\0' && (s[i] >= 'A' && s[i] <= 'Z')) { i++; return (1); /* True */ } else if { return (0); /* False */ } ...
C
#include <stdio.h> #include <math.h> int binaryToDecimal(int n); int decimalToBinary(int); int main() { int dec[4], bin[4]; printf("Enter IP address in decimals : "); scanf("%d.%d.%d.%d", &dec[0], &dec[1], &dec[2], &dec[3]); for (int i = 0; i < 4; i++) { bin[i] = decimalToBinary(dec[i]); printf("%08d.", bin...