language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> void reverse(char *str, int start, int end); int main() { char str[80] = "teri maa ki saaree"; int i, start = 0; for (i=0 ; str[i]!= '\0'; i++) { if (str[i] == ' ') { reverse(str, start, i); start = i+1; } } reverse(str, start...
C
#ifndef _linkedlist_h_ #define _linkedlist_h_ #include <stdio.h> #include <stdlib.h> #include <string.h> #define OK (0) #define ERROR (-1) typedef void* Type; struct _List_Node{ Type *data; struct _List_Node *next; struct _List_Node *prior; }; typedef struct _List_Node List_Node; struct _...
C
#include <stdio.h> #include <conio.h> #include <stdlib.h> #include <string.h> main() { int aux, somadig=0, dig1, dig2, dig3, dig4, dig5, cc, dv, dv2, somad; printf("Informe a conta conrrente:"); scanf("%d", &cc); dig5 = cc%10; aux = cc/10; dig4 = aux%10; aux = aux/10; dig3 = aux%10; ...
C
/** * Judge Online: Caribbean Online Judge. * URL: http://coj.uci.cu/24h/problem.xhtml?pid=2422 * Problem: 2422 - Betty and the Modular Exponentiation * Description * * Betty likes integer–number mathematics, and knows that calculating something like a^b * can produce rather large results when a and b are sufficiently bi...
C
#include <stdio.h> //Standar inputs and outputs, has the main functions in c #include <stdlib.h> //Standar library, it contains functions and manage processes #include <string.h> //It contains macro definitions, constants and declarations of functions #include <math.h> //Defines various mathematical functions and on...
C
#include <stdlib.h> #include <stdio.h> struct PunchCard { int *r1; int *r2; int *r3; }; /* LOL punchcard lol lol lol whoops */ void radixIsort(struct PunchCard p, int col, int len) { int *ptr; switch(col) { case 2: ptr = p.r3; break; case 1: ptr = p.r2; break; case 0: ptr = p.r1; break; } ...
C
// RLG20141229 // analogue.c = read an analogue voltage and vary the brightness of an LED #include <avr/io.h> #include <util/delay.h> int main(void) { // volatile unsigned int val, val2; volatile unsigned int val; DDRB |= 0xff; PORTC |= 0x01; //ADMUX |= (1 << ADLAR); // left-adjust result ADMUX |= (1 << REFS0); ...
C
//Encontrar o numero de elementos pares, numero de elementos impares e numero de elementos primos de um vetor aleatorio #include<stdio.h> #include<stdlib.h> #include<pthread.h> #include<math.h> #include<time.h> #include"timer.h" long int dim; //dimensao do vetor de entrada int nthreads; //numero de threads long int ...
C
#define _XOPEN_SOURCE 700 #include <stdio.h> #include <stdlib.h> #include <time.h> #include <stdbool.h> #include <sys/types.h> #include <signal.h> #include <sys/wait.h> #include <unistd.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> #include "mom.h" #include "philo_general.h" #include "libs/argv_parse...
C
#include<stdio.h> void swap(int*,int*); int main() { int a=10,b=20; swap(&a,&b); printf("a=%d\tb=%d",a,b); } void swap(int*x,int*y) { int temp; temp=*x; *x=*y; *y=*x; printf("x=%d\ty=%d\n",*x,*y); }
C
#ifndef GAME_H #define GAME_H #include <stdbool.h> typedef struct game_s { int n; // number of rows int m; // number of columns double **player1; // payoffs for player 1 double **player2; // payoffs for player 2 int orig_n; // do not change after initialized int orig_m; ...
C
/** * CSC 335 - Analysis of Algorithms * Programming Assignment 1 * Jan-Lucas Fitzanthony Ott, Anthony Fitznathan Pompili, David Quadragesimus Shull * March 28, 2017 */ #include <stdio.h> #include "read_array.c" void heapify(int* heap, int i, int size) { int left = i * 2 + 1; int right = left + 1; in...
C
#include<stdio.h> #include<conio.h> void main() { int a,b; clrscr(); printf("\n enter the numbers:"); scanf("%d %d",&a,&b); if(a==b) printf("\n a and b are equal"); else printf("\n a and b are not equal"); getch(); }
C
// list.c #include <stdio.h> #include <stdlib.h> #include "list.h" struct list_node *list_create(int val) { struct list_node* head = (struct list_node*)malloc(sizeof(struct list_node)); head->val = val; head->next = NULL; return head; } int list_insert_after_recursive(struct list_node **list, int node_val...
C
 #include<stdio.h> void main() { int n,sqr=0; printf("\n\t ENTER THE NO.:= "); scanf("%d",&n); sqr=n*n; printf("\n\t SQUARE OF %d is %d .",n,sqr); }
C
#include "ApproxSeg.h" void ClassiSegProba(double *sequence, int *lgSeq, int *nStep, double *res1, int *res2, int *nbClasse, double *moyennes, double *logP, double *variance_){ /* Compteurs et autres */ int i, k, l, indice; double variance = variance_[0]; /* Variable temporaires */ double * vTmp; vTm...
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> #include <stdlib.h> int main() { char c; printf("Introduza o caracter\n"); scanf("%c",&c); c=toupper(c); if(c!='S' && c!='C' && c!='D' && c!='V'){ printf("Carcter introduzido = \'%c\' ERRO-Carcter invlido!",c); }else if(c=='C'){ printf("Carcter introduzido = \'%c...
C
/*palindrom olup olmadigini bulma*/ #include<stdio.h> #include<conio.h> #include<string.h> int main(void) { char x[10]; int a,b,durum=1; printf("kelime yaz:"); scanf("%s",&x); for(a=0,b=strlen(x)-1;a<=(strlen(x)/2);a++,b--) { if(x[a]==x[b]) { ...
C
#include <stdio.h> #include <math.h> void Forward(int n){ int i,j; float ax[10],ay[10],x,y=0,h,p,diff[20][20],y1,y2,y3,y4; for(i=0; i<n; i++) { printf("x%d: ",i+1); scanf("%f",&ax[i]); } for(i=0; i<n; i++) { printf("y%d: ",i+1);...
C
/* Find How many times a word appears in another sentence */ /* Notice : 5Geeks didn't carried out the promise of announcing the winners , They are liars */ #include<stdio.h> #include<string.h> main() { char string [20] , sentence[2000]; int x ,i ,j , result , l ,t; gets(string); gets(sen...
C
/* 1부터 100 까지 3의 배수는 fizz 5의 배수는 buzz 둘 다 해당하는 경우 fizz buzz를 출력하는 프로그램을 작성 */ #include <stdio.h> int main() { int i; for(i=1; i<=100; i++) { if((i % 15) == 0) { printf("fizz buzz "); } else if((i % 3) == 0) { printf("fizz "); } else if((i % 5) == 0) { printf("buzz "); } else { printf("%d ...
C
#include <msp430.h> #include "DS18B20.h" // Drivers to access DS1822 Temperature Sensor over a 1-wire comm bus from: // https://www.maximintegrated.com/en/design/technical-documents/app-notes/1/162.html ////////////////////////////////////////////////////////////////////////////// // OW_RESET - performs a reset on ...
C
#include "header.h" int bikeIndexMax = 0; void main() { system("mode con cols=75 lines=40"); system("color b"); bool mLoop = true; char strBuffer[256]; char select[10]; char loginId[30]; char loginPwd[30]; char *id = loginId; char *pwd = loginPwd; FILE* f; if (fopen_s(&f, LNAME, "a")) { ...
C
#include <stdio.h> #include <stdlib.h> struct number1{ int odd; struct odd *next; }; struct number2{ int even; struct even *next; }; struct number1 *start1; struct number2 *start2; struct number1 *temp1; struct number2 *temp2; struct number1 *last1; struct number2 *last2; int n; void insert1(){ ...
C
#include <stdio.h> #include <sys/select.h> #include <sys/time.h> #include <unistd.h> int main(void) { struct timeval timer; fd_set readfds; timer.tv_sec=2; timer.tv_usec=500000; FD_ZERO(&readfds); FD_SET(STDIN_FILENO,&readfds); select(STDIN_FILENO+1,&readfds,NULL,NULL,&timer); if(FD_ISSET(STDIN_FILENO,&readfds...
C
week6 Pointers & Dynamic memory allocation segmentation fault การพยายามเข้าถึงหน่วยความจำที่เราไม่ได้จองไว้หรือหน่วยความจำที่นอกเหนือจากตัวเเปรที่เราประกาศไว้ มีโอกาสที่จะถูกระบบปฏิบัติการจะหยุด การทำงานของโปรเเกรม #include <stdio.h> // void addTen(int number[][n]], int n) //คอลลัมต้องใส่ค่าด้วย void addTen(int ...
C
/* Module: list_handler.c * * Purpose: The main purpose of this module is provide functions to deal with and maintain the * list data structures. * * Written by Jesse Costales, Ismael Flores, Julian Escontrias, and Mike Marez. * */ #include "project_manager.h" extern list attribute_names; extern list relation_...
C
/***************************************************************************//** * @file : cox_types.h * @brief : Contains the COX typedefs for C standard types. * @version : V1.0 * @date : 26. May. 2010 * @author : CooCox *************************************************************************...
C
#include "ft_printf.h" static int ft_count_len(long c) { int len; len = 0; if (c < 0) { len++; c = c * (-1); } while (c > 0) { len++; c /= 10; } return (len); } static char *ft_convert_char(char *str, long num, int len, int minus) { if (num != 0) str = (char *)malloc(sizeof(char) * (len + 1)); e...
C
#include "fcounter.h" const char *get_filename_ext(const char *filename) { const char *dot = strrchr(filename, '.'); if(!dot || dot == filename) return ""; return dot + 1; } int collect_children_file_count() { int file_count, status; file_count = 0; while(wait(&status)>0) { /* increase the count if child term...
C
// #include <time.h> // #include <stdlib.h> #include <stdio.h> #include <string.h> #include "chip8.h" // #define STACK_SIZE 16 // #define STACK_MASK 0x0F #define MEMORY_SIZE 4096 extern unsigned short chip8_get_compatibility_flags(); extern UBYTE *mem; // Memory // Stops playing at zero. static unsigned sho...
C
#include <windows.h> #include <stdio.h> #include <math.h> // К заданию 1 enum org_name{ ZAO, OOO, IP, }; // К заданию 2 struct trinagle { float x1,y1,x2,y2,x3,y3,x4,y4; }; // К задание 3 union cond{ struct{ unsigned int on_off : 1; unsigned int SDcard : 1; unsigned in...
C
//指针运算中的优先级 // order.c // C programming // // Created by bhjml on 2020/4/22. // Copyright © 2020 bhjml. All rights reserved. // #include <stdio.h> int data[2]={100,200}; int moredata[2]={300,400}; int main() { int *p1, *p2, *p3; p1 = p2 = data; p3 = moredata; printf(" *p1 = %d, *p2 = %d, *p3 =...
C
#include "lib.h" #include <stdio.h> void main(){ list lst = create_lst(); node* n1 = create_node_by_value(8); node* n2 = create_node_by_value(2); node* n3 = create_node_by_value(5); node* n4 = create_node_by_value(4); add_node(&lst, n1); add_node(&lst, n2); add_node(&lst, n3); add_node(&lst, n4); delete_node(&...
C
#include "holberton.h" int main(void) { int len; int len2; len = _printf("Let's try to printf a simple sentence.\n"); _printf("Length:[%d, %i]\n", len, len); _printf("Negative:[%d]\n", -762534); _printf("Character:[%c]\n", 'H'); _printf("String:[%s]\n", "I am a string !"); len = _printf(...
C
/****************************************************************************** * Copyright (C) 2017 by Alex Fosdick - University of Colorado * * Redistribution, modification or use of this software in source or binary * forms is permitted as long as the files maintain this copyright. Users are * permitted to mod...
C
//Write a C program to check two given integers, and return true if one of them is 30 or if their sum is 30 #include <stdio.h> int main(){ int int1, int2, sum; printf("Enter int1: "); scanf("%d", &int1); printf("Enter int2: "); scanf("%d", &int2); sum = int1 + int2; if ((sum == 30) || (i...
C
/** * @file server.c (IPK projekt 2) * * @brief SFTP - RFC-913 implementation * @date 2021-04-23 * @author F3lda * @update 2021-04-24 */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <sys/stat.h> #include <sys/socket.h> #include <sys/types.h> #include ...
C
#include <stdlib.h> #include "lerror.h" #include "circularBuffer.h" void pushNode(circularBuffer* this, char* value) { circularNode* node; if ((node = malloc(sizeof(circularNode))) == NULL) lerror(MEMORY_ERROR(sizeof(circularNode))); node->next = NULL; if (!this->endQueue) this->endQueue = node; el...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "stdbool.h" struct stack { int val; struct stack* next; }stack; struct stack* head = NULL; void push(int x) { struct stack* new = (struct stack*) malloc(sizeof(struct stack*)); new->val = x; new->next = head; head = new; prin...
C
/*! \file JmsMapMessage.h \brief Describes a JmsMapMessage handle This file describes the functions that can be performed on a JmsMapMessage handle A JmsMapMessage handle corresponds to javax.jms.MapMessage \author Copyright (c) 2002, BEA Systems, Inc. */ #ifndef _JMS_MAP_MESSAGE_H #define _JMS_MAP...
C
#include "list.h" /* * Generic doubly linked list. * head,tail: pointers to first,last element * len : number of nodes * data_size: size of element data in bytes * free_fn: function for deleting data */ struct list { list_node_t *head; list_node_t *tail; unsigned int len; unsigned int data_size; free_func f...
C
// // main.c // lista 02-9 // // Created by Marco Antonio Zambeli on 09/07/13. // Copyright (c) 2013 Marco Antonio Zambeli. All rights reserved. // #include <stdio.h> #include <stdlib.h> int vetneg (float vetor[],int tam) { int i,neg=0; for(i=0;i<=tam;i++) { if(vetor[i]<0) neg++; ...
C
#ifndef BITPRACTICE_H #define BITPRACTICE_H /* The above preprocessor directives are what is called an "include guard". They prevent compilation errors due to the same header file being included multiple times. */ /* This macro contains the number of bits in an int for the current implementation. The sizeof() operato...
C
#include "../includes/rtv1.h" t_object *ft_disk_new(void) { t_object *new; if ((new = (t_object *)malloc(sizeof(*new)))) { new->type = DISK; new->name = "DISK"; new->pos = (t_vector){0.0, 0.0, 0.0}; new->translate = (t_vector){0.0, -1.01, 0.0}; new->rotate = (t_vector){0.0, 0.0, 0.0}; new->scale = (t_v...
C
/* * SurgeScript * A scripting language for games * Copyright 2016-2023 Alexandre Martins <alemartf(at)gmail(dot)com> * * 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://w...
C
#include<stdio.h> #include<string.h> #include<stdlib.h> #pragma warning(disable : 4996) typedef struct _RESULT { // ans struct int ans_count; char words[100]; }_RESULT; char* eliminateSpecial(char* str); void bubbleSort(char* string[], int size); void swap(char* arr[], int front, int back); int main() { ...
C
#include <stdio.h> #include <stdlib.h> #include <ctype.h> int sumFibs(max) { int fibs[512] = {0}; fibs[0] = fibs[1] = 1; int x=1; do { x++; fibs[x] = fibs[x-1] + fibs[x-2]; //add prev 2 } while (fibs[x] <= max); int tot=0; for(int y=x-1; y>=0; y--) tot += (fibs[y] & 1) ? fibs[y] : 0; return ...
C
#include <stdio.h> void main (void) { int num1, num2,result; while(1){ printf("please enter first number "); scanf("%d",&num1); printf("please enter second number "); scanf("%d",&num2); result = num1 + num2; printf("the result is %d \n \n",result); } }
C
#include <stdio.h> #include <string.h> #include <errno.h> #include "common.h" #include "../qrinput.h" #include "../qrencode_inner.h" #include "../split.h" #include "decoder.h" int encodeAndCheckBStream(int mqr, int version, QRecLevel level, QRencodeMode mode, char *data, char *correct) { QRinput *input; BitStream *b...
C
#include <stdio.h> #define x 100 #define y 200 int main(void) { printf("常數 x = %d, y = %d \n", x, y); printf("Pree any key to continue... \n"); getchar(); return 0; }
C
//********************************************************************** // Date: 01/26/2018 // Program to calculate the time for a System call and context switch // //********************************************************************** #define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <string.h> #...
C
/****************************************************************************** calcura area e perimetro de um hexagono *******************************************************************************/ #include<stdio.h> #include<math.h> void calc_hexa(float l, float *area, float *per) { *per = 6 * l; *area = (3 * pow(l...
C
#include<stdio.h> #include<conio.h> main() { int day; printf("Enter the day:"); Scanf("%d",&day); switch(day) { case Monday: printf("True"); break; case tuesday: printf("True"); break; case Wednesday: printf("True"); break; case Thursday: printf("True"); break; case Friday: printf("True"); break; case Saturday: printf(...
C
#include "internal.h" /// <summary> /// Build the gradient and rotation pyramids /// NOTE: Size of Pyramids = octave_count * gaussian_count with empty entries! /// </summary> /// <param name="gaussians"> IN: The octaves of the input image. </param> /// <param name="gaussian_count"> IN: Number of octaves. </param> ///...
C
//********************************************* // ntpproxy.c - NTP Proxy // // Program runs as proxy between NTP time source // and another NTP client which in turn acts as // a server for other NTP clients. // NTP Proxy modifies time stamps and // sets leap-indicator flag on the flow // from NTP time source to cli...
C
#include<stdio.h> void main() {int count=0; int a[5]={1,2,3,4,5}; for(int i=0;i<sizeof(a/4);i++) { count++; } printf("%d",count); }
C
#include<stdio.h> #include<Windows.h> void main(int argc,char* argv[]) { int check1 = 0,check2=0; STARTUPINFO sui1; STARTUPINFO sui2; PROCESS_INFORMATION pi1; PROCESS_INFORMATION pi2; ZeroMemory(&sui1, sizeof(sui1)); ZeroMemory(&pi1, sizeof(pi1)); sui1.cb = sizeof(sui1); ZeroMemory(&sui2, sizeof(sui2)); Zero...
C
#include "remote_controller.h" #include "stream_controller.h" //#include "graphics.h" static inline void textColor(int32_t attr, int32_t fg, int32_t bg) { char command[13]; /* command is the control command to the terminal */ sprintf(command, "%c[%d;%d;%dm", 0x1B, attr, fg + 30, bg + 40); printf("%s", com...
C
#define RESP_EOL "\n" int hex2bin(const char *in, unsigned char *out); unsigned char *hex2bin_m(const char *in, long *plen); int do_hex2bn(BIGNUM **pr, const char *in); int do_bn_print(FILE *out, const BIGNUM *bn); int do_bn_print_name(FILE *out, const char *name, const BIGNUM *bn); int parse_line(char **pkw, char **...
C
//structure_pointer with function and user_input #include<stdio.h> #include<string.h> // we define structure before function prototypes and int main //i.e. structure is global variable struct Books //name of structure is Books { char title[50]; char author[50]; char subject[100]; int id; }; //now we declare f...
C
/* 2- Escrever uma função recursiva que retorna o tamanho de um string, tamstring(char s[]) */ #include <stdio.h> int tamstring(char s[]) { if (s[0] == '\0') return 0; else return 1 + tamstring(&s[1]); } void main() { char s[30]; printf("\nDigite a palavra que deseja saber o ta...
C
/* * File: 4bit_mode_lcd.c * Author: Yuvaraj * * Created on September 12, 2020, 4:38 PM */ // CONFIG #pragma config FOSC = HS // Oscillator Selection bits (HS oscillator) #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled) #pragma config PWRTE = OFF // Power-up Timer ...
C
#include <stdio.h> #include <stdlib.h> int main(){ int x = 2; int y = 8; int *p = &x; int *q = &y; printf("1) %p - %d\n",p ,*p); printf("2) %d - %d\n",p ,*p); printf("3) %p - %d\n",q ,*q); printf("4) %d - %d\n",q ,*q); int **pp = &p; printf("5) %p\n",&p); int **qq = &q; ...
C
#ifndef RTCDRIVER.H #define RTCDRIVER.H #include <Wire.h> #include "ds3231.h" #define RTC RTCDriver() /* GND to GND VCC to 5V SDA to A4 SCL to A5 */ #define FETCH_INTERVAL 60000 struct ts lastTimestamp; long lastFetchMillis = -FETCH_INTERVAL; struct RTCDriver { void init() const { Wire.begin(); DS323...
C
#include <stdio.h> #include <string.h> void main() { char src[20]; char dest[20]; strcpy(src,"beautiful"); strcpy(dest,src); printf("destination string is %s\n",dest); }
C
#include<stdio.h> #include "pico/stdlib.h" #include "hardware/gpio.h" #include "pico/binary_info.h" #include "hardware/uart.h" #include "tusb.h" // this header file will handle the problem of losing initial output // which port we want to use uart0 or uart1 #define UART_ID0 uart0 #define BAUD_RATE 115200 #de...
C
#include <stdio.h> int main(void) { int x; float y, total; scanf("%d%f", &x, &y); total = x / y; printf("%.3f km/l\n", total); return 0; }
C
/******************************************************** File Name:pcapanalysis.c Author:Qingqing Liang Description:This file include the implemention of the functions of analyzing the PCAP file and return the result of the statistic. And list the main function here: total flow analysis total_flow* totalflow...
C
#include <stdio.h> void Grid(int n); int main() { int n; printf("n = ? "); scanf("%d", &n); Grid(n); return 0; } void Grid(int n) { int j,i; if(n) { printf(""); for(j = 1;j < n;j++) { printf(""); } printf("\n"); for(i = 1;i < n;i++) { printf(""); for(j = 1...
C
#include<stdlib.h> #include<stdio.h> unsigned char CautareLiniara(short int *TablouCautare, unsigned char NumarElementeTablou, short int ElementCautat) { unsigned char pozitie; for (pozitie = 0; pozitie < NumarElementeTablou; pozitie++) if (TablouCautare[pozitie] == ElementCautat) return pozitie + 1; return 0...
C
// Name: Li-Ching, Cheng // Student Number: 143292175 // Email: lcheng49@myseneca.ca // Section: GG // Date: 2018.05.29 #include<stdio.h> #define _CRT_SECURE_NO_WARNINGS #define NUMS 3 // Put your code below: int main(void) { int i; int high, low; int sumHigh = 0; int sumLow = 0; float average; printf("---===...
C
#include "MKL46Z4.h" #include "board.h" /** * @brief Init_Led * @param[in] void * @param[in,out] void * @return void */ void Init_Led (void) { /* Enable clock for PORTE & PORTD*/ SIM->SCGC5 |= ( SIM_SCGC5_PORTD_MASK | SIM_SCGC5_PORTE_MASK ); /* * Initialize the R...
C
#include<stdio.h> int main(void) { int i,j; puts("(A)"); for ( i = 1; i <= 10; ++i) { for (j = 1; j <= i; j++) { printf("%s", "*"); } printf("%s", "\n"); } printf("\n\n\n"); puts("(B)"); for ( i = 10; i >= 1; i--) { for (j = 1; j <= i; j++) { printf("%s", "*"); } printf("\n"); } printf...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <errno.h> //On linux need below two #include <sys/types.h> #include <sys/wait.h> //execl will success #define IFCONFIG_CMD_PATH "/sbin/ifconfig" //execl will fail intentionally #define IFCONFIG_WRONG_CMD_PATH "/sbin/ifconfigasd" ...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> #define MAXLENOPERAND 20 #define EMPTYPOS 10 #define UNDEFCHAR '*' #define UNDEFVAL -1 typedef struct letravalor{ char letra; int valor; } SOLC; SOLC Solucao[11] = { {UNDEFCHAR,UNDEFVAL}, {UNDEFCHAR,UNDEFVAL}, {UNDEFCHAR,UNDEFVAL}, {UNDEFCHAR,UNDEFVAL}...
C
#include<stdio.h> #include<stdlib.h> struct node { int value; struct node *left, *right; }; struct node *newNode(int n) { struct node *temp = (struct node *)malloc(sizeof(struct node)); temp->value = n; temp->left = temp->right = NULL; return temp; } void inorder(struc...
C
#include "tool.h" #include <errno.h> #include <sys/socket.h> #define BUFLEN 128 void process(int sockfd) { char buf[BUFLEN], msg[BUFLEN]; FILE *fp; int nbytes; nbytes = read(sockfd, buf, BUFLEN); guard(nbytes >= 0, "read failed"); if (nbytes == 0) { /* End-of-file */ close...
C
/* Modo Synchronization from HUB * This code is used to calculate the time difference from Node 1 */ #include <unistd.h> #include <signal.h> #include <stdint.h> #include <thread> #include "mraa.hpp" #define fSCLK 8000000 int running = 0; int i,j=0; int maxDif, error,restartCount = 0; int timeNode1, tim...
C
#include <stdio.h> #include <pthread.h> #include "mythreads.h" #define NUMCPUS 5 #define ITERATIONS 1000000 #define THRESHOLD 1024 typedef struct counter_t{ int global; pthread_mutex_t globalLock; int local[NUMCPUS]; pthread_mutex_t glock[NUMCPUS]; int threshold; }counter_t; typedef struct __c...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_num_player.c :+: :+: :+: ...
C
#include<stdio.h> int main() { int n,sum; while(scanf("%d",&n) != EOF) { sum = n * (n + 1) / 2; printf("%d\n",sum); } return 0; }
C
#include<stdio.h> #include<conio.h> #include<math.h> int fact(int x) { int f=1,i; for(i=1;i<=x;i++) { f=f*i; } return f; } int main() { int x[20],y[20],i,n,z[10],j=0,k; float u,sum,t=1,a,h; printf("enter value of n"); scanf("%d",&n); for(i=0;i<n;i++)...
C
#include <gb/gb.h> #include "player.sprites.h" // Id ("nb") of the two sprites used to represent the player #define PLAYER_SPRITE_L_ID 0 #define PLAYER_SPRITE_R_ID 1 // Animations data for the players sprites UINT8 PLAYER_SPRITE_ANIM_L[] = { // LEN | FLIP | TILES ID | DIRECTION 4, 0, 0 , 4, 0, 8,...
C
#include <sys/select.h> #include <sys/time.h> #include <sys/types.h> #include <unistd.h> #include <sys/stat.h> #include <fcntl.h> #include <stdio.h> #include <sys/ioctl.h> #include <string.h> #include <strings.h> #include <sys/epoll.h> #include <linux/signal.h> #include <errno.h> #define MEM_SIZE 0x1000 #defin...
C
#include<stdio.h> #include<math.h> void push(int *a,int ele,int *top) { a[++(*top)]=ele; } int pop(int *a,int * top) { if(*top==-1) printf("Stack Underflow"); else printf("%d",a[(*top)--]); } void display(int *a, int n) { int i; for(i=0;i<n;i++) printf("%c",a[i]); } void m...
C
#include <stdio.h> #include <errno.h> #include <stdlib.h> #include <string.h> #include <time.h> #include "ex19.h" #include <assert.h> void *Map_move(void *self, Direction direction) { assert(self != NULL); // Should always be in some valid location Map *map = self; Room *location = map->location; Room *nex...
C
#include <stdio.h> int main(int argc, char **argv){ int orig_stdout; //duplicate the stdout file handle and store it in orig_stdout orig_stdout = dup(fileno(stdout)); //this text appears on screen printf("writing to original stdout .... \n"); //reopen stdout and redirect it to the "...
C
/* * File: ser.h * Author: Brendan * * Created on 24 September 2016, 1:24 PM */ #ifndef SER_H #define SER_H unsigned char speedH = 0; unsigned char speedL = 0; unsigned char radH = 0; unsigned char radL = 0; unsigned int VelocityRight = 0; unsigned int VelocityLeft = 0; unsigned char RightSp...
C
#include <stdio.h> #include <string.h> #define MAXWORDLEN 101 #define MAXNAMELEN 101 #define MAXWORDS 1000 /*David Hatcher MW 9:30-10:45 This program allows a user to enter a file name it will then take that file name read all the text out of that file extract only the first letter from each word then place those lett...
C
/* * Section: 1.6.6 * Problem: Interpreter * UVa ID: 10033 * * Solve by @alysonNBS */ #include <stdio.h> int registers[10]; char ram[1000][4]; int instructions_size; int current_instruction; void (*encodings[10])(int, int); void setup_encodings(void); void reset_computer(void); int read_instructions(void); int execu...
C
/******************************************************/ /********** TEST CODE Modified by Ziho Shin ***********/ /******************************************************/ /******************************************************/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <fc...
C
// C program to find sum of digits of a number #include <stdio.h> int main() { int n,s=0; scanf("%d",&n); while(n>0) { s=s+n%10; n=n/10; } printf("Sum of digits is %d",s); }
C
#include <stdio.h> int main() { int birimA, birimB, birimC; int ekipA1, ekipA2, ekipA3, ekipA4, ekipB1, ekipB2, ekipB3, ekipB4, ekipC1, ekipC2, ekipC3, ekipC4; printf("Birim A,B,C ve ekiplerinin(1,2,3,4) satış miktarlarını girin:\n"); printf("Birim A, Ekip 1: \n"); scanf("%d", &ek...
C
/* * * Demonstrates how to draw a cockpit view for a 3D scene. * * Key bindings: * m Toggle cockpit mode * a Toggle axes * arrows Change view angle * PgDn/PgUp Zoom in and out * 0 Reset view angle * l Enable lighting * ESC Exit */ #include "CSCIx229.h" in...
C
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- vim:set ts=4 sw=4 sts=4 noet: */ BOOST_AUTO_TEST_CASE(abs) { TESTCASE1(abs, 0, 0); TESTCASE1(abs, 1, 1); TESTCASE1(abs, -1, 1); } BOOST_AUTO_TEST_CASE(arccos) { TESTCASE1(arccos, 1, 0); } BOOST_AUTO_TEST_CASE(arccosh) { TESTCASE1(arccosh,...
C
// Solution to week 3 ex. 1, timing division. #include <stdlib.h> #include <math.h> // M_PI #include <stdio.h> #include <time.h> // This is to allow compilation on different compilers. // If you are using gcc <x86intrin.h> is the right header. // #ifdef _MSC_VER #include <intrin.h> #else #include <x86intrin.h> #endi...
C
//Steven Touchstone //Programming I //Simple Arithmetic Examples in C #include<stdio.h> int main() { //Addition int a,b,c; a = 2; b = 3; c = a+b; printf("%d + %d = %d \n",a,b,c); //Subtraction int d,e,f; d = 10; e= 7; f = d-e; printf("%d - %d = %d \n",d,e,f); //Multiplication int g,h,i; g = 20...
C
#include "DS3232.h" int main(void) { DateTime_t t; RTC_Setup(); t.Second = 55; t.Minute = 59; t.Hour = 23; t.Day = Sunday; t.Date = 31; t.Month = December; t.Year = 2016; RTC_Set(t); while (1 == 1) { t = RTC_Get(); if (RTC_Status() == RTC_Ok) { //Do something } } return 0; }