language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #define MAX_COUNT 10000000 void count(void); pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; int counter = 0; int main (void) { int rc1, rc2; pthread_t thread1, thread2; if ((rc1 = pthread_create(&thread1, NULL, (void *)count, NULL))) { printf("Thre...
C
/* * * mm.c - The fastest, least memory-efficient malloc package. * */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include <unistd.h> #include "mm.h" #include "memlib.h" /****DEFINING MACROS************/ /* single word (4) or double word (8) alignment */ #define ALIGNMENT 8 /*...
C
#include "mcp7940m.h" /* Declaring an instance of twim Peripheral. */ static const nrf_drv_twi_t twim = NRF_DRV_TWI_INSTANCE(BOARD_TWI); void MCP79GetTime(uint8_t *recvTime) { uint8_t *buff = recvTime; /* Set address of first byte */ buff[0] = MCP79_REG_RTCSEC; nrf_drv_twi_tx(&twim, ADDR_MCP7940M, buf...
C
#include<stdio.h> void display(); int x=5; //GLOBAL VARIABLE void main() { int x=10; //LOCAL VARIABLE printf("%d\n",x); display(); } void display() { printf("%d",x); }
C
#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> int main() { //FILE * pf; char str[1024] = {0}; sprintf(str, "%d", 12345); printf("%s\n",str); //12345 //pf = fopen("test.txt","w"); //if(pf != NULL) //{ // fputs("fopen example",pf); // fclose(pf); //} //pf = fopen("test.txt", "a"); ...
C
#include "queens.h" //zamiana pionkow na krolowe void swap_to_queen(char board[8][8]) { int i=7; for(int j=0;j<7;j+=2) { if(board[i][j]=='O') board[i][j]='o'; } i=0; for(int j=1;j<8;j+=2) { if(board[i][j]=='X') board[i][j]='x'; } }
C
#include <stdio.h> int main() { int a[5] = {1,2,3,4,5}; int result = 0; int Sum(int [], int); result = Sum(a,5); printf("Sum = %d\n", result); return 0; } int Sum(int a[], int b) { int i, rst = 0; for(i=0;i<b;i++) rst += a[i]; return rst; }
C
/* * TTScheduler.c * * Created on: Feb 14, 2019 * Author: Administrator */ #include <stdint.h> #include <stdlib.h> #include <stdbool.h> #include "Timer_driver/Timer.h" #include "TTScheduler.h" static bool g_bIsValidToRun; static Task_t *g_ptTaskArray; static uint32_t g_ui32NumOfTasks; s...
C
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include "list.h" /** * Print the value of *ev */ void print_chars (void* ev) { char* e = ev; printf ("%s\n", e); } void print_ints (void* ev) { intptr_t e = (intptr_t) ev; printf ("%ld\n", e); } void str_to_int(void** vdst, voi...
C
/* * koar/nodes/reson.c * copyright (c) 2014 Frano Perleta */ #include "buf.h" #include "patchvm.h" #include "nodes/active.h" // state {{{ typedef struct reson_s* reson_t; struct reson_s { enum { PURE_2POLE = 0, RES_GAIN, PEAK_GAIN, LOWPASS, HIGHPASS } mode; s...
C
/* ** EPITECH PROJECT, 2021 ** B-CPE-200-BER-2-1-matchstick-pablo-elias.herrmann ** File description: ** print */ #include "my.h" void print_takes(int player, int nb, int line) { if (player == 1) my_putstr("Player removed "); if (player == -1) my_putstr("AI removed "); my_put_nbr(nb); ...
C
#include<stdio.h> #include<string.h> int main(){ char s1[1000000],s2[1000000]; int i,j,t,n; scanf("%d",&t); while(t--){ scanf("%s",s1); fflush(stdin); scanf("%s",s2); int count[256]={0}; for(i=0;s1[i]!='\0';i++){ count[s1[i]]++; } for(i=0;s2[i]!='\0';i++){ if(count[s2[i]]!=0) break; } if...
C
#include "../inc/fdf.h" t_point **realloc_pts(t_point **pts, t_point *point) { unsigned int i; unsigned int nb_pts; t_point **pts_tmp; nb_pts = 0; while (pts[nb_pts]) nb_pts++; if (!(pts_tmp = (t_point**)malloc(sizeof(t_point*) * (nb_pts + 2)))) return (NULL); i = -1; while (++i < nb_pts) pts_tmp[i]...
C
#include <stdlib.h> #include <stdio.h> typedef void (*FuncionVisitante) (int dato); typedef enum { BTREE_RECORRIDO_IN, BTREE_RECORRIDO_PRE, BTREE_RECORRIDO_POST } BTreeOrdenDeRecorrido; typedef struct _BTNodo { int dato; struct _BTNodo *left; struct _BTNodo *right; } BTNodo; typedef BTNodo * BTree; ///...
C
#include <stdio.h> int main() { long nc; int c, blanks, tabs, new_lines; new_lines = 0; tabs = 0; blanks = 0; nc = 0; while (getchar() != EOF) ++nc; printf("%ld\n", nc); while ((c = getchar()) != EOF) { if (c == '\n') ++new_lines; else i...
C
#include<stdio.h> struct company{ char name[30]; //float term_marks[3]; float income; float cost; float profit; }; int main() { struct company s[3]; int i,j,n; float profit; //float sum[3]={0,0,0}; printf("Enter how many companies:"); scanf("%d", &n); for(j=0;j<n;j++) { printf("Nam...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* color.c :+: :+: :+: ...
C
/* Copyright (C) 2016 Leonard Ding <dingxiaoyun88@gmail.com> */ #include <stdlib.h> #include <stdbool.h> #include <string.h> #include <stdio.h> int uniquePaths(int m, int n) { if(m == 1 && n == 1){ return 1; } int r[m][n]; int i = 0, j = 0; for(i = 1; i < m; i++){ r[i][0] = 1; } for(i = 1; i < n;...
C
/* /Names: Matthew Crepea, Thomas Haumersen /Pledge: I pledge my honor that I have abided by the Stevens Honor System. Matthew Crepea Thomas Haumersen */ #include "../../include/my.h" #include <stdlib.h> /*Help function to my_str2vect * Returns copy of string up to the next space, tab, newline, or * string en...
C
/* ** EPITECH PROJECT, 2020 ** my_strncpy ** File description: ** Copy some string letter by letter */ char *my_strncpy(char *dest, char const *src, int n) { for (int i = 0; i < n; i++) { dest[i] = src[i]; } return dest; }
C
/* ** EPITECH PROJECT, 2019 ** panel ** File description: ** panel */ #include <stdlib.h> #include "../include/my.h" #include "../include/defender.h" void parse_element(game_t *gt, int x, int y) { if (x == -1) x = 0; if (y == -1) y = 0; switch (gt->win.position_map[y][x]) { case 0: ...
C
#include <stdio.h> #include <mem.h> #include "house.h" int main() { house_t houses[2]; house_t house1; strcat(house1.adress,"kossuth6"); house1.area_m2 = 200; house1.number_of_rooms = 10; house1.price = 60000; houses[0] = house1; house_t house2; ...
C
/* * André D. Carneiro e Victória Simonetti */ #include <stdio.h> #include "tokens.h" extern FILE* yyin; extern int yylex(); extern int isRunning(); extern int hashPrint(); extern int initMe(); int main(){ int token; yyin = fopen("teste.ling", "r"); initMe(); while(isRunning()){ token = yylex(); switch...
C
/* * ColorUtils.h * Gui * * Created by Marek Bereza on 05/05/2010. * */ // gets the R, G or B component out of a hex colour #define hexValR(A) ((A >> 16) & 0xff) #define hexValG(A) ((A >> 8) & 0xff) #define hexValB(A) ((A >> 0) & 0xff) int blendColor(int color1, int color2, float amt = 0.5); int colorFloa...
C
/*====================================================================* * * void syslog_error (int priority, errno_t number, char const *format, ...); * * syslog.h * * print user message and system error message using the syslogd * priority; * *. Motley Tools by Charles Maier *: Published 1982-2005...
C
/* * Jacopo Del Granchio * #093-2 12.02.2020 */ #include <stdlib.h> #include <stdio.h> #include <math.h> #include <locale.h> #include <stdarg.h> #include <stdbool.h> #include <string.h> // Costanti #define NC 10 #define NS 50 #define LS 20 // Macro #define chiedi(msg, format, ...) \ printf(msg); \ scanf(forma...
C
#define max(a, b) (((a) > (b)) ? (a) : (b)) #define min(a, b) (((a) < (b)) ? (a) : (b)) int maxProductPath(int** grid, int gridSize, int* gridColSize) { static const int MOD = 1e9 + 7; int M = gridSize, N = *gridColSize; long dp[M][N][2]; for (int i = 0; i < M; ++i) { for (int j = 0; j < N; ++j) { if (i =...
C
/*--------------------------------------------------------------------------------- METRIC.C -Helper functions for metric tensors -Compute 4x4 matrix minor, adjoint, determinant and inverse -Compute connection coefficients -Raise and lower rank-1 tensors -Take dot product of a contravariant and covariant...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* insertsort_step1.c :+: :+: :+: ...
C
/* Pointers programs */ #include<stdio.h> // malloc functions #include<stdlib.h> #include<string.h> void print_char_array(char *c); void print_2d_array(int number[][2] ); int main() { char *c = "venu"; int num[2][2] ; int (*p)[2] = num; for (int i=0 ; i<2; i++ ){ for (int j=0; ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <malloc.h> #include "dk_tool.h" void swap(int *a, int *b); void generation(int *darray, int dsize) { int i; for (i = 0; i < dsize ; ++i) { *(darray+i)=rand() % 10000; } return; } void bubbleSort(int *darray, int dsize) ...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <unistd.h> #include "rpi-gpio.h" // both are "nobody" on my system #define UID_AFTER_DROP 99 #define GID_AFTER_DROP 99 static void drop_privileges(void) { if(chdir("/") == -1) { perror("chdir"); exit(1); } if(setgid(GID_AFTER_DROP) == -1) { pe...
C
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <unistd.h> int in=0, out=0; int buffer[10000]; int count = 0; int mutex = 1; void wait(int *semaphore) { while(*semaphore <= 0) ; *semaphore -= 1; } void signal(int *semaphore) { *semaphore += 1; } void *producer() { int next = 0; ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> void mostrarEmpleados(char[][20], int[], char[], float[], int); void mostrarEmpleado(char[], int, char, float); void ordenamiento(char[][20], int[], char[], float[], int); int main() { char nombres[5][20]; int legajos[5]; char sexo[5];...
C
#include "comm.h" int Command(int size,int flag) { key_t key = ftok(".",1); if(key < 0) { perror("ftok"); exit(1); } int shmid = shmget(key,size,flag); if(shmid < 0) { perror("shmget"); exit(1); } return shmid; } int CreateShm(int size) { return ...
C
#include<stdio.h> #include<string.h> #include<stdlib.h> //structure typedef struct account { int id; char name[20]; float abal; char bday[10]; char addrs[50]; float trns; struct transform { char mode[25]; char transdate[10]; float money; char cmnt[20];...
C
#include<stdio.h> int main() { int a[50][50],i,j,sum=0; for(i=0;i<3;i++) { for(j=0;j<3;j++) { scanf("%d",&a[i][j]); } } for(i=0;i<3;i++) { for(j=0;j<3;j++) { if(i==j) { sum=sum+a[i][j]; } } } printf("sum is : %d",sum); }
C
/*Finding the value of function f(x)=sqrt(3x^3 + 2x^2 + 4)using pow() and sqrt() function*/ #include<stdio.h> #include<math.h> int main() { double x, result; printf("Enter the value of x:"); scanf("%lf", &x); //using sqrt() and Pow() function for getting the result result = sqrt(3*pow(x,3)+2*pow(...
C
//编写一段程序,输入6名学生2门课程(语文、数学)的分数, //显示各门课程的总分和平均分,以及各个学生的总分和平均分。 #include <stdio.h> int main(void) { int stu[6][2]; int i, j; int sum1 = 0; int sum2 = 0; printf("输入学生分数: \n"); for (i = 0; i < 6; i++) for (j = 0; j < 2; j++) { printf("No.%d学生第%d门成绩: ", i + 1, j + 1); ...
C
#include "hash_tables.h" /** * hash_table_get - retrieves a value associated with a key. * @ht: Hash table * @key: key * Return: The value associated to the key */ char *hash_table_get(const hash_table_t *ht, const char *key) { int index; hash_node_t *temp = NULL; char *value = NULL; /* check if table exist ...
C
//#include <stdio.h> // //int main(void) //{ // int nInput = 0; // const int nCUTOFF = 70; // // printf(" Էϼ. : "); // scanf_s("%d", &nInput); // /*printf("%d", nInput);*/ // // if (nInput >= nCUTOFF) printf("հԴϴ.\n"); // else printf("հԴϴ.\n"); // // nCUTOFF = 80; // // return 0; //}
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* vectors_ops.c :+: :+: :+: ...
C
/* * Copyright 2021 Aaron Barany * * 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 agreed to...
C
int main() { int *p; f(p); } void f(int *p) { printf("%d\n", *p); }
C
/** * @file HuffmanDecoder.c * @brief The implementation of the huffman decoder (NeXaS flavor). * @copyright Covered by 2-clause BSD, please refer to license.txt. * @author CloudiDust * @date 2010.02 */ #include <stdlib.h> #include <string.h> #include "Logger.h" #include "BitStream.h" #include ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_putstr_non_printable.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> #include "pqueue.h" #include "graph.h" #include "union_find.h" graph_t kruskal(graph_t graph) { graph_t result = graph_empty(graph_vertices_count(graph)); unsigned int L, R, num_edges = graph_edges_count(graph); vertex_t l = NULL, r = NULL; pqueue_t Q = pqueue_e...
C
#include <stdio.h> int main() { /** * Escreva a sua solução aqui * Code your solution here * Escriba su solución aquí */ int x,y,i, sum=0; scanf("%d", &x); scanf("%d", &y); if(y>x){ i = x; x = y; y = i; } fo...
C
#include <time.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #define MAX_FILE_NAME 100 int main() { srand(time(NULL)); FILE *fp; int count = 1; // Line counter (result) unsigned int line_count = 0; char filename[MAX_FILE_NAME]; char c; // To store a charac...
C
/* * buffer.h * * Created on: Jan 31, 2016 * Author: suma */ #ifndef BUFFER_H_ #define BUFFER_H_ //#include <stdio.h> //#include <stdlib.h> /* malloc, free, rand */ //#include <assert.h> //#include <stdbool.h> // // // //typedef struct circular_buffer //{ // void *buffer; // data buffer // ...
C
#include <stdlib.h> #include <string.h> #include "Qsort.h" #include "utile.h" /* pour IN et OUT */ #include "temps.h" /* pour Chrono */ /* #define useChrono */ #undef useChrono /************************************************************************/ /* tri des donnees */ /************************************...
C
// glob.h - pathname pattern-matching types // #include <glob.h> // The <glob.h> header shall define the structures and symbolic // constants used by the glob() function. // The <glob.h> header shall define the glob_t structure type, which // shall include at least the following members: typedef struct { size_t g...
C
/* ID: wind1900 LANG: C TASK: castle */ #include <stdio.h> int m, n; char square[50][50]; int id[50][50] = {0}, sid = 1; int area[2501], ta; int r = 0, ri, rj; char rc; void search(int i, int j) { if (id[i][j]) return; ta++; id[i][j] = sid; if ((1 & square[i][j]) == 0) { search(i, j - 1); } if ((2 & s...
C
/* See LICENSE file for copyright and license details. */ /* name: TEST007 description: basic while test error: output: G2 I F "main { \ A3 I "x A3 #IA :I j L6 e L4 A3 A3 #I1 -I :I L6 y L4 A3 #I0 !I b L5 h A3 } */ int main() { int x; x = 10; while (x) x = x - 1; return x; }
C
/* * linemeans calculates the mean and variance of each scan line * in one frame of a 3150 pixel TM quart scene. * Leading and trailing bytes are unchanged. * Output is a one-column HIPS file with one or two frames. * If variance is output, output is bandinterleaved (mean,var,mean,var,..). * * Header-lines are d...
C
#include <stdio.h> #include <cs50.h> long get_right_num(string prompt); long ten_ntimes(int n); int company(long num); int if_valid(long num); int main(void) { long num = get_right_num("Number: "); if (company(num) == 1) { printf("AMEX\n"); } else if (company(num) == 2) { print...
C
#include "stm32f10x_gpio.h" void Init() { GPIO_InitTypeDef GPIO_InitStruct; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOE, ENABLE); GPIO_InitStruct.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPU; GPIO_Init(GPI...
C
#include<stdio.h> int main() { long long int n1=0,n2=1,n3=0,i,number; printf("Enter the number of elements:"); scanf("%lld",&number); for(i=2;i<number;++i)//loop starts from 2 because 0 and 1 are already printed { n3=n1+n2; n1=n2; n2=n3; } printf("Last Fibonacci number in the sequence: %lld",n3); return ...
C
/* * Header file that defines various functions and structs for reading the * lang.txt file that defines the programming language to be compiled. */ #ifndef _LANG_H #define _LANG_H #define SCANNER_TAG ("SCANNER") #define PARSER_TAG ("PARSER") #define CFG_TAG ("CFG") #define ILCGEN_TAG ("ILCGEN") #define CGEN_TA...
C
#include <stdio.h> #include <stdlib.h> void main(int argc, char **argv) { FILE *fp; int char_read; char *filename = *(argv+1); char *format = *(argv+2); fp = fopen(filename, "r"); if (fp == NULL) { printf("File not found\n"); exit(0); } do { char_read = fgetc(fp); if ((strcmp(forma...
C
#include "node1_memory_map.h" #ifndef NODE1_JOYSTICK_H_ #define NODE1_JOYSTICK_H_ //Vil legge inn enumen inne i structen så jeg bare kan legge inn en variable av type struct inne i funksjonen //vil så sammen funksjonene til en stor funksjon typedef enum joystick_direction{ LEFT, RIGHT, UP, DOWN, NEUTRAL }joystick...
C
#include "log.h" #include <errno.h> #include <stdarg.h> #include <stdbool.h> #include <stdio.h> #include <string.h> #include <sys/types.h> #include <syslog.h> #include <time.h> #include <unistd.h> #include "common.h" #include "time.h" const char *level_desc[__LOG_LEVEL_MAX] = { "INFO", "WARN", "ERR!" }; const int leve...
C
/* Copyright Statement: * */ /** * @file pwm.h * * Pulse Width Modulation. * */ #ifndef __PWM_H__ #define __PWM_H__ #include "hal_platform.h" #ifdef HAL_PWM_MODULE_ENABLED #include "pinmux.h" #ifdef __cplusplus extern "C" { #endif #define PWM_CLK_SRC_32K (0) #define PWM_CLK_SRC_2M (1) #define P...
C
#include <stdio.h> #include "joueur.h" joueur_t * Creer_Joueur(char * nom, int pa, objet_t inventaire[4], int statut[7]){ joueur_t * joueur = malloc(sizeof(joueur_t)); int i; joueur->nom = nom; joueur->pa = pa; for(i=0; i<4; i++){ joueur->inventaire[i] = inventaire[i]; } for(i=0; i<7; i++){ jo...
C
/* I pledge my honor that I have abided by the Stevens Honor System. * Brandon Patton * Assignment 3 */ #include "cs392_log.h" void logH(char *in){ FILE *file; file = fopen("cs392_shell.log", "a"); //sets up a pointer to log file if(file == NULL){ perror("Error: Failed to open file.\n"); } else { fprint...
C
/* Includes ------------------------------------------------------------------*/ #include "random.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro ---------------------------------------...
C
#include <stdio.h> #include <stdlib.h> /* int *counting_sort_stable(int *array, int n, int min, int max) { int i, j, z; int sorted[n]; int range = max - min + 1; int *count = malloc(range * sizeof(*array)); for (i = 0; i < range; i++) count[i] = 0; for (i = 0; i < n; i++) count[array[i] - min...
C
#ifndef _STDIO_H #include <stdio.h> #endif void astreiheAusgeben(int mitte, int breite) { int i; for(i = 0; i < (mitte - (breite/2)); i++) { printf(" "); } for(i = 0; i < breite; i++) { printf("*"); } printf("\n"); } void stumpfAusgeben(int mitte) { int i; for(i...
C
// The common code for the eval functions is here. // This is meant to be included into the eval functions in board.c u64 taken = black | white; u64 empty = ~taken; // Corners double eeC = 0; // Poison squares (squares that give up corner, or risky x-squares) // This computation is fini...
C
#include <stdio.h> int fact(int n); int powr(int x,int n); double sin(double x); int main() { printf("sin30: %f\nsin31: %f\nsin32: %f\nsin33: %f\nsin34: %f\nsin35: %f\n",sin(30*3.14/180),sin(31*3.14/180),sin(32*3.14/180),sin(33*3.14/180),sin(34*3.14/180),sin(35*3.14/180)); /*To convert the values ??to...
C
#include "hash_aux.h" // Function documentation is available at the header file unsigned int djb2(unsigned char *str){ unsigned int hash = 5381; int c; while ((c = *str++)) hash = ((hash << 5) + hash) + c; return hash; }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* b_cd.c :+: :+: :+: ...
C
/** * helpers.c * * Helper functions for Problem Set 3. */ #include <cs50.h> #include <stdio.h> #include "helpers.h" /** * Returns true if value is in array of n values, else false. */ //binary search algorithm bool search(int value, int values[], int n) { //checks if there are any values in the array ...
C
void main() { char a[3600]; gets(a); char *p; int len,n; len=strlen(a); n=0; for(p=a;p<=a+len;p++) { if(*p!=' ') { n=n+1; } else if(*p==' '&&n!=0) { printf("%d,",n); n=0; } } printf("%d",n-1); }
C
#include void swapnum ( int *var1, int *var2 ) { int tempnum ; tempnum = *var1 ; *var1 = *var2 ; *var2 = tempnum ; } int main( ) { int num1 = 35, num2 = 45 ; printf("Before swapping:"); printf("\nnum1 value is %d", num1); printf("\nnum2 value is %d", num2); /*calling swap function*/ swap...
C
#include "holberton.h" /** * swap_int - Swap two integeres * @a: Integer * @b: Integer */ void swap_int(int *a, int *b) { int aux; aux = *a; *a = *b; *b = aux; } /** * reverse_array - reverses the content of an array of integers * @a: varable to be used * @n: number of elements in array */ void reverse_a...
C
#include<stdio.h> #include<stdlib.h> struct Node { int data; struct Node* left; struct Node* right; }; struct Node* newnode(int data) { struct Node* root=(struct Node*)malloc(sizeof(struct Node)); root->left=NULL; root->right=NULL; root->data=data; return root; } struct Node* queue[100]; int rear=0; int front=...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* add_prefix.c :+: :+: :+: ...
C
#pragma once #include "sort_util.h" void heap_adjust(data_t* datas, int l, int r) { data_t tmp = datas[l]; int i = l; int j = 2 * i + 1; while (j <= r) { if (j + 1 <= r && datas[j] < datas[j + 1]) { j++; } if (datas[i] > datas[j]) { break; } else { swap(&datas[i], &datas[j]); i = j;...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include "total_function.h" /* WHICH BLOCK WOULD YOU LIKE TO SEARCH ? (A1 , A2 , B1 , B3) PLEASE ENTER YOUR CHOICE : a1 STUDENT ID: TP049952 FIRST NAME: JARED GENDER: M BLOCK: A1 ROOM: 1 IDETIFICATION: 990423076521 PHONE: 013...
C
#include <stdio.h> int findDigitalRoot(int number) { while(number >= 10) { number = number % 10 + findDigitalRoot(number / 10); } return number; } int main(int argc, char *argv[]) { int digitalRoot = findDigitalRoot(atoi(argv[1])); printf("Digital root: %d", digitalRoot); return 0; }
C
/** * Hamlog * * Copyright (C) 2011, Jan Kaluza <hanzz.k@gmail.com> * * 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 2 of the License, or * (at your option) any later ver...
C
/* * procfs1.c */ #include <linux/module.h> #include <linux/kernel.h> #include <linux/proc_fs.h> #include <linux/uaccess.h> #define procfs_name "helloworld" struct proc_dir_entry *Our_Proc_File; ssize_t procfile_read(struct file *filePointer,char *buffer, size_t buffer_length, loff_t * offset) { int ret=0; if(s...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* env.c :+: :+: :+: ...
C
#include <stdio.h> #include "WolframRTL.h" #include "functions.m.h" int main(int argc, char *arg[]) { double num1 = 20.4; double num2; WolframLibraryData libData = WolframLibraryData_new(WolframLibraryVersion); Initialize_functions(libData); square(libData, num1, &num2); printf("square %5.2f\n", num2); cube(lib...
C
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main(){ int t,i=0,c=1,j=0; float avg; cin>>t; while(t--) { char a; while(c<3){ scanf("%c",&a); if(a==' ') ...
C
//#include <stdio.h> // //int N, M; //int front, back=-1; //int num; //int cnt; //int q[100000]; //int push(int num) //{ // q[++back] = num; //} //int pop() //{ // return q[front++]; //} // int main() //{ // scanf("%d %d", &N, &M); // // for (int i = 1; i <= N; i++) // { // push(i); // } // for (int i = 0; i < M; i++...
C
/* * Makenna Kidd * CSE 240 * Professor Chen * T+TH 1:30pm - 2:45pm * Due Jan 23th by 11:59pm * * This program hw01q2_2 was rewritten from the provided homework problem into a for loop format to contain * break statements, fix syntax/semantic errors, change numbers to floating point, and allow user input to en...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <fast-aleck/fast-aleck.h> struct fast_aleck_test_case { int count; int passes; int fails; char wrap_amps; char wrap_caps; char wrap_quotes; char widont; }; void fast_aleck_test(struct fast_aleck_test_case *a_test_case, char *a_input, char *a...
C
#include <stdio.h> int length(int x, int y){ if(x>=y) return x-y; else return y-x; } int main(){ int a,b,c,d; scanf("%d %d %d %d",&a,&b,&c,&d); if(length(a,c) <= d) printf("Yes\n"); else if(length(a,b) <= d && length(b,c) <= d) printf("Yes\n"); else printf("No\n"); return 0; }
C
/* Thomas Stoeckert COP 3223H - Final Project Verbs handles pretty much all user input. This file is used both by the "Player" and the "Editor" As such, functions used exclusively by one will be called out in commments. This file is mostly entered through handlePlayerVerb or handleEditorVerb, with th...
C
#include <stdio.h> int main() { char g; // m or f int age; float height; float weight; float BMI = 0; printf("input your age\n"); scanf("%d", &age); printf("what's your gender? m or M for Male, f or F for female\n"); scanf(" %c", &g); printf("what's your weight in kg?\n"); ...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <stddef.h> #define ALPHAB 26 void print_words_alphabetically(char ***alphabetical_array) { int row, col; /*for loop to print words from alphabetical_array*/ for (row = 0; row < ALPHAB; row++) { col = 0; /*using ASCII val...
C
#include "common.h" int main(int argc, char * argv[]) { char *fname; byte buf[MAX_RX_LINE]; byte ackBuf[RXTX_BUFFER_SIZE]; struct sockaddr_in sin; int len, dataLen, receiverSeqnum, firstSeqnum; int s, i; struct timeval tv; char seq_num = 1; FILE *fp; struct Packet ackPkt; struct Packet rxPkt; ...
C
#include <stdlib.h> #include <stdio.h> #include "queue.h" int main(){ struct Queue* queue = new_queue(); add(queue,1); add(queue,2); add(queue,3); while(!isEmpity(queue)) printf("%d\n",getFirst(queue)); return 0; }
C
// Peter Christakos // Andrew Morrison #include <sys/syscall.h> #include <sys/wait.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> struct ancestry { pid_t ancestors[10]; pid_t siblings[100]; pid_t children[100]; }; #define __NR_cs3013_syscall2 378 int main() { pid_t pid1, pid2, pid3; //process ID ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_treat_s_tools.c :+: :+: :+: ...
C
void wait(){ cin.ignore(); cout<<"PRESIONE ENTER PARA CONTINUAR"; cin.get(); } void longitudMaxima(int id,string titulo,int dato1,string dato2){ if(to_string(id).size()>lId){ lId=to_string(id).size(); } if(titulo.size()>lTitulo){ lTitulo=titulo.size(); } if(to_string(dato1).size()>lDato1){ lDato...
C
// // pellet.c // swim_mill // // Created by Michael Handria on 10/29/16. // Copyright © 2016 Michael Handria. All rights reserved. // #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <string.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> #include <unistd.h> #...
C
//----------------------------------------------------------------------------- #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_CSTRING 128 typedef char CString[MAX_CSTRING]; typedef struct { CString FamilyName; CString GivenName; } PersonType; #define PRETTY_PRINT(This) printf("\n---...