language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdint.h> #define SIZE 4 // given a sequence of bytes, run length encode the string // and then decode it. struct In { int in[SIZE]; }; struct Out { int out[SIZE]; }; void compute( struct In *input, struct Out *output ) { int i; int j; int outp = 0; bool skip = 0; // worst case is no ...
C
#include <stdio.h> #include <stdlib.h> int main() { int n=19; int r; while(n!=0) { r=n%2; n=n/2; printf("%d",r); } return 0; }
C
/************************************************ * 我的版本比答案好一点。 * 答案还是不能处理Integer.MIN_VALUE. * 我的版本可以。 ***********************************************/ #include <stdio.h> static void itob(int n, char *s, int b); static void reverse(char *s, int from, int to); int main(void) { char s[10]; int x = -21474836...
C
#include <stdio.h> int maximum(int x, int y, int z); int minimum(int a, int b, int c); int main(void) { int number1; int number2; int number3; printf("Enter three numers: "); scanf("%d%d%d", &number1, &number2, &number3); printf("Maximum is: %d\n", maximum(number1, number2, number3)); printf("Min...
C
/* $Header$ */ /* * Author: Peter J. Nicklin */ #include "null.h" #include "hash.h" #include "macro.h" /* * htrm() removes a hash table entry. If key is null, the entire hash * table is removed. */ void htrm(key, hash) char *key; /* key for hash table entry */ HASH *hash; /* hash table */ { HASHBLK *htbr...
C
#include<stdio.h> int main(void) { int i, a, b, x; scanf("%d %d", &a, &b); x = b; for(i = 1; i <= a; i++, b++) { if(i < x) { printf("\t"); } printf("%d%c", i, b % 7 == 0?'\n':'\t'); } return 0; }
C
#pragma once #include<stddef.h> typedef char seqType; typedef struct seqlist { seqType* data; size_t size; size_t capacity; }seqlist; void SeqlistInit(seqlist* seq); void SeqlistPushBack(seqlist* seq, seqType value); void SeqlistPushFront(seqlist* seq, seqType value); void SeqlistPopBack(seqlist* seq); void...
C
#include <stdlib.h> #include <stdio.h> #include "Pilha_interface.h" Stack *stCreate(){ Stack *st = (Stack*)malloc(sizeof(Stack)); st->elements = listCreate(); st->destroyFunction = NULL; return st; } void stDestroy(Stack **stackAddress, StDestroyMode mode){ Stack...
C
#include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> #include "asmbl.h" #include "pass.h" #include "misc.h" #include "files.h" #include "globals.h" /* static REGISTER r0, r1, r2, r3, r4, r5, r6, r7; */ /* * ─── START HERE ──────────────────────────────────────────────────────...
C
int main() { float a,b,c,*Pc,*Pa,*Pb; printf("enter value of a and b:"); scanf("%f%f",&a,&b); Pa=&a; Pb=&b; Pc=&c; *Pc=*Pa+*Pb; printf("\n\nSum=%f",c); }
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <strings.h> #include <sys/socket.h> #include <sys/types.h> #include <pthread.h> #include <arpa/inet.h> #define SERV_PORT 6666 #define MAX_CLIENT 32 #define KEY "2015032042" #ifdef BUFSIZ #undef BUFSIZ #define BUFSIZ 1024 #endif ...
C
#include "sched.h" /** Initialises queue mutex, head, and tail. @queue - to initialise @return - result of initialisation */ int initQueue(Queue** queue) { *queue = (Queue*) malloc(sizeof(Queue)); if (pthread_mutex_init(&((*queue)->lock), NULL) != 0) { perror("Queue mutex initialisation failed"); ...
C
#include <string.h> #include <errno.h> const int sys_nerr = 41; const char *sys_errlist[] = { [0] = "Success", /* 0 */ [EPERM] = "Operation not permitted", /* 1 */ [ENOENT] = "No such file or directory", [ESRCH] = "No such process", [EINTR] = "Interrupted system call", [EIO] = "I/O error"...
C
#include<stdio.h> #include<conio.h> #include<stdlib.h> #include<malloc.h> typedef struct bst { int data; struct bst*left; struct bst*right; }node; node*create(); void insert(node* , node*); void inorder(node*); int main() { char ch; node*root=NULL,*N; do { N=create(); if(root==NULL) root=N; else insert(root,N); print...
C
#include <assert.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include "buddy.h" static int _test_size(struct buddy *buddy, unsigned int size) { unsigned int offset; int rc; if ((rc = buddy_alloc(buddy, size, &offset)) == 0) printf("%s>size=%d, offset=%d\n", __FUNCTION__, size, off...
C
/* * File: newmain.c * Author: Nathlia Ohana * * Created on 25 de Maro de 2020, 22:24 */ #define _XTAL_FREQ 2000000 // CONFIG #pragma config FOSC = EXTRC // Oscillator Selection bits (RC oscillator) #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled) #pragma config PWRTE...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* parser.c :+: :+: :+: ...
C
#ifndef LIBFT_H # define LIBFT_H # include <stdio.h> # include <string.h> # include <stdlib.h> # include <stddef.h> # include <unistd.h> void *ft_memset(void *s, int c, size_t n); //fill memory with repeated bytes void ft_bzero(void *s, size_t n); //establishes the first n bytes of a stryng to 0 void *ft_memcpy(void *...
C
#include <stdio.h> #include <stdlib.h> int main() { int a,b; printf("Enter the value of a and b"); scanf("%d %d",&a,&b); printf("Sum of two Values is %d",a+b); return 0; }
C
#include<stdio.h> int main() { char c = ' ', x; getc(c); if((c >= 'a') && (c <= 'z')) x = convert(c); printf("%c", x); return 0; }
C
#include "lx_string.h" #include <string.h> //extern void *memcpy(); /** * Add a string to the end of a lx_gd. * * Flush when gd is full. * * Returns 0 on success. */ char lx_gdstrput (gd, ss1) lx_gd *gd; const lx_s *ss1; { register unsigned int left; lx_s ss2; /* no need for initialization with a mirror *...
C
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <fcntl.h> #include <err.h> #include <errno.h> #include <time.h> #include <clo.h> #include <jansson.h> #include "cJSON.h" uint64_t ntime(void) { struct timespec tv; clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tv); return ((uint64_t) tv.tv_sec * 10...
C
/** \file main.c * * \brief main loop * * \author Tim Ingersoll * * \copyright Copyright (c) 2019 TT Electronics * All rights reserved. * * \date 12 September 2019 * \version 1 */ #include <sys/ioctl.h> #include <errno.h> #include <stdint.h> #include <stdbool.h> #include <string.h> #include...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> typedef struct Node { struct Node *next; int digit; } Node; Node *makeNode(Node *np, int digit) { Node *newPtr = (Node *) malloc(sizeof(Node)); newPtr->next = np; newPtr->digit = digit; return newPtr; } int len(Nod...
C
#include<stdio.h> int main(){ int i,j,h,a,b,c; for(i=1;i<=4;i++){ for(j=3;j>=i;j--){ printf("0"); } for(h=1;h<=i;h++){ printf("*"); } for(j=2;j<=i;j++){ printf("*"); } for(h=3;h>=i;h--){ printf("0"); } printf("\n"); } for(a=1;a<=3;a++){ for(b=1;b<=a;b++){ pr...
C
#include "Compiler_Cfg.h" /***************************************************************************************/ /*2种 Memory class 的定义 */ /* 内存类AUTOMATIC应作为空定义提供,用于声明本地指针。*/ #define AUTOMATIC /* 内存类TYPEDEF应作为空定义提供。此内存类应在类型定义中使用,其中不能指定内存限定符。 这对于定义指针类型(例如P2VAR)是必要的,其中宏需要两个参数。 可以在类型定义中指定第一个参数(到指针引用的内存位置的距离),但此时不能定...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> int n; int flag = 0; int maxprofit = 0; typedef struct { int profit;//10-30 int weight;//5-20 int mark; int upperBound; }item; typedef struct { float value; int index; }node; float KWF2(int i, int weight, int profit, node t...
C
#include "string.h" #include "types.h" #include "x86/multiboot.h" #define EARLYALLOC_SZ 2048 extern int main(int argc, char **argv); multiboot_t mboot; static uintptr_t earlyalloc(unsigned len) { static uint8_t buf[EARLYALLOC_SZ]; static unsigned idx = 0; if (idx + len >= EARLYALLOC_SZ) return NULL; u...
C
#include "functions.h" struct num { int number; int freq; }; int x; struct num S[16];// for S-boxes int testIP(char * line) { char *values; char s[2] = ","; int flag=0; values = strtok(line, s); int count=0; int i_value; struct num obj[64]; int i; for(i = 0; i < 64; ++i) { obj[i].number=i+1; obj[i]...
C
/*Sergeev Sergey 10-6 14.05.2016*/ #include<stdio.h> #include<conio.h> #include<stdlib.h> #include"SORT.h" void FillIncr( int *A, int N ) { int i; for (i = 0; i < N; i++) A[i] = i + 1; } void FillDecr( int *A, int N ) { int i; for (i = 0; i < N; i++) A[i] = N - i; } void FillRand(...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <time.h> #include "scoreText.h" #define TEMP 20 #define STEP 0.1 #define COUNT 10000 char *bifidDecipher(char *key, int period, char *in,char *out, int len); float bifidCrack(char *text,int len, char* maxKey, int period); static cha...
C
// // main.c // rpn // // Created by William McCarthy on 192//20. // Copyright © 2020 William McCarthy. All rights reserved. // // did 4.3 and 4.4 // did 4.5 in class // couldn't do 4.6 #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <math.h> #include <string.h> #define MAXOP 100 /* max ...
C
// prints a demo matrix then inputs one row at a time and prints the matrix #include <stdio.h> #include <stdlib.h> #include <ctype.h> main(){ int row,col,r,c; int a[3][5]={ {2,3,7,4,0}, {3,6,90,8,6,}, //demo Matrix {23,11,87,55,34} }; for(r=0;r<3;r++){ for(c=0;c<5;c++){ if(c<4) printf(" %...
C
/* * 4.cpp * * Created on: 2011-1-9 * Author: jsgl */ int main() { int a[1000][1000]; int m, n, i ,j; cin>>m>>n; for(i=1; i<=m; i++) for(j=1; j<=n; j++) { cin>>a[i][j]; } for(i=0; i<=m+1; i++) a[i][0]=a[i][n+1]=-1; for(i=0; i<=n+1; i++) a[0][i]=a[m+1][i]=-1; for(i=1; i...
C
#include <stdio.h> #include <stdlib.h> #include "gamelib.h" int main (){ int scelta; extern int end_mappa; system("clear"); do{ printf("\t\t**************************************************************************** \n"); printf("\t\t* ...
C
/* A program that asks the user to input a phrase. The program returns whether the phrase is a palindrome or not. */ #include <stdio.h> #include <ctype.h> #define MAXLINE 100 enum bool{false, true}; typedef enum bool bool; int type_phrase(char string[]); bool check_pal(int last, char string[]); int main(void) { ...
C
#ifndef EXPR_H #define EXPR_H #include <stdint.h> #include "token.h" typedef int number_t; typedef struct { var_t *var; } lval_t; struct comp_expr { struct expr *left; op_t operator; struct expr *right; }; typedef struct comp_expr comp_expr_t; typedef enum { IMMEDIATE_NUM, // constant IMMED...
C
#ifndef SERIAL_CAST_H #define SERIAL_CAST_H #include <windows.h> wchar_t* wcstring(char* std){ size_t newsize = sizeof std + 1; wchar_t * wcstring[newsize]; // Convert char* string to a wchar_t* string. size_t convertedChars = 0; mbstowcs_s(&convertedChars, wcstring, ne...
C
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <time.h> #define PASS_SIZE 16 int main(void){ char *password; int i; srand(time(0)); password = calloc(1, PASS_SIZE+1); for (i = 0; i < PASS_SIZE; i++) { password[i] = rand() % ('z'-' ') + ' '; } ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> void main() { int nums[] = {1,2,3,4,5,6,7,8}; int numsSize = sizeof(nums)/sizeof(nums[0]); int ret = 0; ret = singleNumber(&(nums[0]),numsSize); if(ret){ printf("ret = %d \n",ret); }else{ printf("error ret = %d\n",ret); } }
C
#include <stdio.h> #include <fcntl.h> #include <stdlib.h> int main( void ) { if(open("tmpfile",O_RDWR) < 0) { printf("open error!\n"); exit(-1); } if(unlink("tmpfile") < 0) { printf("unlink error\n"); exit(-1); } printf("file unlinked\n"); sleep(15); printf("Done\n"...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h> //#include <ctype.h> //#include <gmp.h> /* * The prime 41, can be written as the sum of six consecutive primes: * * 41 = 2 + 3 + 5 + 7 + 11 + 13 * * This is the longest sum of consecutive primes that adds to a prime below * one-hund...
C
// CONSTANTS: #define MAX_CLIMB_SUM_ERR 10 #define MAX_CLIMB 1 #define CLOCK 16 #define MAX_PPRZ (CLOCK*600) #define CLIMB_LEVEL_GAZ 0.31 #define CLIMB_GAZ_OF_CLIMB 0.75 #define CLIMB_PITCH_OF_VZ_PGAIN 0.05 #define CLIMB_PGAIN -0.03 #define CLIMB_IGAIN 0.1 const float pitch_of_vz_pgain=CLIMB_PITCH_OF_VZ_PGAIN; const...
C
/*-------------------------------- ----------Sergeev_Sergey---------- --------------------11_6---------- -----------------group_B---------- --------------29.11.2016---------- --------------------------------*/ #include<stdio.h> #include<stdlib.h> #include"NB.h" #include<ctype.h> void GetStr(char *Str, int Ma...
C
/** @file */ /** * @brief zwraca rozmiar pliku * * @param f plik * @return int */ int get_file_size(FILE *f); /** * @brief kopiuje header z wejściowej bitmapy do wyjściowej * * @param info właściwości */ void copy_header(struct Meta *info); /** * @brief czyta i zwraca plik wejściowy po jednym bicie * ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_substr.c :+: :+: :+: ...
C
//#include<stdio.h> // //int main(void) //{ // double w,h,area,perimeter=0; // // // printf("簢 :"); // scanf("%lf", &w); // printf("簢 :"); // scanf("%lf", &h); // Է // // area = w*h; // perimeter = 2 * ( w + h ); // // // printf("簢 : %lf\n簢 ѷ : %lf\n", area, perimeter); // // // return 0; //}
C
#include <stdio.h> int main() { int test; scanf("%d", &test); while (test--) { int sum = 0; int min = 987654321; int num[7] = {0}; for (int i = 0; i < 7; i++) scanf("%d", &num[i]); for (int i = 0; i < 7; i++) if (num[i] % 2 == 0) { sum += num[i]; if (min >= num[i]) min = num[i]; } p...
C
#include <stddef.h> #include <avr/io.h> #include <avr/interrupt.h> #include "util.h" static volatile timer_command command; // command executed after n seconds static int number_of_interrupts; // number of interrupts necessary to wait n seconds /* * disable the timer used by "wait...
C
/*! * @file tcp.c * @brief Definitions for functionality that handles TCP client operations. */ #include "precomp.h" #include "common_metapi.h" #include "tcp.h" /*! * @brief Writes data from the remote half of the channel to the established connection. * @param channel Pointer to the channel to write to...
C
#include<stdio.h> void main() { int choice = 0; printf("Enter the choice what to eat"); scanf("%d",&choice); switch (choice) { case 1: printf("Food item - Burger\n\nPrice - Rs 129"); break; case 2: printf("Food item - Pizza\n\nPrice - Rs 239"); break; case 3: printf("Foo...
C
/********************************************************************************* Copyright 2006-2009 MakingThings 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...
C
// Copyright (c) Acconeer AB, 2018-2019 // All rights reserved #ifndef ACC_SERVICE_H_ #define ACC_SERVICE_H_ #include <stdint.h> #include "acc_sweep_configuration.h" /** * @defgroup Services Services * * @brief Radar services provided by Acconeer * * @details Experimental * * In our code you might e...
C
#include <stdio.h> #include <math.h> // #define M 640 //rows #define N 480 //columns int x,y; double ex=0.50; double ey=0.50; double ez=-1.00; double lx=0.00; double ly=1.25; double lz=-0.50; double spheres[2][7] = { {1.00,0.5,1.00,0.25,0,255,0},{0,0.75,1.25,0.5,255,0,0}}; double ground[7]={0.50,-20000.00,0.5,20...
C
// lab03 // is_leap_year // Zixuan Guo z5173593 #include <stdio.h> int main (void) { int year; printf("Enter year: "); scanf("%d", &year); if (year % 4 != 0) { printf("%d is not a leap year.\n", year); } else if (year % 100 != 0) { printf("%d is a leap year.\n", year); ...
C
#ifndef __KERNEL_MEMORY_H #define __KERNEL_MEMORY_H #include "bitmap.h" #include "stdint.h" // 内存池标记 enum pool_flags { PF_KERNEL = 1, // 从内核内存池中分配 PF_USER = 2 // 从用户内存池中分配 }; // page directory entry 和 page table entry 的低3位 #define PG_P_1 1 #define PG_P_0 0 #define PG_RW_R 0 #define PG_RW_W ...
C
#include <stdio.h> #include <stdlib.h> void insert ( int , int , int); void print(int); void delete ( int , int); void multiplication(); struct node{ int coefficient; int exponent; struct node* link; }; struct node* start[3]; int n; int main() { start[0] = NULL; start[1] = NULL; start[2] = NULL;...
C
#include "holberton.h" /** * puts_half - check the code for Holberton School students. * @str: Variable. * Return: Not have. */ void puts_half(char *str) { int a, div; a = 0; for (; str[a] != '\0'; a++) { } if ((a % 2) == 0) { div = a / 2; while (div < a) { _putchar(str[div]); div++; } } el...
C
// PROGRAM TO FIND FACTORIAL OF A BIG NUMBER WHICH CANNOT FIT IN A SINGLE VARIABLE. /***********************************************************************************/ #include<stdio.h> #include<conio.h> #include<string.h> #define MAX 200 void initarr(int num[]); void factorial(int num[],int fact[]); int c...
C
#include<stdio.h> #include<stdlib.h> #include<fcntl.h> #include<errno.h> #include<unistd.h> #include<sys/types.h> #include<sys/socket.h> #include<string.h> #include<arpa/inet.h> #include<netinet/in.h> #define pf printf #define sf scanf int main() { FILE *fp1; char fname1[100]; pf("enter file namae for 1st file \n");...
C
#include <stdio.h> #include <pthread.h> typedef struct msg{ char *first; char *second; }msg; typedef struct box{ msg *m; }box; void showt( void * vp){ box *p = (box *)malloc( sizeof( box)); p = (box *) vp; printf("fist = %s second = %s", p->m->first, p->m->second); } int main(){ msg *line = (msg ...
C
#include <textmode.h> #include <archx86.h> #include <fonctions.h> #include <bioscall.h> #include <cpux86.h> static char kX = 16; /* position courante du curseur a l'ecran */ static char kY = 16; static uchar kattr = 0x07; /* attributs video des caracteres a afficher */ /* * 'scrollup' scrolle l'ecran (la console ma...
C
#include <stdio.h> #include <fcntl.h> #include <unistd.h> #include <string.h> int main( int argc, char **argv) { int gpio_pin = 18; int fd; char buff[BUFSIZ]; fd = open("/sys/class/gpio/export", O_WRONLY ); if (fd == -1) { perror("fail to open export." ); ...
C
#include<stdio.h> #include<conio.h> void main() { char a[10],b[10],c[20],k; int n,i; clrscr(); printf("enter string 1\n"); gets(a); printf("enter string 2\n"); gets(b); k=0; for(i=0;a[i]!=0;i++) { c[i]=a[i]; k++; } for(i=0;b[i]!='\0';i++) {c[k]=b[i]; k++; } c[k+1]='\0'; puts(c); getch(); }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include "wchar.h" #include <locale.h> struct wc { int str_num; int words_num; int chars_num; }; int main(int argc, char *argv[]) { char *locale = setlocale(LC_ALL, ""); wint_t prev; wint_t c; struct wc* arr = (s...
C
/********************************************************************* ** Author: Nick DaCosta ** ** Class: 310 <Section 01> ** ** Assignment: pa 4 ** ** Certification of Authenticity: ** ** I certify that this assignment is entirely my own work. ** **************************...
C
// // Created by matthias on 31.01.17. // #include "include/HelpFunctions.h" void createResultFolder(char* folder_path, struct stat buf) { // "results" folder does not exist -> create it if (stat(folder_path, &buf) == -1) { mkdir(folder_path, 0700); } } char* createResultFile(char* folder_path, i...
C
int max(int x[],int h) { int i,da=x[0],k=0; for(i=1;i<h;i++) { if(x[i]>da) { da=x[i]; k=i; } } return(k); } int min(int x[][10],int l,int d) { int i,xiao=x[0][d],k=0; for(i=1;i<l;i++) { if(x[i][d]<xiao) { xiao=x[i][d]; k=i; } } return(k); } void main() {...
C
#include<stdio.h> #include<string.h> #include<stdlib.h> //include<sys/socket.h> //for sockaddr //include<netinet/in.h> //for sockaddr_in #include<sys/fcntl.h> //for O_RDONLY #include<netdb.h> #define SERVER_PORT 5000 #define BUF_SIZE 4096 int main(int argc, char *argv[]) { int c,s,bytes; char buf[BUF_SIZE...
C
#include<stdio.h> #include<stdarg.h> #include<stdlib.h> #include<string.h> #include<ctype.h> #include<math.h> #include<locale.h> #define pi 3.14159265358979323846 #define e 2.71828182845904523536 #define EPSILON 0.0000000001 #pragma warning( disable:4996) typedef enum error { ERRORTYPE_WITHOUT_ERROR,...
C
#include <arpa/inet.h> #include <stdio.h> #include "arp_client.h" int main(int argc, const char **argv) { struct sockaddr_in sin; inet_pton(AF_INET, argv[1], &sin.sin_addr); sin.sin_family = AF_INET; struct hwaddr rep; areq((void *)&sin, sizeof(sin), &rep); int i; for (i = 0; i < rep.sll_halen; i++) printf("%...
C
// ADC.c #include <stdint.h> #include "inc/tm4c123gh6pm.h" // ADC initialization function Channel 1 (PE2) // Input: none // Output: none void ADC_Init(void){ volatile uint32_t delay; SYSCTL_RCGCGPIO_R |= 0x10; //initialze clock for Port E delay = SYSCTL_RCGCGPIO_R; GPIO_PORTE_DIR_R &= ~(0x04); ...
C
/* * Functions to define the character set * and do things specific to the character set. */ #pragma noroot #include "less.h" #ifdef _ORCAC_ segment "LoadSegONE"; #endif /* * Predefined character sets, * selected by the LESSCHARSET environment variable. */ struct charset { char *name; char *desc; } charsets[]...
C
#include <stdlib.h> #include <time.h> #include <stdio.h> #include "params.h" #include "tree.h" #include "parse_args.h" #include "initialise.h" #include "rng.h" #include "timer.h" static inline TYPE_COMPLEX ipow(int n) { TYPE_COMPLEX i; i = (n & 0x1) ? I : TYPE_ONE; i *= (n & 0x2) ? -TYPE_ONE : TYPE_ON...
C
# include "stack.h" # include "huffman.h" # include <stdint.h> # include <stdbool.h> # include <stdlib.h> # include <stdio.h> // Stack file provided by Darrell Long via Piazza, it is slightly modified to work for our purposes # define MIN_STACK (10) stack *newStack(void) // Construct a stack { stack *s = (stack *) ...
C
#include <stdio.h> #include <sys/types.h> /* defines types used by sys/stat.h */ #include <sys/stat.h> /* defines S_IREAD & S_IWRITE */ int main() { int fd; fd = creat("datafile.dat", S_IREAD | S_IWRITE); if (fd == -1) printf("Error in ...
C
#include <stdio.h> #include <stdlib.h> #define PARENT(i) (i)/2 #define LEFT(i) 2*(i) #define RIGHT(i) 2*(i)+1 typedef struct heap { int *a; int length; int size; } heap; heap* heap_create(int size); int heap_insert(heap *h, int key); int heap_set_key(heap *h, int i, int key); int heap_get_max(heap...
C
class Solution_205 { public: bool isIsomorphic(string s, string t) { unordered_map<char, char>s2t; unordered_map<char, char>t2s; int j = 0; for (int i = 0; i < s.size(); ++i) { //哈希表中已经存在一个相同的key值了,但是key值映射的哈希值不一致,说明不是同构 if (s2t.count(s[i]) && s2t[s[i]]!=t[i] || t2s.count(t[i]) && t2s[t[i]] != s[i])...
C
#include <stdio.h> #include <limits.h> char* foo (int x) { if ((x+1) > x) return "true" ; else return "false"; } int main ( void ) { printf("INT_MAX = %d", INT_MAX); printf("\n(INT_MAX +1) > INT_MAX : %s",foo(INT_MAX)); return 0; }
C
#include<stdio.h> #include<string.h> int main() { char name[50]; printf("Enter your name: "); scanf("%s",name); int a[50]; int n,j,count=0,i=0; //LOOP TO PRINT THE ASCII VALUES, STORE EACH DIGIT OF ASCII CODE AS ELEMENTS OF AN ARRAY AND UPDATE THE ELEMENT COUNT for(j=0;j<strlen(name);j++) { n=(i...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> /* char *ft_bzero(char *str) { int i; i = 0; while (str[i]) { str[i] = 0; i++; } return (str); } */ void brainfuck(char *str) { char ret[2048]; int i; int c; int j; int b; j = 0; i = 0; c = 0; while (i < 2048) { ret[i] = 0; i++; } i ...
C
#include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <stdio.h> #include <iostream> int main() { int fd, result, data=222; size_t size; char name[] = "1.txt"; (void)umask(0); fd = open(name, O_RDONLY); read(fd, &data, 2); std::cout<< data<<std::endl; close(fd); return 0; }
C
#include<stdio.h> #include<stdlib.h> void main(){ FILE *f; char ch; int charcount=0, whitecount=0, linecount=0, tabcount=0; f=fopen("abc.txt", "r"); if(f==NULL){ printf("File not found"); exit(0); } while((ch=fgetc(f))!=EOF){ charcount++; if (ch==...
C
#include <unistd.h> int main(int argc, char** argv) { int i; i = 0; while(argv[0][i] != '\0') i++; write(1, *argv, i); return (0); }
C
#include<stdio.h> const int a = 1, b = 2; void main() { int a = 2; switch(a) { case 1: printf("PPA\n"); break; case 2: printf("JAva\n"); break; } } /* vivek@vivek-HIRAY:~/Desktop/Co...
C
/*** *ismblgl.c - Tests to see if a given character is a legal MBCS char. * * Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved. * *Purpose: * Tests to see if a given character is a legal MBCS character. * ****************************************************************************...
C
#include "input.h" /* - LEITURA DE ENTRADA - */ Graph *read(char *file_name) { char line[1000]; FILE *file; int lineCount = 0; Graph *G; G = malloc(sizeof(Graph)); file = fopen(file_name , "r"); while((fgets(line, sizeof(line), file)) != NULL) { char *aux; if (lineCount == 0) { /* First line contain...
C
//Tom McClintock //PHYS 105 //to compile: $gcc passbyvalue.c -o passbyvalue.exe //to run: $passbyvalue.exe #include <stdio.h> //This will be a short function that //adds one to the variables void add_one(int i, int*p); int main() { //Declare some variables we will use int i = 2, j = 77; int* p = &j; printf("...
C
/** * Listas duplamente encadeadas * * @author Mateus Calza * * Baseado no exemplo do Professor Kurt Schneider **/ #include <stdlib.h> #include <stdio.h> #include <string.h> struct lista { int valor; struct lista *anterior; struct lista *proximo; }; typedef struct lista Lista; Lista *lista_cria(void) { ...
C
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> int arrangeCoins(int n){ int i = 0; int sum = 0; do { i++; sum = sum + i; } while (sum < n); if (sum == n) return i; else return i - 1; } int main() { printf("%d ", arrangeCoins(5)); system("pause"); return 0; }
C
#include "stdio.h" #include "set.h" #include "stack.h" int main() { printf("\n"); //i. //init set intSetPtr s1 = initIntSet(5); //add values addToSet(s1, 10); addToSet(s1, -3); addToSet(s1, 88); addToSet(s1, 765); addToSet(s1, 21); //ii. //print set printf("Set 1: "); ...
C
#include <stdio.h> #define MAXLINE 1000 #define NUM 80 int getline_(char line[],int lim); void copy(char longest[],char line[]); main() { int len; char line[MAXLINE]; while((len = getline_(line,MAXLINE)) > 0) { if(len > NUM) { printf("%s",line); } } return 0; } int getline_(char line[],int lim) { int...
C
#include <string.h> #include "../common/common.h" #include "./deviceKeyGeneration.h" #include "../aacs-crypto-primitives/aacs-crypto-primitives.h" void xorBuffers(byte *dest, byte *xor, uint length) { uint i; for(i = 0; i<length; i++) { dest[i] ^= xor[i]; } } /** * This function derives lower l...
C
#include<stdio.h> #include<stdlib.h> struct node { int info; struct node *link; }; typedef struct node node; node* insert_rear(int item,node* first); node* delete_front(node* first); void display(node* first); void main() { node* first=NULL; int choice,item; for(;;) { printf("1:insert_rear 2:delete_fr...
C
/* ------------------------------ Nome: Pedro Jos Garcia Nmero USP: 11846943 ------------------------------ */ #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <windows.h> #include <locale.h> struct auxiliar{//nicio estrutura (estrutura para auxiliar na excluso de produtos alugados). char codP...
C
#include <stdio.h> #include <string.h> void main() { char s[100]; int i, j, n; printf("输入字符串:"); gets(s); n = strlen(s); for (i = 0, j = n - 1; i < j; i++,j--) { if (s[i] != s[j]) { break; } } if (i >= j) { printf("是回文串"); } else { ...
C
void InsertSort(int[],int); int SaiMa(int[],int[],int); void main() { int horse_n[100];//?? int horseTian[100][1000]; int horseQi[100][1000]; int horse_i=0;//??(???+1) int i; scanf("%d",&horse_n[horse_i]); do { for(i=0;i<horse_n[horse_i];i++){ scanf("%d",&horseTian[horse_i][i]);} for(i=0;i<...
C
//Octothorpe (1/15/17) //Shadow, Mage Tower Foyer //Designed by Ivyes #include <std.h> #include "../defs.h" inherit VAULT; void create() { ::create(); set_property("indoors",1); set_property("light",2); set_travel(PAVED_ROAD); set_terrain(STONE_BUILDING); set_climate("temperate"); set_name("Foyer...
C
#include<stdio.h> long long isSquare(long long n) { long long x; x = n; while(!(n==x*x || (n>x*x && n<(x+1)*(x+1)))) { x = (x+(n/x))/2; } return (x*x==n)? x : 0; } int main() { long long a,b,x,y,c,d; a = 1; while(a<2000) { x = (a*(3*a-1))/2; b = a+1; while(b<3000) { y = (b*(3*b-1))/2; c = isSquar...
C
#pragma once #include "Token.h" #include "Type.h" #include "Scope.h" typedef enum Operator_Bin { OPERATOR_BIN_ASSIGN = TOKEN_ASSIGN, OPERATOR_BIN_LOGICAL_AND = TOKEN_OPERATOR_LOGICAL_AND, OPERATOR_BIN_LOGICAL_OR = TOKEN_OPERATOR_LOGICAL_OR, OPERATOR_BIN_PLUS = TOKEN_OPERATOR_PLUS, OPERATOR_BIN_MINUS = ...