language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
//// 10 - Է¹޾ Ǵϴ α׷ Ͻÿ. //// ( - 4 ̰, 100 ƴ or 400 ) //#include <stdio.h> //int main( ) //{ // int year; // Է¹ // // printf(" Է: "); // scanf("%d", &year); // // if(((year%4==0)&&(year%100!=0))||(year%400==0)) // printf("\n"); // else // printf("\n"); //}
C
#include<stdio.h> #include<stdlib.h> #include<stdbool.h> int enqueue(int queue[], int *back, int *p, int a){ (*p)++; queue = (int *)realloc(queue, (*p) * sizeof(int)); queue[*back] = a; (*back)++; } int pop(int *front){ (*front)++; } int main(){ int n, i, j; scanf("%d",&n); int a[n]; ...
C
#pragma once #include <inttypes.h> #include <math.h> struct MidiNote { uint8_t channel; uint8_t note; uint8_t velocity; static double getFrequency(int midiNote) { return 440.0 * powf(2.0, (midiNote - 69) * 0.08333333333333333); } };
C
//100~999ˮɻ #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <math.h> int main(void) { int i = 100; do { //λ int a = i % 10; //ʮλ int b = i / 10 % 10; //λ int c = i / 100; if (pow(a, 3) + pow(b, 3) + pow(c, 3) == i) { printf("%d\n", i); } i++; } while (i < 1000); }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* read_filepart_3.c :+: :+: :+: ...
C
/* Problem Statement : Accept N numbers from user check whether that numbers contains 11 in it or not. Input : N : 6 Elements : 85 66 11 80 93 88 Output : 11 is present Input : N : 6 Elements : 85 66 3 80 93 88 Output : 11 is absent */ #include "Header.h" int main() { int iValue = 0; int *ptr = NULL; int ...
C
#include<stdio.h> #include<locale.h> int main() { setlocale(LC_ALL, "Russian"); int n,s,k=0,r=0; printf(" "); scanf_s("%d", &n); s = n; // // - while (5 < 6) { // if (s % 10 == 0) { break; } else { s /= 10; k++; } } if (k == 1) { printf(" , ...
C
#pragma once #include "Nest/Api/NodeArray.h" #ifdef __cplusplus extern "C" { #endif /// Structure describing a symbol table, with multiple entries /// Note that the entries will be allocated after this structure. struct Nest_SymTab { struct Nest_SymTab* parent; ///< The parent symbol table Nest_Node* node; ...
C
//Maximum intervals overlap #include <stdio.h> void insertionSort(int a[],int n){ for(int i=1;i<n;i++){ int j=i-1; int key=a[i]; while(j>=0 && a[j]>key){ a[j+1]=a[j]; j=j-1; } a[j+1]=key; } } void maxGuests(int a[],int e[],int n){ insertionSort...
C
#include <ctype.h> #include <limits.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/time.h> #include <sys/types.h> #include <sys/wait.h> #include <getopt.h> #include "find_min_max.h" #include "utils.h" pid_t currentPID; int ShowZombies(){ FIL...
C
/* * An implementation of the ARC4 algorithm * * Copyright (C) 2001-2003 Christophe Devine * * 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 * ...
C
/* * channel.h * * Created on: May 30, 2021 * Author: jpaca */ #ifndef CHANNEL_H #define CHANNEL_H #include "main.h" #include <stdint.h> #include "board_defines.h" typedef struct channel_t { GPIO_TypeDef * port; uint16_t pin; }channel_t; // Function to convert loc to channel_t // check loc and compare ...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> char opr1[50],opr2[50]; struct stack { char data[1000]; struct listItem *next; }; typedef struct stack STACK; //create a new node STACK *createStack() { STACK *create; create = (STACK*)malloc(sizeof(STACK)); create->next=NULL; return create; } //insert...
C
#include "BinTree.h" #include <malloc.h> #include <assert.h> #include <stdio.h> #include <string.h> #include "Queue.h" BTNode* BinaryTreeFind(BTNode* pRoot, BTDataType x) { if (pRoot == NULL) return NULL; if (pRoot->_data == x) return pRoot; BTNode* pTemp = NULL; if (pTemp = BinaryTreeFind(pRoot->_pLeft, x)) ...
C
/* * MyShell Project for SOFE 3950U / CSCI 3020U: Operating Systems * * Copyright (C) 2015, Albert Fung 100520898, Jason Runzer 100520992, Nicholas Gregorio 100514374 * All rights reserved. * */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <dirent.h> #include <sys/types.h> #include <sys/wa...
C
#include <stdio.h> #include <math.h> #include <conio.h> #define true 1 #define false 0 #define err -2000123000 #define max 2147483646 typedef struct { double inet, vlc, oth, sms, mms, abr; } user; double stod1(char s[1000]) { int i = 0, o = false; double sm = 0; if (s[0] == '-') ...
C
#include "holberton.h" /** * cant_read - prints error message upon failure to read * @str: filename * Return: void */ void cant_read(char *str) { dprintf(STDERR_FILENO, "Error: Can't read from file %s\n", str); exit(98); } /** * cant_write - prints error message when n fails to create or to write to file * @s...
C
/* ======================================== * * Nicholas Jannuzzi * CMPE121 Spring 2016 * * * Lab Exercise 1, part 1B: PWM control of LED * * * ======================================== */ #include "project.h" #define Pot_Min 1 #define Pot_Max 65535 int32 reading; int main(void) { //initialize modules ...
C
/* ** main.c for lo in /home/munoz_d/CPE_2015_BSQ/src ** ** Made by Munoz David ** Login <munoz_d@epitech.net> ** ** Started on Sun Dec 20 21:38:17 2015 Munoz David ** Last update Sun Dec 20 22:38:28 2015 Munoz David */ #include <stdlib.h> #include <stdio.h> #include <sys/stat.h> #include <sys/types.h> #include <...
C
#include<stdio.h> int main() { char s[20]; gets(s); int i=0,l=0; while(s[i]!='\0') { l++; i++; } printf("%d",l); return 0; }
C
// Benchmark latency of various methods to learn the CPU ID. // // CPUID gives the initial APIC ID // RDTSCP gives the "processor ID" // RDPID is the same as RDTSCP but doesn't give the clock // // RDPID not available in Haswell #include <stddef.h> #include <stdio.h> #include <inttypes.h> #include <stdbool.h> #include...
C
void print_buffer(CSV_BUFFER *buffer) { int i, j; printf("\n"); for (i = 0; i < buffer->rows; i++) { for (j = 0; j < buffer->width[i]; j++) { printf("%c%s%c%c", buffer->text_delim, buffer->field[i][j]->text, buffer->text_delim, buffer->field_delim); } prin...
C
#include<stdio.h> #include<string.h> int main() { char s[1000] ; int i ; gets(s) ; if(strlen(s)>80){ printf("lenth is gretter then 80\n") ; } for(i=0 ;i<strlen(s);i++){ if(i%10==0){ printf("\n") ; } printf("%c",s[i]) ; ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "instructions.h" // обход дерева, // включение, исключение и поиск узлов, void instruction_bst() { blue(); printf("\n\t\t\t\t\t\t\t\t\t\tМеню:\n\ \t\t\t\t\t\t\t▍▹ 1. %-30s\n\ \t\t\t\t\t\t\t▍▸ 2. %-30s\n\ \t\t\t\t\t\t\t▍▹ 3. %-30s...
C
#include "geometry.h" #include <stdlib.h> #include <stdio.h> #include <math.h> /* Construit le point x y z */ Point3D pointXYZ(float x, float y, float z) { Point3D tmp; tmp.x = x; tmp.y = y; tmp.z = z; return tmp; } /* Construit le vecteur x y z */ Vector3D vectorXYZ(float x, float y, float z) { Vector3D tmp; ...
C
#include "gen_queue.h" #include <stdlib.h> #include <assert.h> #include <pthread.h> #include <stdbool.h> #include <stdio.h> //appends an item to the end of the Queue. //Queue does not take ownership of the item, must be allocated/deallocated elsewhere int gen_append(struct gen_queue * Q, void * item) { //lock critica...
C
#include <stdio.h> #include <string.h> #define TRUE 1 #define FALSE 0 int prepare_key(char *key) { char buffer[]; char Table = {A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y,Z}; toupper(*key); for(i=0; i<strlen(key); i++) { for(j=0; j<strlen(key);j++) { if(strcmp(k...
C
#include<stdio.h> #include<stdlib.h> void moveZeroes(int* nums,int size); int main() { int nums[] = {3,0,0,84,12,0,1,0}; moveZeroes(nums,8); for(int i=0;i < 8;i++) printf("%d\t",nums[i]); } void moveZeroes(int* nums,int size) //[3,12,0,1,0] { int* temp = (int*)malloc(size*sizeof(int)); temp = calloc(size,si...
C
#include<stdio.h> #include<conio.h> void main() { int year; printf("Enter the year:"); scanf("%d",&year); if(year%4==0&&year%100!=0||year%400==0) printf("The year is leap year.\n"); else printf("The year is not a leap year.\n"); getch(); }
C
// // Created by sebastian on 10/11/2019. // #include <stdio.h> #include <stdlib.h>.//me gusto mucho la interaccion int main() { int n,m, max = -1,min=1000000; printf("--------------------------\n"); printf("Valor M%cximo de la Matriz!\n",160); printf("--------------------------\n"); printf("Ingres...
C
/// Author: Terry Hsu /// Test case for creating memdom domains #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <smv_lib.h> #include <memdom_lib.h> #include <pthread.h> #define NUM_THREADS 10 #define NUM_MEMDOMS_PER_THREAD 100 // Thread stack for creating memdoms void *fn(void *args){ int i = ...
C
/*------------------------------------------------------------------------------ * 4190.308 Computer Architecture Spring 2020 * * Bomb Lab * * Handout: May 6, 2020 * Due: May 20, 2020 11:00 * * The binary bomb notifies the bomblab server automatically when you solve a * ...
C
/* * Copyright 2017, Crank Software Inc. All Rights Reserved. * * For more information email info@cranksoftware.com. */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <inttypes.h> #ifdef WIN32 #include <windows.h> #else #include <unistd.h> // for usleep #endif #include <gre/greio.h> #include "...
C
/*Joao Guilherme Araujo - 9725165 */ #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> /*-----------------Trie and its functions--------------------*/ //Trie data structure definition struct Trie{ char ending; //1 if a terminating character of a word struct Trie *node[26]; }; typ...
C
#include <stdio.h> struct node { int burst_time; int wait_time; int turn_around_time; int exec_time_left; }; int main(int argc, char const *argv[]) { int n, i, j, slice, update; struct node process_list[10]; printf("Enter number of processes[max 10]: "); scanf("%d", &n); printf("Enter time slice: "); scanf...
C
//Newton-Raphson Root Finding Method //Algorithm: //xi+1 = xi - f(xi)/f'(xi) //Example: find the roots of f(x) = 2x2 -x -21 //% cat newt3.cpp // Newton-Raphson method for finding the // roots of f(x) = 0 for a polynomial function #include <iostream> using namespace std; #include <cmath> double newton(double a, do...
C
#include<stdio.h> int main() { int n=10,arr[n]; int max=0,s,i,j,z; for (i=0;i<10;i++) scanf("%d",&arr[i]); i=0; for (j=0;j<10;j++) { z=arr[i]; if (z<0) max=i; i++; } i=0; for (j=0;j<10;j++) { z=arr[i]; if (z<0&&z>arr[max]) max=i; i++; } if (max!=0||arr[max]<0){ s=arr[9]; arr[9]=a...
C
#include <stdlib.h> #include<stdio.h> struct node{ int data; struct node* next; }; struct node* top=NULL; void push(int key){ struct node* newnode=(struct node*)malloc(sizeof(struct node)); newnode->data=key; newnode->next=NULL; if (newnode==NULL){ printf("stack overflow"); }else{ ...
C
/** Code file for hash tables. */ #include <stdlib.h> #include <string.h> #include <stdio.h> #include <assert.h> #include "storer.h" #include "eprintf.h" static State *linked_lookup(char *prefix[], int create, PrefixStorer* ps); static void linked_add(char *prefix[], char *word, PrefixStorer* ps); static void pr...
C
/* * I2C ͨѶЭʵ飨2016-5-13 5 17:35 PM) I2C 鷳ĵطʱ⣬ǰǽӴ Uart ЭͲе 1602 ҺI2C ǰЭ鶼ҪЩֱʾĻͼ£ SCL ----__--__--__--__--__--__--__--__--__--__---- SDA --_S_/7 \/6 \/5 \/4 \/3 \/2 \/1 \/0 \/a \_T_-- ܽһ I2C ͨѶ 1. SCL Ϊʱźţʱӵزͷͣ SCL Ϊߵƽʱȶ 2. ʼλֹͣλͼе S Tͼ S T λöӦΪ ͵ƽʼλ SCL SDA Ϊ ߵƽʱ SDA һʱʾݴĿʼ֮෴ SCL SDA Ϊ͵ƽʱ SC...
C
#include <stdio.h> #include <math.h> #include <complex.h> int main() { double a,b,c; scanf("%lf", &a); scanf("%lf", &b); scanf("%lf", &c); double D = pow(b, 2) - 4 * a * c; if (D > 0) { D = sqrt(D); printf("%f\n%f\n", (-b + D) / (2 * a), (-b - D) / (2 * a)); } else if (D ==...
C
#include<stdio.h> #include<stdlib.h> #include<gmp.h> #include<math.h> #include"arithZn.h" void mpzExpo_mod(mpz_t result, mpz_t m, mpz_t e, mpz_t n){ /*int i = 0; size_t fin = 0; mpz_t t; mpz_t m; mpz_t tmp; mpz_init (t); mpz_init (tmp); mpz_set(t,m); mpz_set(result,b); fin = mpz_size...
C
#include <stdio.h> int A[100][100], B[100][100]; int main() { int n, m, i, j; scanf("%d %d", &n, &m); for (i=0; i<n; i++) for (j=0; j<m; j++) scanf("%d", &A[i][j]); for (j=0; j<m; j++) for (i=0; i<n; i++) B[j][i] = A[i][j]; for (j=0; j<m; j++) { for (i=0; i<n; i++) printf("%d ", B[j][i]); printf...
C
# include <stdio.h> int strindex(char[], char[]); int main(void) { printf("%d\n", strindex("Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo", "buffalo")); // answer - 56 } int strindex(char s[], char t[]) { int pos = -1; int i, j; for (i = 0; s[i] != '\0'; i...
C
#include <netinet/in.h> #include "unpheader.h" void print_fdset(fd_set s) { printf("{"); int fisrt = 1; for(int i=0;i<FD_SETSIZE;++i) { if(FD_ISSET(i,&s)) { if(!fisrt) printf(",%d",i); else printf("%d",i); fisrt = 0; } }...
C
/* * Exercise 2-8 * * Write a function rightrot(x, n) that returns the value of the integer x * rotated to the right n bit positions. */ #include <stdio.h> unsigned rightrot(unsigned x, int n); int main() { unsigned x = 9713; // 0010 0101 1111 0001 printf("%u\n", rightrot(x, 4)); return 0; } unsigned right...
C
#include <stdio.h> #include <cs50.h> #include <string.h> int main(int argc, string argv[]) { // Check for proper input if( argc == 1 || argc > 2 ) { printf("%i",1); return 1; } string keyword = argv[1]; int key_len = strlen(keyword); int key[key_len]; // Check for ...
C
#include <stdio.h> #include "read_input.h" int main(void) { int first, second; read_int("Syötä ensimmäinen kokonaisluku: ", &first); read_int("Syötä toinen kokonaisluku: ", &second); if (first % second == 0) printf("%i on %i:n %i. monikerta.\n", first, second, first/se...
C
#include <stdio.h> int main() { int* pc, c; c = 5; pc = &c; c = 1; printf("%d", c); // Output: 1 printf("%d", *pc); // Ouptut: 1 }
C
/* A year is leap year if the following conditions are satisfied: 1.Year is multiple of 400. 2.Year is multiple of 4 and not multiple of 100. pseudo-code: if year is divisible by 400 then is_leap_year else if year is divisible by 100 then not_leap_year else if year is divisible by 4 then is_leap_year el...
C
#include <stdio.h> #include <cs50.h> #include <math.h> #define K25 25 #define K10 10 #define K5 5 int main(void) { float balance; do { printf("Gimme a float: "); balance = get_float(); } while(balance <= 0); // convert balance to kobo int kobo = (int)round(balance * 10...
C
#include <Polynomail.h> void AddPolynomial(const Polynomial Poly1, const Polynomial Poly2, Polynomial PolySum) { int i; ZeroPolynomial(PolySum); PolySum->HighPower = Max(Poly1->HighPower, Poly2->HighPower); for(i = PolySum->HighPower; i >= 0; i--) { PolySum->CoeffArray[i] = Poly1-...
C
#include "../include/options.h" #include <getopt.h> static struct option long_opts[] = { {"execute", required_argument, NULL, 'e'}, {"version", no_argument, NULL, 'v'}, {"help", no_argument, NULL, 'h'} }; int main(int argc, char *argv[]) { int opt; int retcode = 0; extern char *...
C
// Written by Cezary Migazewski - Last Edit 1/1/16 my_float kepler_equation (my_float e, my_float M) { my_float E, E0, f0, f1, f2, f3, d1, d2, d3, delta, nu; int i; E = M; delta=1; i=0; while ((delta>1e-8) && (i<100)) { ++i; E0=E; f0=E-e*sin(E)-M; f1=1-e*cos(E); f2=e*sin(E); ...
C
#include<cs50.h> #include<stdio.h> #include<math.h> int sum_of_digits(long long number, long long odd_or_even); int even_addition(int digit); int get_digits(long long number, long long loop, int decision); int main(void) { printf("Please enter a credit card number \n"); long long number = get_long_long(); ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> char* readLine(char* buffer) { char c; int i = 0; while((c = getchar()) != '\n') { buffer[i++] = c; } buffer[i] = '\0'; return buffer; } int main(void) { char buffer[100]; while(1) { printf("$ "); readLine(buffer)...
C
/* * File: scheduler.h * Description: The main scheduler * ***************************************************************************** * Copyright 2021 Scott Maday * Check the LICENSE file that came with this program for licensing terms */ #pragma once #include "x86_64/isr.h" #define SCHEDULER_QUEUES_NUM _S...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_lltoa_base.c :+: :+: :+: ...
C
#include "holberton.h" /** *_pow_recursion - return value f x raised to power y *@x: x value *@y: value being raise to *Return: returns int **/ int _pow_recursion(int x, int y) { if (y < 0) return (-1); if (y == 0) { return (1); } return (x * _pow_recursion(x, y - 1)); }
C
#ifndef IMM_LIST_H #define IMM_LIST_H #include "api.h" #include "container.h" #include <stdbool.h> struct imm_list { struct imm_list *next; struct imm_list *prev; }; IMM_API void imm_list_init(struct imm_list *list); IMM_API void imm_list_add(struct imm_list *neu, struct imm_list *head); IMM_API void imm_list_de...
C
#include "ind_lt_neg.h" int ind_lt_neg(int a, int arr[100]) { int x = 0; for (int i = 0; i > a; i++) { if (arr[i] < 0) { x = i; } } return x; }
C
/* ** EPITECH PROJECT, 2019 ** minishell1 ** File description: ** my_getenv.c */ #include <unistd.h> #include <stdlib.h> #include "../include/structures.h" #include "../include/my.h" char *my_getenv(name_t *value, name_t *name, char *elem, char **command) { char *path; int count = 0; char **pathes; ch...
C
#include <stdio.h> #include <conio.h> #include <stdlib.h> int wordcount(char s[],int x) { int n=0; if(s[0]!='\0') { for(int i=0;i<x && s[i+1]!='\0';i++) if(s[i]==' '&& s[i+1]!=' ') n++; n=s[0]==' '?n:n+1; } return n; } int main() { char s[100]; pr...
C
/** * Header file for config file management. * @author John Bellardo */ #ifndef CONFIG_H #define CONFIG_H #include <stdlib.h> #include <stddef.h> #ifdef __cplusplus extern "C" { #endif typedef void *(*CFG_parseCB_t)(const char *key, const char *value, void *data, void *p1, void *p2); struct CFG_ParseCB { ...
C
#include <stdio.h> // 共用体类型的定义 struct mystruct { int a; char b; }; // a和b其实指向同一块内存空间,只是对这块内存空间的2种不同的解析方式。 // 如果我们使用u1.a那么就按照int类型来解析这个内存空间;如果我们使用u1.b那么就按照char类型 // 来解析这块内存空间。 union myunion { int a; char b; }; typedef union xx { int a; char b; double c; }XXX; union test { int a; float b; }; int main(void)...
C
# include <stdlib.h> # include <stdio.h> # include <math.h> # include <time.h> # include <string.h> int main ( int argc, char *argv[] ); char ch_cap ( char ch ); int ch_eqi ( char ch1, char ch2 ); int ch_to_digit ( char ch ); int file_column_count ( char *input_filename ); int file_row_count ( char *input_filename ); ...
C
/* LzmaRamDecode.h */ #ifndef __LzmaRamDecode_h #define __LzmaRamDecode_h #include <stdlib.h> /* LzmaRamGetUncompressedSize: In: inBuffer - input data inSize - input data size Out: outSize - uncompressed size Return code: 0 - OK 1 - Error in headers */ int LzmaRamGetUncompressedSize( ...
C
#include<stdio.h> #define Max 10 int Q[20]; int front=-1,rear=-1,data; void exit(); void insert_Q() { if(front==0 && rear==Max-1) { printf("\n\t\t\t!......Q_Overflow......!\n"); } else if(front!=0 && rear==Max-1) { rear=0; printf("\n\t\t\tEnter data:"); scanf("%d",&Q[rear]); rear=...
C
/* * FM hello world * based on Programming the AdLib/Sound Blaster FM Music Chips * http://www.shipbrook.net/jeff/sb.html * * Tested with djgpp and DOSBox */ #include <stdlib.h> #include <stdio.h> #include <time.h> #define ADDR_PORT 0x388 #define DATA_PORT 0x389 typedef char* string; void outb(const int port...
C
// // Created by hlhd on 2021/5/7. // #include "../all.h" void stdInCallbackEP(evutil_socket_t fd, short what, void* arg) { char buf[1024]; printf("stdin_callback start %s\n", (char*)arg); int ret = read(fd, buf, sizeof(buf)); buf[ret] = '\0'; printf("buf is %s\n", buf); printf("stdin_callback...
C
/** * Ŀʹõĺ궨塣 */ #include <NkUtils/types.h> #include <NkUtils/log.h> #include <string.h> #ifndef NK_ASSERT_H_ #define NK_ASSERT_H_ NK_CPP_EXTERN_BEGIN /** * ʱ㡣 */ #define NK_CHECK_POINT() \ do {\ NK_PChar file = strrchr(__FILE__, '/');\ printf("\r\n-- @ %s:%d \r\n\r\n", !file ? __FILE__ : file + 1, __LINE...
C
#include <stdio.h> #include <ctype.h> #include <stdlib.h> #include <cs50.h> string ari(string s) { string grade; float chara = 0, word = 0, sentence = 0; for(int i = 0; i<strlen(s); i++) { if(isalnum(s[i])) { chara = chara + 1; } if(s[i]==' ') { word = word +1; } ...
C
#include<stdio.h> #include<math.h> #include<stdlib.h> #define cuenta 472395814 //FUNCION DEPOSITO float depo(float capital,float d){ float saldo; capital+=(capital*0.0125)+d; return(capital); } //FUNCION RETIRO float ret(float capital,float retiro){ float saldo; capital=capital-retiro; ...
C
// made by Ankit Das // on 15 July 2020 // tested on gcc 8 #include<stdio.h> #include<stdbool.h> #include<stdlib.h> int MAX = 0; void display(int *array) { int i = 0; printf("\n"); for(i = 0; i < MAX; i++) printf("%d ",*(array + i)); printf("\n"); } void insert(int *array, int ...
C
/* bgrep - A binary grep tool. */ #include "blib.h" #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x20 int flip_pe_la_flag(char* name) { map_file(name, WRITE_FILE); if( CH_BUF(0) != 'M' || CH_BUF(1) != 'Z' ) goto invalid_ret; // MZ header missing. uint32_t pe_loc = U32_BUF(0x3C); if ( U32_BUF(pe_loc) != 0x4550 ) ...
C
#include <stdio.h> #include <string.h> int main(int argc, char *argv[]){ int n,i; int x; scanf("%d", &n); int pre[n]; for(i=0; i<n; i++){ scanf("%d", &x); pre[x-1]=i+1; } for(i=0; i<n; i++){ printf("%d", pre[i]); } return 0; }
C
#include <stdio.h> int main(){ int a[10]; a = {1,2,3,4,5,6,7,8,9,10}; int i; printf("the size of an integer in my version of C is %d\n",sizeof(int)); printf("a is %d\n",a); for (i=0;i<10;i++){ printf("the ADDRESS of a[%d] is %d\n",i, &(a[i])); } return 0; }
C
#include "stdlib.h" #include "stdio.h" #include "string.h" void inverseArr(char *myArr){ char *p1 = NULL; p1 = myArr; if(*p1 == '\0' || p1 == NULL) return; inverseArr(p1+1); //˴ȲִУջȳ printf("%c",*p1); } int main(){ char *p1 = "avsbfgsfg"; int len1 = strlen(p1); inverseAr...
C
/** * @file pthread_ex.h * @brief function definitions for threading example in hw3 * @author Andrew Kuklinski * @date 02/18/2018 **/ #include <pthread.h> #include <stdio.h> #include <stdlib.h> extern pthread_mutex_t locking; //struct to be used to pass information between threads typedef struct{ int member1; ...
C
#include <stdio.h> #define MAX(x, y) ( ((x) > (y)) ? (x) : (y)) #define MIN(x, y) ( ((x) < (y)) ? (x) : (y)) #define N 7 int policzWode(int *histogram); int main(){ int histogram[N] = {3, 5, 4, 2, 1, 7, 2}; printf("Maksymalny stan zgromadzonej wody wynosi %d.\n", policzWode(histogram)); return 0; } in...
C
// ------------------------------------------------------------------------ // NAME: Victor Gorchilov // CLASS: 11a // NUMBER: 8 // PROBLEM: #1 // FILE NAME: strlen.c (unix file name) // FILE PURPOSE: creating strlen without use of library // ------------------------------------------------------------------------ #in...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> #include"answer10.h" #include<strings.h> #include<inttypes.h> char** explode(const char* str, const char* delims,int* arrLen) { int num_delim = 0; // No. of delimiters in the string 'delims' int str_index = 0; // String Index // This Below lo...
C
/* * Definition for singly-linked list: * struct ListNode { * int val; * struct ListNode* next; * }; */ #include <math.h> int countNodes(struct ListNode* head) { int count = 0; struct ListNode* current = head; while (current != NULL) { count++; current = current->next; } return count;...
C
#include "holberton.h" /** *_strpbrk - searches a string for bytes * *@s: string *@accept: string * *Return: a pointer to s or NULL */ char *_strpbrk(char *s, char *accept) { int i, j, pos, flag = 0; for (i = 0; s[i] != '\0'; i++) ; pos = i; for (i = 0; accept[i] != '\0'; i++) { for (j = 0; s[j] != '\...
C
#include "invArray.h" typedef struct tabinv{ inv_t* vettInv; int nInv; }tabInv_t; tabInvP invTinit()//inizializza il wrapper per l'inventario { tabInvP tabInv; tabInv=(tabInv_t*)malloc(sizeof(tabInv_t)); tabInv->nInv=0; return tabInv; } inv_t* sObjL1(tabInvP tabInv,int f) { return &(tabIn...
C
#include<stdio.h> #include<stdlib.h> struct node{ int data; struct node *link; }; struct node *create(struct node *,int); void traverse(struct node *); void exit(); int main(){ struct node *start=NULL; int choice,n; printf("\t\t\t\t\t\t\t\t\t\t\t CREATION AND DISPLAY OF LINKED LIST"); printf("\n\n\n\n\...
C
#include<stdio.h> int main() { char a[100]; int b1=0,c1=0,d1=0,e1=0,f1=0,g1=0,i; scanf("%s",&a); for(i=0;a[i]!='\0';i++) { if(a[i]=='{') b1++; else if(a[i]=='[') c1++; else if(a[i]=='(') d1++; else if(a[i]=='}') e1++; else if(a[i]==']') f1++; else g1++; } if(b1==e1&&c1==f1&&d1==g1) printf("yes"); else printf("no"); }
C
#include<stdlib.h> #include<locale.h> int main(){ setlocale(LC_ALL,NULL); printf("File is %s\nDate %s\nTime %s\nLine %d\n",__FILE__,__DATE__,__TIME__,__LINE__); return 0; }
C
#include<stdio.h> #include<stdlib.h> #include<unistd.h> #include<sys/types.h> #include<pwd.h> #include<string.h> #include <dirent.h> #include <errno.h> int checkdir(char *directory) { DIR* dir = opendir(directory); if (dir) { /* Directory exists. */ closedir(dir); return 1; } else if (ENOENT == errno...
C
#include "lib/pen.h" enum opcao{vai = 1, volta = -1}; void dragao(Pen &p, float tam, int n, opcao op, float desl){ if(n == 0){ p.walk(tam); return; } dragao(p, tam, n - 1, vai, desl - 10); p.right(90 * op); dragao(p, tam, n - 1, volta, desl + 10); } void frac_dragao(){ Pen pen...
C
#include <stdio.h> #define TAMANIO 20 void imprimir(int* elemento); void ordenar(int* elemento); void main (void) { int elemento[] = {16, 20, 9, 7, 10, 6, 11, 2, 12, 8, 14, 1, 15, 5, 17, 3, 18, 13, 19, 4}; imprimir(elemento); ordenar(elemento); } void imprimir(int* elemento) { int i; for (i = 0; i < TAMA...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> void main() { FILE *fp,*fp1; int d; char c[20],s[20],t; fp = fopen("fileA", "a+"); printf("Enter the country\n"); scanf("%s", s); while (fscanf(fp, "%20s", c)==1) { if (strcmp(strupr(s), strupr(c)) == 0) { fseek(fp, ftell(fp) + 1, SEEK_SET); ...
C
#include <stdio.h> #include <stdbool.h> #include <ctype.h> double compute_average_word_length(const char *sentence); int main(int argc, char *argv[]) { if (argc != 2) { fprintf(stderr, "Usage: %s \"Enter a sentence in quotes.\"\n", argv[0]); return 1; } printf("%.2f\n", compute_average_word_length(argv...
C
/*=========================================================================== gary.c This team forms a loose pattern once the ball is aquired. The robot that finds the ball is the captain. The others flank him diagonally, hoping to catch the kicks of the opposing team. Gary Boone gboone@cc.gatech...
C
# include <stdio.h> # include <stdlib.h> # define MAX 100 //The Binary Counter function takes an Array and size n as its //parameters. It traverses the Array from right to left and //increments the value by 1. void binCounter(int A[], int n){ int i; for (i=n-1; i>=0; i--){ if (A[i]==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() { typedef struct{ int i; int j; } posT; posT pos1; pos1.i=1; pos1.j=2; printf("The i is %d\n",pos1.i); //Pointers should first be initialized here or segment fault posT pos2; posT *ppos=&pos2; ppos->i=3; printf("The i is %d\n",ppos->i); printf("The j is ...
C
#include <stdio.h> #include <ncurses.h> #include <stdlib.h> #include <time.h> #include <ncurses.h> #include <unistd.h> int initall(void) { initscr(); return 0; }; int enditall(void) { endwin(); return 0; } // Init a cell matrix with zeros CellMatrix* Init_matrix(int n_rows, int n_cols) { struct CellMatrix*...
C
/* * Sean Keough * GitHub: SKeough117 * * set.c - CS50 'set' module * * see set.h for more information. * * Sean Keough, January 2020 * */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "set.h" #include "memory.h" /******************* file-local global variables ****************/ /* no...
C
#include "dominion.h" #include "dominion_helpers.h" #include <string.h> #include <stdio.h> #include <assert.h> #include "rngs.h" int main(){ int i; int k[10] = {adventurer, council_room, feast, gardens, mine, remodel, smithy, village, baron, great_hall}; int tempCount; int actualCoun...