language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* my_unset.c :+: :+: :+: ...
C
/* bluepp 2014-06-02 2014-07-08 2014-08-07 2014-11-23 May the force be with me! Problem: Binary Tree Postorder Traversal Source: http://oj.leetcode.com/problems/binary-tree-postorder-traversal/ Notes: Given a binary tree, return the postorder traversal of...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define UseAESedp // Tell AES.h to define things for AESedp. #include "AES.h" /* In comments below, {n} designates the Galois field element represented by the byte n. See notes about Galois field multiplication in ReadMe.txt. So 3+5 is addition of ordina...
C
i#include <stdio.h> int main() { double a; double b; double MEDIA; double aa ; double bb; scanf("%lf %lf",&a,&b); aa = a * 3.5 ; bb = b * 7.5; MEDIA = (aa + bb) /11; printf("MEDIA = %.5lf\n",MEDIA); return 0; }
C
#include <pthread.h> #include "papi_test.h" void * pthread_main( void *arg ) { ( void ) arg; int retval = PAPI_register_thread( ); if ( retval != PAPI_OK ) { test_fail( __FILE__, __LINE__, "PAPI_register_thread", retval ); } clockcore( ); retval = PAPI_unregister_thread( ); if ( retval != PAPI_OK ) { ...
C
// This is a personal academic project. Dear PVS-Studio, please check it. // PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com #include "AVLNode.h" int32_t avl_test_print(avlnode_ptr node, int32_t dep) { if (!node) { return 0; } if (node->left) { avl_test_print(node-...
C
#include <stdio.h> #include "machin_serial.c" #define PI 3.14159265358979323846 int main(int argc, char const *argv[]) { FILE *fp; fp = fopen("./machin0_residual.txt", "w"); double pi_k = 0; for (int k=1; k<=24; ++k) { pi_k = machin0(pow(2,k)); double resi = fabs(PI - pi_k); fprintf(fp, "n = %.0lf,\t...
C
/** * @file icl_hash.c * * Dependency free hash table implementation. * * This simple hash table implementation should be easy to drop into * any other peice of code, it does not depend on anything else :-) * * @author Jakub Kurzak */ /* $Id: icl_hash.c 2838 2011-11-22 04:25:02Z mfaverge $ */ /* $UTK_Copyrigh...
C
#include <stdio.h> #include <stdbool.h> #include <gtk/gtk.h> #include <cairo.h> // switch case wymagal zeby obiekty nie byly zmiennymi wiec zmienilem na #define #define DROGA '#' #define OSIEDLE 'O' #define KOPALNIA 'K' #define ELEKTROWNIA 'E' #define LINIA 'T' #define UNIWERSYTET 'U' int width, height; char map[100...
C
#include "minishell.h" void ft_free(void **ptr) { free(*ptr); *ptr = NULL; } int check_symbols(char *str) { int i; if (!ft_isalpha(str[0]) && str[0] != '_') return (1); i = 1; while (str[i] && str[i] != '=') { if (str[i] == '+' && str[i + 1] == '=') return (2); if (!ft_isalnum(str[i]) && str[i] != '_...
C
#include <stdio.h> int main() { int n; printf("Enter a number to see if it is prime:"); scanf("%d", &n); int isPrime = 1; for (int i = 2; i < n; i++) { if (n % i == 0) { isPrime = 0; printf("%d is divisible by %d\n", n, i); break; } } if...
C
#include <stdio.h> #include <sys/time.h> #include <sys/types.h> #include <unistd.h> #include <string.h> #include <stdlib.h> #define STDIN 0 // file descriptor for standard input int main(void) { fd_set rfds; struct timeval tv; int retval; char buf[255]; int len; /* Watch stdin (fd 0) to see w...
C
/* socket_tcp_client.c A client enters textline to server and also receive echo back message Server is handled as thread with epoll Compiling and Execution $ gcc -o exec_c socket_tcp_client.c -Wall - $ ./exec_c localhost 5000 or $ ./exec_c 192.168.1.46 5000 There can be several clients f...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_putnbr_hexa_fd.c :+: :+: :+: ...
C
#include<stdio.h> #include<stdlib.h> #define bucketSize 512 void bktInput(int a,int b) { if(a>bucketSize) printf("\n\t\tBucket overflow"); else { while(a>b){ printf("\n%d bytes outputed.",b); a-=b; } if (a>0) printf("\n\t\tLast %d" ,a); printf("\tbytes sent\t"); printf("\n\t\tBucket output successful\n")...
C
// // main.c // HeAtom // // Created by Mitchell Miller on 3/23/12. // Copyright 2012 __MyCompanyName__. All rights reserved. // #include <math.h> #include <stdio.h> #include <stdlib.h> #include <time.h> double bohrRadius = .5291772083; //angstroms double Pi = 3.141592653589793; double E = 2.718281828459045; doub...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* rotation.c :+: :+: :+: ...
C
#include "spi.h" void SPI_MasterInit(void) { /* Set MOSI and SCK output, all others input */ DDRB = (1<<DDB2)|(1<<DDB1); //enable OE DDRE |= _BV(PE4); //enable pour LE DDRE |= _BV(PE5); // enable port SS DDRB |= _BV(PB0); /* Enable SPI, Master, set clock rate fck/16, enable interuption*/ ...
C
#ifndef __LINKLIST_H__ #define __LINKLIST_H__ #include<stdio.h> #include<stdlib.h> #include<assert.h> typedef int DataType;//char޸ģάԴ룩 typedef struct Node { DataType data; struct Node* next; }Node; void PushBack(Node** pphead, DataType x);//ppheadӦΪָ void PopBack(Node** pphead); void PushFront(Node** pphead, Da...
C
/** * @file test.c * * A test driver. */ #include <stdio.h> #include <string.h> #include <sys/stat.h> #include <fcntl.h> #include "logger.h" #include "allocator.h" /** * A test driver. * * @param void */ int main(void){ // //test 3 // char* str0 = malloc(100); // char* str1 = malloc(100); // char* str2 ...
C
#include <stdio.h> #include <string.h> #include <sys/types.h> #include <sys/uio.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include "../incs/libasm.h" int main(int ac, char **av) { int ret = 0; if (ac == 2) { char copy[ft_strlen(av[1])]; char copy2[ft_strlen(av[1])]; printf("\nSTRLEN TEST--...
C
/* A simple example for dangling pointer. */ #include <stdio.h> #include <stdlib.h> int main(){ char* data = (char *)malloc(32); // Assuming that the 9th char is critical... data[8] = 'L'; printf("data buffer at address %x\n", data); /* ... * some complex program code here * ... */ free(data...
C
#include <stdio.h> #include <stdlib.h> int big(int a, int b) { if (a > b) { return a; } return b; } void work(int * data, int * max, int * visited, int current, int count) { if (data[data[current]] == current) { max[current] = big(max[current], count); return ; } if (visited[current]) { max[current] = bi...
C
#include "../include/sock_help.h" void *get_in_addr(struct sockaddr *sa) { if(sa->sa_family == AF_INET) return &(((struct sockaddr_in *) sa)->sin_addr); else return &(((struct sockaddr_in6 *) sa)->sin6_addr); } int get_tcp_socket(const char *port, char *hostname, char flags) { int fd = 0; int rv = 0; #if...
C
/** * Write a program to print a histogram of the frequencies of different * characters in its input. */ #include <stdio.h> #define MAXLEN 100 int main(int argc, char const *argv[]) { char c; int most_occuring = 0, ind = 0, count = 0, k = 0; char input[MAXLEN]; int word_freq[MAXLEN]; bool signal...
C
/*maximum and minimum of three numbers using ternary condition input: 10 6 17 output: max:17 min:6 */ #include<stdio.h> int main(){ int a,b,c; int max,min; scanf("%d %d %d",&a,&b,&c); max=(a>b&&a>c)?a:b>c?b:c; min=(a<b&&a<c)?a:b<c?b:c; printf("max:%d min:%d",max,min); }
C
#include<stdio.h> #include"grpengine.h" void clear_screen() { //ȭ ޼尡 ʿ //system("cls"); COORD Coor = { 0, 0 }; DWORD dw; FillConsoleOutputCharacter (GetStdHandle(STD_OUTPUT_HANDLE), ' ', 80 * 42, Coor, &dw); } void sleeped(int mil_second) { //clock();// ð int result; result = mil_second + clock(); whil...
C
#include <stdlib.h> #include <string.h> #include <stdio.h> #include "v1beta1_custom_resource_validation.h" v1beta1_custom_resource_validation_t *v1beta1_custom_resource_validation_create( v1beta1_json_schema_props_t *openAPIV3Schema ) { v1beta1_custom_resource_validation_t *v1beta1_custom_resource_validatio...
C
#include "log.h" #include "wrapper.h" #include <stdio.h> #include <sys/stat.h> #include <sys/types.h> #include <time.h> #include <string.h> #include <sys/mman.h> #include <pthread.h> #include <stdlib.h> #include <sys/time.h> static const char* dir_name = "../log"; //static pthread_mutex_t* mutex; static FILE* FP; sta...
C
#include <stdio.h> main() { int a=10; int b=20; swapv(a,b); printf("a=%d\n",a); printf("b=%d\n",b); } swapv(int x,int y) { int t; t = x; x = y; y = t; printf("x=%d\n",x); printf("y=%d\n",y); }
C
/* Meno: Matus Brandys Datum: 4.12.2016 Simulujte nasledujucu situaciu. Vo vyvhodnej Europe, v malej dedinke prepukla epidemia a nakazilo sa 10 ludi. Sedem z nich maju len mensiu nemoc na traja ludia maju vazne problemi. Aby sa nakazilo este viac ludi, tak sa vlada rozhodla tychto 10 ludi prestahovat do vedlasej dedin...
C
#include <stdio.h> // c function must return int FindGreatestSumOfSubArray(int* array, int arrayLen ) { // write code here int f = array[0]; int s = array[0]; int re = array[0]; for (int i = 1; i < arrayLen; i ++){ s += array[i]; printf("%d ", s); if (s > array[i]){ ...
C
#include "ft_malloc.h" void *realloc(void *ptr, size_t size) { t_allocinfo *zone; t_allocinfo *next; t_allocinfo *next_tmp; size_t tmp_size; zone = ptr - STRUCTSIZE; if (exists(zone)) return (NULL); if (zone->size >= size + STRUCTSIZE * 2) zone = split_zone(zone, size); else { next = (void *)malloc(s...
C
#include <stdio.h> #include <omp.h> #define N 1000000 int a[N]; int main(){ // initialize the array for(int i=0; i<N; ++i){ a[i] = 0.2 * i; } int sum = 0; double seq_time, par_time; double t1 = omp_get_wtime(); // sequential implementation for(int i=0; i<N; ++i){ sum...
C
//A dictionary //data is the contents of the dictionary (not including definitions) //so dict.data[0] should be a string containting the first word in the dictionary, and so on. //size is the number of words in the dictionary. typedef struct{ char** data; int size; } dictionary; //reads a dictionary line by line...
C
#include <stdio.h> // 1. Է ޾ void main(){ int dan; int i=9; printf(" Էϼ: "); scanf("%d", &dan); while (i > 0){ printf("%d x %d = %d \n", dan, i, dan * i); i--; } }
C
#include <unistd.h> #include <sys/types.h> #include <errno.h> #include <stdio.h> #include <sys/wait.h> #include <stdlib.h> int main() { int i; for(i = 0; i < 4; i++) { pid_t pid = fork(); if(pid < 0) { printf("Error"); exit(1); } else if (pid == 0) { printf("Child (%d): %d\n", ...
C
#include <esp8266.h> #include <serled.h> static ETSTimer serledTimer; static uint8_t serledPin; static void ICACHE_FLASH_ATTR setSerled(int on) { // LED is active-low if (on) { gpio_output_set(0, (1<<serledPin), (1<<serledPin), 0); } else { gpio_output_set((1<<serledPin), 0, (1<<serledPin), 0); } } s...
C
#include<stdio.h> #define F_LOW 0 //------------------------------ #define F_MAX 250 //-----SYMBOLIC CONSTANTS------- #define STEP 25 //------------------------------ int main() { typedef float REAL; REAL f, c; f = F_LOW; printf("Fahrenheit | Celsius\n\n"); //------------------------------------------...
C
#include<stdio.h> #include<string.h> #include<stdlib.h> void printByArray(int(*pArr)[3], int len1, int len2) { for (int i = 0; i < len1; ++i) { for (int j = 0; j < len2; ++j) { //printf("%d ", *(*(pArr + i) +j)); printf("%d ", pArr[i][j]); } } printf("\n"); } void test01() { int arr[3][3] = { {1, 2, ...
C
/* Created on 04/2015 Author: guidefloripa A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The lexicographic permutations of 0, 1...
C
#include <stdio.h> int main(void) { int parcela1, parcela2; printf("Digite a primeira parcela: "); scanf("%d", &parcela1); printf("Digite a segunda parcela: "); scanf("%d", &parcela2); int soma = parcela1 + parcela2; printf("%d + %d = %d\n", parcela1, parcela2, soma); return 0; }
C
#include <stdio.h> void next(int *a, int n) { int j = n - 1; int temp; while (a[j] > a[j + 1]) j--; int k = n; while (a[j] > a[k]) k--; temp = a[j]; a[j] = a[k]; a[k] = temp; int r = n; int s = j+1; while (r > s) { temp = a[r]; a[r] = a[s]; a[...
C
//mapping table data structure is used to store the correspondence between threads and core. author:hh typedef struct processor{ int logical_id; int physical_id; }Proc; typedef struct index{ int proc_no; int thread_no; }Index; ////mapping function: returns the cpu number bound to the thread in same core author:h...
C
/* 'global shared int i = 0 main: spawn thread_1 spawn thread_2 join all threads (wait for them to finish) print i thread_1: do 1_000_000 times: i++ thread_2: do 1_000_000 times: i-- */ #include <pthread.h> #include <stdio.h> int i = 0; //Husk i og ikke j void minus(){ for...
C
/* * 链表反转 */ #include <stdio.h> #include <stdlib.h> #define LEN 5 typedef struct NUMS { int num; struct NUMS *p_next; }N; N* create_linklist( int *a, int n ){ N *p_head; N *p_node; p_head = ( N* )malloc( sizeof( N ) ); if( !p_head ) return NULL; p_head->num = a[0]; p_head->p_next = NULL; p_node = p_hea...
C
#include <stdio.h> int main () { int marks; char grade; scanf ("%d",&marks); if (marks >= 80){ grade = 'A+'; printf ("your grade is %c\n",grade); } else if (marks >= 70){ grade ='A'; printf ("your grade is %c\n",grade); } else if (marks >= 60){ gra...
C
#include <stdio.h> #include <math.h> float Floating(float x){ float y; y = x/(1 + fabsf(x)); return y; } int main(){ printf("Input x:\n"); float x; scanf("%f",&x); printf("%f\n", Floating(x)); }
C
void arpcache_insert(u32 ip4, u8 mac[ETH_ALEN]) { // check is there has been one item with given ipv4 addr, if yes, replace it int i = 0; int flag = 0; for (i = 0; i < MAX_ARP_SIZE; i += 1) { if(arpcache.entries[i].ip4 == ip4) { flag = 1; memcpy(arpcache.entries[i].mac, m...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> int main(){ FILE *f; char input[1000]; int t, i=0; f=fopen("input.txt", "r"); fseek(f, 0, SEEK_END); t=ftell(f); fseek(f,0,SEEK_SET); while(!feof(f)){ fscanf(f, "%c", &input[i]); i++; } input[i-1]='\0...
C
/* * AF_INET * This designates the address format that goes with the Internet namespace * 网络编程 -- 客户端 */ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <unistd.h> #include <sys/un.h> #include <arpa/inet.h> #include <netinet/in.h> int main(int argc, char const *argv[]) { ...
C
#include <stdio.h> int main() { int i = 0; for(i = 0; i < 729; ++i) { printf("%i\n", i); } printf("The value of i is %i\n", i); }
C
#include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #include "ArrayEmployees.h" #define cant 1000 int menuOpcion_getNumero(int opcion, char* mensaje, char* mensajeErrorUno) { system("cls"); printf("Bienvenido al Menu, que desea realizar?"); printf("\n\n 1. Dar Alta Empl...
C
/* ** EPITECH PROJECT, 2019 ** str_to_word_array.c ** File description: ** create tab string */ #include "../header.h" char *select_word(char *wrd, char *str, int end, int start) { int i = 0; while (start != end) { wrd[i] = str[start]; i = i + 1; start = start + 1; } wrd[i] = ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "lista.h" #include "operacoes.h" void menu(){ int op=-1, i; system("clear"); printf("#######################################\n"); printf(" CALCULADORA - BIG INT \n"); printf("#######################################\n\n"); pri...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<unistd.h> #include<stdbool.h> #include<err.h> #include<errno.h> #include<arpa/inet.h> #include<netinet/in.h> #include<sys/socket.h> #include<sys/select.h> #include<signal.h> #define MAXLINE 1008 #define HEADER 8 char filename[20]; char *filedata; stati...
C
/* elem.c */ /* Returns TRUE if the first argument is a */ /* member of the array (the second argument). */ /* Otherwise, returns FALSE. */ /* This code is released to the public domain. */ /* "Share and enjoy...." ;) */ #include <stdio.h> #include <stdlib.h> #...
C
#include <stdio.h> #include <string.h> #define SIZE 64 void reverse_name(char *name); int main(void) { char name[SIZE + 1]; printf("Enter First Name and Last Name: "); fgets(name, sizeof(name), stdin); reverse_name(name); puts(name); return 0; } void reverse_name(char *name) { /* char first[SIZE / 2],...
C
#include <stdio.h> #include <stdlib.h> #include "Mapping.h" #include "Debug.h" #include "Comm.h" // FIXME: find a better place for this Mapping* Mapping_create(int dim, int levels, int order, const Tuple *flat_size, const Tuple* tiling, const Dist *dist, size_t scalar_size) { return Mapping_create_impl(-1, 0, dim...
C
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <sys/wait.h> #include <string.h> void first_cmd(int argc, char **argv); //function for handle command-line arguments void first_cmd(int argc, char **argv){ pid_t k; int status; char* buf[100]; int count = 0; memset(bu...
C
//program to do all experimental actions on c (basic actions) // Author:Ajay Shinde Date : 11/01/2019 #include<stdio.h> int main(){ // int a = b = 3 =4; // // int a,b; // a = b = 4= 4; printf("%d",12345/10); return 0; }
C
#include<stdio.h> void bonjour(char * name) { printf("Boujour %s\n",name); }
C
/* testfork1.c * Simple program to test the fork system call. */ #include "syscall.h" void test1(){ Write("test1\n", 6, ConsoleOutput); Exit(0); } void test2(){ Write("test2\n", 6, ConsoleOutput); Exit(0); } int main() { Fork(test1); Fork(test2); }
C
#include "struct.h" /* Get file size */ uint64_t fgetsize(int fd) { struct stat info; if (fstat(fd, &info) != 0) { perror("fstat() error\n"); exit(1); } return info.st_size; } /* Get file width for mal_site1, mal_site2 */ int getwidth(const char *buf) { int i = 0; while (buf[i++] != '\1'); return i; } /* ...
C
#include "sort.h" /** * selection_sort - sorting by selection * @array: array * @size: size */ void selection_sort(int *array, size_t size) { size_t i = 0, j, pivote; int aux; if (array && size > 1) { while (i < size - 1) { pivote = i; j = i + 1; while (j < size) { if (array[pivote] > arra...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { FILE* fp; fp = fopen("./output/rkdsp.bin", "rb"); if(fp){ fseek(fp, 0, SEEK_END); int len = ftell(fp); fseek(fp, 0, SEEK_SET); unsigned char* buf = (unsigned char*) malloc(len); if (fread(buf, len, 1, fp) == 1){//ok FILE* fw; fw ...
C
#ifndef DEBUG_H #include "debug.h" #endif char errore[24]; void error(char message[], int err) { sprintf(errore, "[ERROR : %s]:%s,message:%s\n",processSign, strerror(err), message); printf("%s",errore); cleaner(); perror(errore); exit(err); } int debug(const char *__restrict__ message, ...) { ...
C
#include "include.h" #include "img_control.h" #include <stdlib.h> #include <stdio.h> #include <math.h> #include "timer.h" #include "beep.h" /********************************************************************************** * ƣvoid show_photo() * ˵ͼ * ˵f==1 ӥͷĶֵʽf==0Ҷģʽ * أ * ޸ʱ䣺2014-6-17 wuwenqi * ע *****...
C
#include <stdlib.h> #include <stdio.h> #include <time.h> /*3) Escribe un programa en el que se cargue una matriz de 15 filas con números enteros aleatorios entre 100 y 999. Cada fila se cargará en FORMA DINAMICA. La cantidad de columnas estará dada por un número aleatorio entre [5, 15]. Mostrar por pantalla la matriz a...
C
/**************************************************************************************** * NAME: SOUMITRI CHATTOPADHYAY * ROLL: 001911001083 * SUBJECT: COMPUTER NETWORKS LABORATORY (UG-2, SEM-2) * ASSIGNMENT: CO-3 Assignment 3(a) - Go-Back-N Acknowledgement Protocol - Sender **************************************...
C
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <termios.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <libssh/libssh.h> #include <libssh/priv.h> #include <errno.h> #define AUTHOR "Jonathan Sarba<jsarba@petrobrasenergia.c...
C
/** AST handling for expression nodes: Literals, Variables, etc. * @file * * This source file is part of the Cone Programming Language C compiler * See Copyright Notice in conec.h */ #include "../ast/ast.h" #include "../shared/memory.h" #include "../parser/lexer.h" #include "../ast/nametbl.h" // Create a new func...
C
#include <math.h> #include "myLib.h" #include "sprites.h" typedef struct { const u16* image; u8 x; u8 y; u8 alive; } BRICK; typedef struct { double x; double y; double speed; s16 direction; double dx; double dy; u8 alive; } BALL; typedef struct { s16 x; s16 y; s16 speed; u8 lives; } PLAYER; // global...
C
#include <stdio.h> #include <math.h> int A[200000]; long long B[200000]; int Dp[200000][20]; void SetRMQ(long long *array, int n) { int i, j, k; for(i = 0; i < n; ++i) { Dp[i][0] = i; } k = log(n) / log(2); for(j = 1; j <= k; ++j) { for(i = 0; i + (1 << j) - 1 < n; ++i) { ...
C
#include "holberton.h" /** * print_alphabet_x10 - display alphabet x10 * Return: void */ void print_alphabet_x10(void) { char alp; int i; for (i = 0; i <= 9; i++) { alp = 'a'; while (alp <= 'z') { _putchar(alp); alp++; } _putchar('\n'); } }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* small.c :+: :+: :+: ...
C
#include "scc.h" //calculates number of edges in each scc int process_traversed(t_vect *edgs) { int num = 0; qsort(edgs->tab, edgs->used, sizeof(int), cmp_int); for (int i = 0; i < edgs->used; i++) if (i == 0 || edgs->tab[i] != edgs->tab[i-1]) num++; free(edgs->tab); free(edgs); return num; } t_componen...
C
/* Escreva um programa que leia informações de livros presentes no arquivo bestsellers.cvs, organize-os na forma de um array de structs, e imprima uma tabela com o nome e autor dos livros. o arquivo possui um livro por linha, com cada campo separado por vírgulas, sendo os campos nome, autor, idiom...
C
#include <stdio.h> #include <stdlib.h> void swap(int * n1, int * n2) { int tmp = *n1; *n1 = *n2; *n2 = tmp; } void quick_sort( int *tab, int left, int right ) { int i = left, j = right; int x = tab[( left + right ) / 2 ]; do { while( tab[ i ] < x ) i++; while(...
C
#include <stdio.h> int main() { double cotacao, aliquota, valorproduto, valorfrete; double valortotal, importacao, finalicms, icms, impostos, totalpagar; scanf("%lf %lf %lf %lf", &cotacao, &aliquota, &valorproduto, &valorfrete); valorproduto = valorproduto * cotacao; valorfrete = valorfrete * cot...
C
#define _CRT_SECURE_NO_WARNINGS #define EMPTY_QUEUE_ERROR -999999 #include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> #include <ctype.h> #define MAXLEN 100 /*29 3. ݴʻHuffman ¾ ѹͽѹ love is love, this commandment is always said by Marbury, which means that one person always love any othe...
C
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <string.h> #define MAX_THREADS 3 char WORDS[3] = "ABC"; void *do_thread_stuff(void *i){ int index = (int) i; char *letter = malloc(sizeof(char) + 1); letter[0] = WORDS[index]; unsigned short ...
C
#include<stdio.h> main() { int i=2,n=8,c; for(i=2;i<n;i++) { c=n%i; if(c==0) { printf("%d n is not a prime number\n",n); if (c!=0) continue; } if(i==n) printf("%d n is a prime number\n",n); if(i<n) printf("%d n is not a prime number\n",n); } }
C
#ifndef HASH_H #define HASH_H #include <stdbool.h> #include <stddef.h> typedef struct hash hash_t; // A implementar bool hash_guardar(hash_t* hash, const char* clave, void* dato); hash_t* hash_crear(); bool hash_pertenece(const hash_t* hash, const char* clave); void* hash_borrar(hash_t* hash, const char* clave); ...
C
// Copyright 2016-2019 Coffee Stain Studios. All Rights Reserved. #pragma once /** * A collection of unit conversions to make code more readable. */ struct FUnits { /** Distance */ static FORCEINLINE float CmToM( float cm ) { return cm / 100.0f; } static FORCEINLINE float MToCm( float m ) { return m *...
C
// // main.c // PlayingWithC // // Created by Jonathan Pappas on 5/11/21. // #include <stdio.h> int main(int argc, const char * argv[]) { // insert code here... printf("Hello, World!\n"); int count = 1; for(int i=0;i<1000000000;i++) { for(int j=0;j<1000000000;j++) { ...
C
#include <stdio.h> int main() { float sum = 0.0f, corr = 0.0f; /* corrective value for rounding error */ for (int i = 0; i < 10000; i++) { float y = (i + 1) - corr; /* add the correction to specific item */ float t = sum + y; /* bits might be lost */ corr = (t - sum) - y; /* recover lost...
C
/* 求置换的循环节,polya原理 */ #include <stdio.h> #include <string.h> #include <stdlib.h> #define MAXN 1000 int gcd(int a,int b){ return b?gcd(b,a%b):a; } /* perm[0..n-1]为0..n-1的一个置换(排列) * 返回置换最小周期,num返回循环节个数 */ int polya(int* perm,int n,int* num){ int i,j,p=0,v[MAXN]={0},ret=1; for(*num=i=0;i<n;i++) ...
C
#include <stdio.h> int main(){ int a[10],i,j; for(i=0;i<10;i++){ scanf("%d",&a[i]); } for(i=1;i<10;i++){//n-1 //iʱa[0]a[n-i-1]һȽ for(j=1;j<11-i;j++){ if(a[j-1]>a[j]){//ߵ򽻻 int temp = a[j-1]; a[j-1]=a[j]; a[j]=temp; } } } for(i=0;i<10;i++){ printf("%d\n",a[i]); } return 0; }
C
#define NULL ((void*)0) typedef unsigned long size_t; // Customize by platform. typedef long intptr_t; typedef unsigned long uintptr_t; typedef long scalar_t__; // Either arithmetic or pointer type. /* By default, we understand bool (as a convenience). */ typedef int bool; #define false 0 #define true 1 /* Forward d...
C
#include<stdio.h> int main() { int a,b; printf("/nenter the two numbers"); scanf("%d%d",&a,&b); printf("\n a=%d\nb=%d"); a=a^b; b=a^b; a=a^b; printf("/n after swapping") printf("/n a-%d/nb=%d); getch(); return 0; }
C
#include<gtk/gtk.h> #include<stdlib.h> GtkWidget *window; GtkWidget *table;// 和ios相比,是多出来的,ios没有这种界面布局控件。 GtkWidget *label; GtkWidget *entry; GtkWidget *button; char text[50]; void on_clicked(GtkWidget *widget,gpointer data) { // 获取文本框的内容,并将其复制到text字符数组中 strcpy(text,gtk_entry_get_text(GTK_ENTRY(entry))); prin...
C
// #include "TFile.h" #include "TTree.h" #include "TH1F.h" #include "CMSAna/HHToBBGG/interface/HHToBBGGEventTree.hh" #include "CMSAna/Utils/interface/SimpleTable.h" //-------------------------------------------------------------------------------------------------- // Get Total Number of Events in the sample //----...
C
#include "header.h" #include <math.h> #include <string.h> char *getXor(char *a, char *b) { char *res = strdup("000000"); for (int i = 0; i < 6; i++) { if (a[i] != b[i]) res[i] = '1'; else res[i] = '0'; } return (res); } int toInt(char *bits) { int num = 0; int p = 0; int size = strlen(bits); for (i...
C
#include <stdio.h> #include <stdlib.h> int main() { int m,n,t,i,cif,p,j,bd; scanf("%d%d%d" , &m ,&n ,&t); /**t=broj na deliteli*/ for(i=m;i<=n;i++) { p=i; bd=0; for(j=1;j<=p;j++) { if(p%j==0) ++bd; } if(bd==t) ...
C
#include <stdio.h> #include <stdlib.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main() { int num,num1 = 0,num2=1,cont=1,fibo; printf("Ingrese el valor del termino que desea saber la serie de fibonacci: "); scanf("%i",&num); while(num<=0){ print...
C
/** finalfuncts.c * =========================================================== * Name: Trinity Abdulkhalik, 12/3/2020 * Section:T1A * Project: Hangman * Purpose: Display understanding of overarching course concepts * =========================================================== */ #include <stdio.h> #include <stdlib.h>...
C
#include <ft_printf.h> #define BUFF_SIZE 4096 #include <string.h> #include <unistd.h> static char buffer[BUFF_SIZE]; static size_t size = 0; static size_t total = 0; static void bufferize_too_long_char(const char c, size_t len) { memset(buffer + size, c, TAB_SIZE(buffer) - size); len -= TAB_SIZE(buffer) - size; ...
C
#include <stdio.h> main (int argc, char *argv[]) { int i; printf("There were %d things on the command line\n",argc); printf("They were:\n"); i = 0; while (i < argc) { printf("argv[%d] is %s\n",i,argv[i]); i++; } }
C
#include <stdio.h> void main() { int n, i, res, m, arr[50], sum = 0; int size = 0, b[50]; printf("How many number you want to enter ?\n"); res=scanf("%d", &n); if( n == 0 || n ==1 || n>10 || (res!=1) ) printf("Not right size of array"); else { printf("Enter %d Numb...