language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
char uup(char c) { if (c>=97) c-=32; return(c); } void main() { char arr[40]={0},brr[40]={0}; int n,m,i,j,k; int a[40]={0},b[40]={0}; scanf("%d%s%d",&n,arr,&m); i=strlen(arr); for (k=0;k<i;k++) {if(uup(arr[k])>58) a[i-k-1]=uup(arr[k])-'A'+10; else a[i-k-1]=arr[k]-'0';} //if (n>30)printf("...
C
/* * ppm.c * * Copyright (c) 2014 Jean Guyomarc'h */ #include "ppm.h" static inline int _str2int(const char *str) { return strtol(str, NULL, 10); } Col * ppm_parse(const char *file, int *w_ret, int *h_ret) { FILE *f; Col *ptr = NULL; char buf[16]; int c, k = 0, i ...
C
#include <countingelements.h> /* * PermCheck * Check whether array A is a permutation. * * solution * A - array to check * N - length of array * */ int check_if_permutation(int A[], int N) { int result = 1; int B[N]; for (int i = 0; i < N; i++) { B[i] = 0; } for (int i = 0; i ...
C
#include<stdio.h> #include<malloc.h> #include<stdlib.h> #include<string.h> typedef struct tree_node_s { float frequency; char c; char code[128]; struct tree_node_s *left; struct tree_node_s *right; } tree_node_t; tree_node_t *arr[26], *letters[26]; void findMinAndSecondMin(tree_node_t ...
C
#include <pthread.h> #include <stdio.h> #include <stdlib.h> #define TAM_BUFFER 64 #define NTHREADS 4 #define MILLON 1000000 int buffer[TAM_BUFFER]; int p; pthread_mutex_t m; void *imprimir(void *p_numero) { int minumero = *((int *) p_numero); while(p < TAM_BUFFER) { pthread_mutex_lock(&m); if(...
C
#include "pub.h" #include <stdio.h> #include <stdarg.h> #include <string.h> #include <signal.h> #define LOG_BUF_LEN 2048 void ReleasePrint(const char* LEVEL, const char* funcName, const char* fileName, int line, const char* format, ...){ va_list args; va_start(args, format); char vsp_b...
C
#include<stdio.h> #include<string.h.> #include<windows.h> #define LEN 5 char* mystrncpy(char*, char*, unsigned); int main(void) { char* receive; char s1[LEN]; char s2[LEN]; printf("Enter a string:"); for (int i = 0; i < LEN; i++) { s1[i] = getchar(); if (s1[i] == '\n') { s1[i] = '\0'; s1...
C
/* Capstone Disassembler Engine */ /* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013> */ #include <stdio.h> #include <capstone.h> void print_string_hex(char *comment, unsigned char *str, size_t len); static const char* get_bc_name(int bc) { switch(bc) { default: case PPC_BC_INVALID: return ("invalid"); case...
C
/* libnih * * Copyright © 2009 Scott James Remnant <scott@netsplit.com>. * Copyright © 2009 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, as * published by the Free Software Foundation. * * This program ...
C
#include "stm32f4xx.h" #define osObjectsPublic #include "osObjects.h" // Variables osThreadId send_Thread; char array[10] , array_byte; int16_t array_Cnt = 0; // Function Prototype void config_Hardware_LEDs(void); void config_UART4(uint32_t BaudRate, int16_t Priority , int1...
C
/* * prvocisla.c * Rieenie IJC-DU1, prklad b) 21.3.2011 * Autor: Peter Lacko, FIT * Preloen: GCC 4.5.2 */ #include<stdio.h> #include<stdlib.h> #include<math.h> #include<limits.h> #include"error.h" #define N 90000000L #define PRINT 20 #define LONG_S (sizeof(unsigned long)*CHAR_BIT) // vytvori pole typu unsigned ...
C
#include<stdio.h> char* reverse(char *s){ int l,i; for(l=0;*(s+l)!='\0';l++); for(i=0;i<l/2;i++){ char t; t=*(s+i); *(s+i)=*(s+l-i-1); *(s+l-i-1)=t; } return(s); } void main(){ char a[99]; printf("ENTER THE STRING WHICH U WANT TO REVERSE USING POINTER\...
C
///************************************* // * Purpose: Timer0 ̿ OC0A(PD6) PWM // * // * // *************************************/ #include <avr/io.h> #include <avr/interrupt.h> #include <util/delay.h> #include "timer0.h" // from TCNT = (CS / 16000000 ) * (256-x) =10msec // x = time * (16000000/CS) // if cs = 1024 // ...
C
#include "holberton.h" /** * flip_bits - determine the number bits to flip * @n: first int value * @m: value to convert to * Return: number of bits to flip to change from one number to another */ unsigned int flip_bits(unsigned long int n, unsigned long int m) { unsigned int num_dif, num_bits = 0; if (n == 0 &...
C
//pthread_create方法演示--线程参数传递 #include <pthread.h> #include <stdio.h> #include <unistd.h> void *thread1(void *p) { int *id = p; while (1) { printf("thread1 is running!\tID = %d\n", *id); sleep(1); } } void *thread2(void *p) { char *str = p; while (1) { printf("thread...
C
#include <getopt.h> #include <dirent.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> #include "options.h" #include "file_type.h" static int parse_types(const char *types, struct args *args) { size_t len, i; int mask; len = strlen(types); mask = 0; for (i = 0; i < len; i += 1...
C
#include "a3_1.h" pthread_t *philo_id; pthread_mutex_t *chopstick; int num_phil; int eat_times; int main(int argc, char** argv){ void *return_val; if(argc < 3){ perror("Please enter the number of philosophers and the length of time it takes to eat.\n"); } else { num_phil = atoi(ar...
C
#pragma once #include "dc_motor.h" #include "servo_motor.h" #include <Arduino.h> struct MovementMotors { MovementMotors(){}; MovementMotors(DCMotor leftFront, DCMotor leftBack, DCMotor rightFront, DCMotor rightBack, DCMotor launching, DCMotor ballLifter ,ServoMotor ballStopperR,ServoMotor ballStopperL) { leftFro...
C
#include <gdk/gdk.h> #include <glib.h> GMainLoop* g_mainloop; void event_func(GdkEvent *event, gpointer data); int main (int argc, char **argv) { // Init GDK if (!gdk_init_check (&argc, &argv)) { return 7; } // Setup event handler gdk_event_handler_set(event_func, NULL, NULL); ...
C
#include <stdio.h> #include <stdlib.h> int main(void) { system("clear"); //usa una lista di inializzatori per inializzare l'array n int n[5] = {32, 27, 64, 18, 95}; printf("%s%13s\n", "Elemento", "Valore" ); //invia in uscita i contenuti dell'array n in formato tabellare for (size_t i = 0; i < 5; ++i) { printf("...
C
void tableB(int no) { int i=0,j; for(i=1;i<=10;i++) { for(j=1;j<=no;j++) { printf("%dx%d=%d\t",j,i,i*j); } printf("\n"); } }
C
#include <stdio.h> #include <stdlib.h> struct Student { char name[120]; unsigned int age; }; int N;//this is a "Global Variable" struct Student* inputStudent() {//this is a function printf("Enter number of students: "); scanf("%d", &N); struct Student* student = (struct Student *)malloc(N * sizeof(stru...
C
#ifndef TIMER_H #define TIMER_H #include <stdint.h> #include <avr/io.h> #include <avr/interrupt.h> /** * @file * @brief NODE2 Driver to handle timer interrupts */ volatile uint8_t controller_interrupt; /** < @brief variable to check if timer_interrupt have been triggered, val = 1 if triggered */ volatile uint8_t I...
C
// Keeps track of key states for things like keyHit to work #include <GLFW/glfw3.h> #include "advinput.h" #define MOUSE_SINGLE 1 #define MOUSE_DOUBLE 2 #define MOUSE_NUM_BUTTONS 5 #define MOUSE_DOUBLE_INTERVAL 0.250 static unsigned char keyReleased[350]; static unsigned char mouseIsClicked[MOUSE_NUM_BUTTONS]; static ...
C
/* Felipe 04/04/2018 Calculo da rea do Circulo */ #include<stdio.h> #include<stdlib.h> int main(){ float salarioreajustado; float salario; int idade; //entrada printf("forneca o salario R$ "); scanf("%f", &salario); printf("forneca a idade ","anos"); scanf("%d", &idade); //processament...
C
#include <stdio.h> int a[4][4], score; char op; void rotate(); void move_left_without_merge(); void move_without_merge(char op); void print(); int main(){ for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ scanf("%d", &a[i][j]); } } print(); scanf("%c", &op); ...
C
/** * * file: motors.c * author: Daniel Heise * description: implementation for operating the stepper motors * */ #include "motors.h" #include "sensors.h" #include "driver-boards.h" /** * function: move * description: initialization of the universal synch/asynch rx/tx reg...
C
#include<stdio.h> #include<stdbool.h> #define MAXN 2005 bool f[MAXN][MAXN]; int n; void init(){ int i=0,j; for(;i<n;++i){ for(j=0;j<n;++j){ f[i][j]=false; } f[i][i]=true; } } bool is_friend(int a,int b){ //if f[a][b]=true, person a and per...
C
// // Created by me_touch on 20-11-6. // /* * 实现 strStr() 函数。 给定一个 haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 (从0开始)。如果不存在,则返回  -1。 示例 1: 输入: haystack = "hello", needle = "ll" 输出: 2 示例 2: 输入: haystack = "aaaaa", needle = "bba" 输出: -1 说明: 当 needle 是空字符串时,我们应当返回什么值呢?这是...
C
/* ### Example #### *************************************************************************************************** * A simple example to show the setting up and usage of Photo Interupter. * It can also be used to trigger a relay/switch by a simple addition of 1 output pin connected * to the switch/relay ...
C
#include "utils.h" /** * TODO: Convert upper case to lower case * Modify the given string mapping all characters in [A-Z] to [a-z]. */ void str_to_lowercase(char *s){ for(int i=0; s[i]!='\0'; i++){ if(s[i]>='A' && s[i]<='Z'){ s[i] = s[i] + 32; } } } /** * Function strsep is not...
C
/* * File: gmath.h * ------------- * This file exports the constant PI along with a few degree-based * trigonometric functions, which are typically easier to use than * their radian-based counterparts in <cmath>. */ #ifndef _gmath_h #define _gmath_h /* Constants */ extern const double PI; /* The mathe...
C
#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> void BubbleSort(int arr[], int len) { int i, j; int tem; for (i = len - 1; i > 0; i--) { for (j = 0; j < i; j++) { if (arr[j] < arr[j + 1]) { tem = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = tem; } } } } int main() { int n = 0; int ...
C
#include <sys/types.h> #include <sys/wait.h> #include <stdio.h> int main() { pid_t pid; int option, stat; while(1) { printf("Enter 1 to exec 'ls' program in child process and 0 to exit\n"); scanf("%d", &option); if(!option) exit(0); printf("\n"); if(fork()==0) { execl("/bin/ls","ls","-l",0); e...
C
#include<stdio.h> void main() { int i,j,a[50],n,t,x,y; printf("enter the value"); scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a[i]); } for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { if(a[i]>a[j]) { t=a[i]; a[i]=a...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #define ENDLIST(p,n,r) for(p=r; p->n; p=p->n) #define FORLIST(p,n,r) for(p=r; p; p=p->n) #define LINK(p,n,r,t) if(!r)r = p = NEWNODE(t);\ else{ ENDLIST(p,n,r); \ if( (\ p->n = NEWNODE(t)\ ) == NULL){fprintf(stderr,"\nPOLISH: CALLOC FAILED!\...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #include<string.h> //実行時点で2つのファイルと一緒に実行する。 int a[10]; int b[10]; int c[10]; int d[10]; int i=0,h=0,t,death1=0,death2=0,death3=0,death4=0; int recovery1,recovery2,n1=0,n2=0,run1,run2,value1=0,value2=0; struct status{ char name[20]; int hp; int kougeki; int ...
C
#include <stdio.h> #include <stdlib.h> #include "include/sqlite3.h" static int callback(void *notUsed, int argc, char **argv, char **azColName); int main(void){ sqlite3 *db; char *zErrMsg = 0; int rc; // return code const char * databaseFile = "test.db"; const char * sqlScript = "SELECT * FROM Bo...
C
#include <stdio.h> #include <fcntl.h> #include <io.h> unsigned char b[9 * 512]; extern readsec(unsigned, unsigned, void *); extern recal(); main(argc, argv) int argc; char *argv[]; { int i, j, cnt, time, this; int handle, trk, sec, len; if((handle = open(argv[1], O_CREAT | O_WRONLY | O_BINARY)) == ...
C
#include "monty.h" /** * add - adds two first elements of a list * @head: pointer to the head * @count: line number */ void add(stack_t **head, unsigned int count) { stack_t *ptr = *head; int num = 0; if (head != NULL && ptr != NULL && ptr->next != NULL) { num = ptr->n + ptr->next->n; pop(head, count); ...
C
#include <hal.h> #include "e_uart_char.h" #include "../usbcfg.h" void e_init_uart1(void) { return; } /*! \brief Check if something is comming on uart 1 * \return the number of characters available, 0 if none are available */ int e_ischar_uart1(void) { // To be implemented! return 0; } int e_getchar_uart1(char ...
C
/* ========================================================================================= */ /* File: countersTest.c * Project: Tiny Seach Web Engine * Author: Ying Liu * Date: 2/9/2017 * The file is used to test the counters.c After running the file use valgrind --leak-check=full --show-leak-kinds=all ./coun...
C
/****************************************************************************** Identificacion: rut_fecha.c Nombre : rut_fecha Autor: Gerardo Uriel Gamez Torres ( Banamex/ISD ) Instalacion: BANAMEX, S.A. Fecha: 20/dic/1999 Version: 1.0 *********************************************************************...
C
#include<stdio.h> #include<conio.h> #include<math.h> void arm(){ int n,s=0,d=0,p,k; printf("enter your number\n"); scanf("%d",&n); for(p=n;p!=0;p=p/10){ d++; } for(p=n;p!=0;p=p/10){ k=p%10; s=s+pow(k,d); } if(s==n) printf("%d is a an a...
C
#include "search.h" #include <stdio.h> #include <stdlib.h> #include <string.h> int search_context_init(struct search_context *c) { if (!c) return -1; c->len = 0; c->cap = 0; c->array = NULL; return 0; } static void _insert(int array[], int len, int data) { int i; for (i = len - 1; i >= 0; i--) { if (arr...
C
#include <stdio.h> #define alunos 6 int main() { int matricula[alunos], mediainferior, i; float nota1[alunos], nota2[alunos], notafinal[alunos], mediaturma; for (i = 0; i < alunos; i++) { printf("\nDigite o número da matricula do aluno %i: ", i+1); scanf("%i", &matricula[i]); printf...
C
#define _XOPEN_SOURCE 600 #include <SDL.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <time.h> #include <sys/time.h> #include <signal.h> #include <pthread.h> #include <stdbool.h> #include "timer.h" // Return number of elapsed µsec since... a long time ago static unsigned long get_time (void) ...
C
/*Read Me: # Coded By: # Name:Vaneeswaran N # www.vaneeswaran.com # Description : # Program to swap the odd bits to even and even to odd in a 32 bit integer and it is achieved by doing the below # 1) Extract Even bits from given 32 bit integer # 2) Extract Odd bits from given 32 bit...
C
#include <stdio.h> #include <stdlib.h> #include "strings.h" #define DEBUG 0 void input(char str[], char *delim); void check(char str[], char delim); void process(char str[], char delim); void output(char str[]); int main() { char str[MAX_LENGTH]; char delim; input(str, &delim); check(str, delim); ...
C
/*Copyright (c) 2017 Karan Agrawal Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agr...
C
#include<stdio.h> int main() { int a,b,c,dig; scanf("%d %d",&a,&b); c=a-b; dig=c%10; if(dig==0||dig==1) c++; else c--; printf("%d",c); return 0; }
C
#ifndef GENERATOR_H #define GENERATOR_H #include<stdio.h> #define DRK_HEADER_SIZE 1088 #define DRK_TEST_INFO_SIZE 1184 struct date { int day; int month; int year; }; typedef struct date date_t; struct time { int hour; int minutes; int seconds; }; typedef struct time time_td; /* TODO (#1#): check max field ...
C
#include <sys/types.h> /* See NOTES */ #include <sys/socket.h> #include <string.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdio.h> #include <unistd.h> /* int socket(int domain, int type, int protocol); */ /* * socket() * bind() * sendto() * recvfro...
C
#include<stdio.h> int main() { float a,b,div; printf("Enter the value of A="); scanf("%f",&a); printf("Enter the value of B="); scanf("%f",&b); div=a/b; printf("Division of two number is =%f",div); return 0; }
C
#include <stdio.h> float potenciacao(float x, int n) { float resultado; int i; for(i = 1, resultado = 1.0; i <= n; i++) resultado *= x; /* resultado = resultado * x */ return resultado; } int main() { float numero; int expoente; printf("Insira o numero: "); scanf("%f", &numero...
C
//Funkcja check_kbr zwraca warto wciskanego przycisku klawiatury 4x4 1-16 lub 0 gdy aden nie wybrany. /* -------------------- | ||K1|K2|K3|K4| ==================== |W1|| 1| 2| 3| 4| -------------------- |W2|| 5| 6| 7| 8| -------------------- |W3|| 9|10|11|12| -------------------- |W4||13|14|15|16| -----------------...
C
#include <stdio.h> void printblank(int n) { for(int i=0; i<n; i++) { printf("_"); } } void printstar(int n) { for(int i=0; i<n; i++) { printf("*"); } } int main() { int rows, cols, stars, blanks; printf("Enter the number of rows:"); scanf("%d", &rows); if(rows%2 == 0) cols = rows + 1; else ...
C
main() { int a,b; printf("Enter the value of a : "); scanf("%d",&a); printf("Enter the value of b : "); scanf("%d",&b); sweap(&a,&b); //call by reference or adddress printf("a=%d b=%d",a,b); getch(); } void sweap(int *x,int *y) { int t; t=*x; *x=*y; *y=t; }
C
// Document Analysis project functions for Part 2 #include <stdlib.h> #include <stdio.h> #include <ctype.h> #include <string.h> #include "analysis.h" #include "unit_tests.h" // First checks that p_list is not NULL. Returns 0 if p_list is a NULL pointer. // Then checks that word pointer is not NULL and word is not an...
C
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include "dominion.h" #include "dominion_helpers.h" //tests handCard() int main() { struct gameState G; int i, j, k, r; printf("Testing handCard()\n"); for (i = 0; i < MAX_PLAYERS; i++){ G.whoseTurn = i; for(j=0; j<= MAX_HAND; ...
C
/* BOJ - 2783 ﰢ */ #include <stdio.h> double gram[101]; double price[101]; double res[101]; int N; void init() { scanf("%lf %lf", &price[0], &gram[0]); scanf("%d", &N); for (int i = 1; i <= N; i++)scanf("%lf %lf", &price[i], &gram[i]); } void cal() { double min; for (int i = 0; i <= N; i++) res[i] = price[i]...
C
#include<stdio.h> //int f(); //int main() //{ // int n; // while (scanf("%d", &n) != EOF) // { // if (f(n) % 3 == 0) // { // printf("yes\n"); // } // else // { // printf("no\n"); // } // } //} //int f(int n) //{ // if (n == 0) // return 7; // else if (n == 1) // return 11; // else // return f(n - 1) + f(n ...
C
#include <stdio.h> int main(void) { unsigned int n, flag = 0; scanf("%u", &n); n ^= (n - 1); flag = !~n; n += 1; n >>= 1; n += flag << 31; printf("%u\n", n); return 0; }
C
/*Program that uses a Function */ #include <stdio.h> // #define NUMBER 5 //Function Signature void stars (int,char); int main() { int number; char my_char; printf("How many rows to display \n"); scanf("%d", &number); printf("\n Enter character to display \n"); scanf("%c", &my_char); //Call stars ...
C
#include <stdio.h> int main() { printf("Drawing a shape using printf statement\n\n"); printf(" /|\n"); printf(" / |\n"); printf(" / |\n"); printf("/___|\n"); return 0; }
C
// bitbox implementation of serial protocol // redefines message(...) to output to serial. Needs to compile mini-printf.c #pragma once // defaults, redefine all or none #ifndef SERIAL_BAUDRATE #define SERIAL_BAUDRATE 9600 #define SERIAL_BUFSIZE 64 // most preferably a power of two. Can send BAUDRATE/60/8 bytes in ...
C
#ifndef _CUSTOM_UTILITY_H_ #define _CUSTOM_UTILITY_H_ #include <stdio.h> static char *safe_strncpy(char *dst, const char *src, const size_t len) { assert(dst); assert(src); if (strlen(src) >= len) { strncpy(dst, src, len - 1); dst[len - 1] = '\0'; } else { strncpy(dst, src, strlen(src)); dst[strlen(src)...
C
// Compile with: gcc -o server -Wall Peer-Server.c -lcrypto -lssl #include <stdio.h> #include <unistd.h> #include <sys/socket.h> #include <stdlib.h> #include <netinet/in.h> #include <arpa/inet.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <dirent.h> #include <time.h> ...
C
#include "colorSnake.h" void colorSnake() { pixel3d apples[10]; pixel3d snake[CSNAKE_LEN]; pixel3d *head = &snake[1]; pixel3d *tail = &snake[0]; pixel3d *digest; voxel old_head, new_apple; color snakeColor = {255, 255, 255}; color darkColor = {1,1,1}; // beats the race condition two apples on one spot color ...
C
/*Calculo de Media de 8 alunos com 4 notas - páginas 111 e 112*/ #include <stdio.h> int main(){ float md[8][4], numero; int i, j; printf("\n\nLeitura de notas\n\n"); //Entrada das notas for(i = 0; i < 8; i++){ printf("\nInforme as notas do %d.o aluno: \n", i + 1); ...
C
#include <stdio.h> #include <stdlib.h> #include "portion.h" #define ITERATION_COUNT 5 struct Portion Portions[ITERATION_COUNT] = { { 101, 41, 10, 0.8, 0.01, 0.0 }, { 201, 81, 20, 0.8, 0.005, 0.0 }, { 401, 161, 40, 0.8, 0.0025, 0.0 }, { 101, 81, 10, 0.4, 0.01, 0.0 }, { 101, 21, 10, 1.6, 0.01, 0.0 ...
C
//Sat 25 Jul 2020 12:19:20 PM AWST //K&R ex 2.8 //Write a function rightrot (x, n) that returns "x" rotated to the right by n //positions #include <stdio.h> int rightrot(int x, int n); int main(){ int x, n; x = 16;//186; n = 5; printf("x(%d) right rotated by %d places is: %d\n", x, n, rightrot(x, n));...
C
/* * @lc app=leetcode.cn id=279 lang=c * * [279] 完全平方数 * * https://leetcode-cn.com/problems/perfect-squares/description/ * * algorithms * Medium (47.30%) * Total Accepted: 6.3K * Total Submissions: 13.1K * Testcase Example: '12' * * 给定正整数 n,找到若干个完全平方数(比如 1, 4, 9, 16, ...)使得它们的和等于 n。你需要让组成和...
C
#ifndef __ABASIT__GAMELOGIC__ #define __ABASIT__GAMELOGIC__ #include <ncurses.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include "roomInfo.h" #include "gameControl.h" #include "hero.h" /** *checkChar *Checks from which direction hero moving, and negates move, if they are going into wa...
C
#ifndef HASH_TABLE #define HASH_TABLE #include <stdlib.h> #include "../linked_list/linked_list.h" //=========================// // Hash Table Struct // //=========================// // Hash Table Data Structure // Using Closed Addressing with Linked Lists to resolve collision typedef struct { linked_lis...
C
/* Check c++ first * The job is to add the leftmost digits up, and add the carry (0 or 1) * put it into a new list node, check if there is carry for the next iteration * Instead of having a "carry" boolean, just declare a global variable sum * divide it by 10 at the end of each iteration. * This solution does not ...
C
#include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <errno.h> #include <string.h> int main(){ int socket_a_moi = socket(AF_INET, SOCK_STREAM, 0); struct sockaddr_in adresse_serveur; adresse_...
C
#include "FS.h" #include <stdio.h> #include <stdlib.h> char * file_read(char * file_name) { FILE * file_reading = 0; file_reading = fopen(file_name, "r"); //check if file exists if (!file_reading) exit(1); //know the size of the file fseek(file_reading, 0, SEEK_END); int file_bytesize = ftell(file_...
C
#include<stdio.h> int main() { int a=12; if(a&1) printf("not even"); else printf("Even"); return 0; }
C
#include<stdio.h> double pi=3.14; void my_fnc() { pi=3.1416; return; } int main() { printf("%lf",pi); my_fnc(); printf("\n%lf",pi); return 0; }
C
#include "ft_printf.h" static void clear(t_item *item) { free(item -> data); free(item); } static int make_proper_precision(int precision, int pure_width, t_item *item) { if (precision < 0) { item -> precision_failed = 1; return (pure_width); } return (precision); } int parse(va_list ap, char **format) { ...
C
/* This is the "simple" version of the test program */ /* Definitions go first */ float myFirst; float theSecond; /* There is no "main" program, just blocks */ // THIS FILE USES FLOAT VALUES and declares FLOAT TYPES // so := No warnings. { myFirst := 134.0 + 10.0; theSecond := myFirst / 12.0; }
C
// ConsoleApplication1.cpp: define el punto de entrada de la aplicación de consola. // #include "stdafx.h" #include <stdio.h> /* Variadic + str concatenation */ // operators # and ## to stringize // /* __COUNTER__ Macro is self incrementing at preprocessing time */ #define TRUE (1==1) #define FALSE (!TRUE) #defi...
C
#include <stdio.h> #include <cs50.h> #include <stdlib.h> int main(void) { int r = get_int("Input Radius: "); float p = 3.14; int c = 2*p*r; printf("Circumference of the circle = %d inches\n", c); int a = p*r*r; printf("Area of the rectangle = %d square inches\n", a); return(0); }
C
#include<stdio.h> typedef struct abc { int a; int b; }abc; abc ar[8]; static int compare(const void *i1,const void *i2) { const abc *p1=(const abc *)i1; const abc *p2=(const abc *)i2; return (p1->a-p2->a); } int main(int argc, char *argv[]) { int x,y,z,min,max; for(x=0;x<8;x++) { scanf("%d %d"...
C
/** ** @file util.c ** @author Hugh S. Myers ** @brief A collection of functions in aid of support for mp. ** @date Mon Jul 24 17:01:02 2017 ** ** General catch-all of routines needed but not complicated enough for their own file. ** ** @bug No known bugs. **/ #include <stdio.h> #include <stdlib.h> #incl...
C
#include <stdio.h> int main() { int x, y, z, maior, menor, meio; printf("Digite tres numeros: \n"); scanf("%d\n", &x); scanf("%d\n", &y); scanf("%d", &z); if(x > y && x > z) { maior = x; } if(y > x && y > z) { maior = y; } if(z > x && z > y) { maior = z; } /// maior encontrado if(x <...
C
int fang(int a,int b) { int m; if(b==1||a==0) m=1; else { if(a>=b) m=fang(a-b,b)+fang(a,b-1); if(a<b) m=fang(a,b-1); } return m; } main() { int i,p,q,a,n; scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%d %d",&p,&q); a=f...
C
//https://stackoverflow.com/questions/559581/casting-a-function-pointer-to-another-type #include <stdio.h> #include <stdlib.h> int AddTwoNumber(int iData1, int iData2) { return (iData1 + iData2); } int main(int argc, char *argv[]) { int iRetValue = 0; int (*pfAddTwoNumber)(int, int) = NULL; //Declaration...
C
/* Programmeringsuppgift 7.1, Sida 146 - repetition Skriv en modul som hller reda p aktuell temperatur. Den ska ha fyra funktioner: observation, aktuell_temp, obs_tim, obs_min. Observation anvnds fr att rapportera in uppmtt temperatur vid klockslag (parametrar: temp, tim, min). De andra funktionerna ska returna ...
C
#include <windows.h> #include <winsock.h> #include <stdio.h> #include <string.h> #define REMOTE_SERVER_PORT 6000 #define MAX_MSG 100 int main(int argc, char *argv[]) { int sd, rc, i; struct sockaddr_in cliAddr, remoteServAddr; WSADATA wsaData; LPHOSTENT lpHostEntry; /* check command line args */...
C
#include <stdlib.h> #include "exmemwb.h" #include "decode.h" u32 breakpoint(void) { return 0; } /* int handle_bkpt(unsigned int bp, unsigned int arg) { int r = 1; FILE *f; int s, e, n; unsigned int sp; sp = read_register(13); switch (arg) { case 0x18: fprintf(stderr, "Exiting.\n"); break; case 0x...
C
# include <stdio.h> int main(void) { int i ; typedef struct { char bname[80]; int pages, price ; } book ; book info[3] ; for(i=0 ; i < 3 ; i++) { printf("\nEnter the book(%d) name :", i+1); getchar(); gets(info[i].bname); printf("\nEnter the book(%d) pages :",i+1); scanf("%d", &info[i].pages); printf("Enter the bo...
C
#include <stdio.h> #include <string.h> #define MAXN 200002 int Cnt[2][MAXN]; char StrA[MAXN]; char StrB[MAXN]; int main() { int i, lenA, lenB; long long Ans = 0; scanf("%s %s", StrA, StrB); for(i = 0; StrA[i] != '\0'; ++i) { if(i) { Cnt[0][i] = Cnt[0][i - 1]; Cnt[1]...
C
/*example of how to write to an output file as well as for a differential growth equation fprintf(FILE*,"____", _, _, _, _); FILE *fp; fp = fopen("growth.txt", "w"); w= write r= read a = append HOW TO IMPROVE: Runga-Kutta Method: uses more derivitate information to step forwad by 1/2deltat - then calcs slope at the ...
C
#include <stdio.h> #include "stack.h" #include <stdlib.h> push(stack** head, int v) { stack* s = (stack*)malloc(sizeof(stack)); s->value = v; s->next = *head; *head = s; } int pop(stack** head) { if (*head == NULL) return 0; else { stack* s = NULL; stack* p = NULL; p = *head; int result = p->...
C
#include <stdio.h> int main() { int i, N, j,left, right, k; scanf("%d", &N); for(i =0; i < N; i++) { for(j = 0;j < N-1-i; j++) { printf(" "); } for(k = N-1-i; k < N; k++) { printf("*"); } for(k = N; k < N + i; k++){ printf("*"); } printf("\n"); } for(i =N-2; i > -1; i--) { for(j = 0;...
C
/****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS Code, Compile, Run and Debug online from anywhere in world. *********...
C
/* * Copyright (c) 2017 Eric A. Welsh. All Rights Reserved. * * eol2eol is distributed under the following BSD-style license: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code...
C
#include <stdio.h> int main(void) { // Question 1 /*int num = 10; int * ptr1 = &num; int * ptr2 = ptr1; (*ptr1)++; (*ptr2)++; printf("%d \n", num);*/ // Question 2 int num1=10, num2=20; int * ptr1 = &num1, * ptr2 = &num2; (*ptr1) += 10; (*ptr2) -= 10; ptr1 = &num2, ptr2 = &num1; printf("%d %d\n", nu...