language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
//CMP1160 - Sistemas Operacionais //pthread.h - implementa e gerencia threads nivel usuario //Este programa usa tres threads: as duas primeiras preenchem um vetor cada (vetor a e b) //enquanto a terceira soma os elementos dois dois vetores e armazena em um terceiro (vetor c) #include <stdio.h> #include <pthread.h> v...
C
#include <stdio.h> int main() { char *array[] = { "Zulu", "Paavi", "Vodun", "Vanem" }; printf("%s %s %s %s\n", array[0], array[1], array[2], array[3]); printf("%c%c%c%c\n", array[0][0], array[0][1], array[0][2], array[0][3]); printf("%c%c%c%c\n", *(*(array[0])+0), *(*(array[0])+1), *(array[0])+2), *(array[0]+3)...
C
// // Created by giacomo on 02/12/18. // #include <stdio.h> #include <stdlib.h> #include <sys/wait.h> #include <fcntl.h> #include <string.h> #include <unistd.h> #include <signal.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #define DIM 4096 int main(int argc, char **argv) { /*************...
C
#include<stdio.h> #include<stdlib.h> #include<time.h> #define STACK_INIT_SIZE 100//洢ռʼ #define STACKINCREMENT 10//洢ռ typedef char SElemType; typedef enum { OK, OVERFLOW, ERROR }Status; typedef enum bool{ false, true }bool; typedef struct _SqStack { SElemType *base; //֮ǰ֮baseֵΪNULL SElemType *top; //ջָ int str...
C
/* * Программа, сожержит функции кодирования и декодирования данных * Кодировка выполняется с помощью функции фи1, описанной в методическом пособии ЛР-1.pdf * * Этапы кодирования: * 1. Порционное считывание данных (по 1-ому байту) из кодируемого файла. * 2. Определение "бинарной длины" (length) считавшейся порци...
C
#include "computor.h" void printReductEquation(t_computor_list *reductEquation) { t_computor_list *equation = reductEquation; printf(" <=> "); if (equation->number == 0) { printf("0 = 0\n"); equation->power = 0; return; } while (equation) { if (equat...
C
#include <stdio.h> #include <stdlib.h> int main() { int opcion; printf("Adelante, elegi! Estoy seguro de que perderas!\n"); scanf("%d",&opcion); // el switch evalua el valor de una variable. Esta DEBE ser DISCRETA! switch (opcion){ case 0: // el CASE no puede evaluar rangos, s...
C
/* Alunos Ian Castilho Caldeira Brant N 10133967 Alex Galhardo N 10408344 */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <time.h> #define BILLION 1000000000L; /* Referência Nanoseconds: https://stackoverflow.com/questions/13610471/calculating-function-time-in-nanoseconds-in-c-code */...
C
#ifndef LINKEDLIST_HEADER #define LINKEDLIST_HEADER typedef struct node { int data; struct node * next; } Node; typedef struct list { Node * head; } List; List * makelist(); void add(int data, List * list); void delete(int data, List * list); void display(List * list); void reverse(List * list); void destroy(...
C
#include<stdio.h> #include<stdlib.h> #include<semaphore.h> #include<pthread.h> sem_t sem1; void *thread1(void * args) { /** * sem_wait(): same as wait; it checks if the resouce is free or not * if value is 1 then it this thread can run its critical condition * if value is 0 this wait function will never end ...
C
/** * Programa que calcula e armazena num vetor os números primos que são menor que 100 */ #include <stdio.h> int main(int argc, char const *argv[]) { int divs, n_primos = 0; printf("Programa que calcula e armazena num vetor os números primos menores que 100\n"); for (int i = 0; i < 100; i++) { divs = 0; fo...
C
#include "helpers.h" #include <math.h> // Convert image to grayscale // same as less void grayscale(int height, int width, RGBTRIPLE image[height][width]) { for (int i = 0; i < height; i++){ for (int j = 0; j < width; j++){ float tmp = 0; tmp += image[i][j].rgbtBlue; tmp...
C
#include "sk_comm.h" #include<string.h> #include<stdio.h> const static char* write_direction = "write"; const static char* read_direction = "read"; /*********************************************************************** * * Fuction Name:parse_cmd_param * Description: parse the cmd to get cmd type, and slab...
C
#include "stdio.h" #define MAX_CUR_LINE_LENGTH 1000 int get_line(char cur_inp_line[], int max_cur_line_length); void reverse(char cur_inp_line[]); main(){ int cur_line_len; char cur_inp_line[MAX_CUR_LINE_LENGTH]; while((cur_line_len = get_line(cur_inp_line, MAX_CUR_LINE_LENGTH)) > 0){ reverse(cur_inp_line); p...
C
/** * @file map.h * @brief A data structure that maps keys to values * @author John F.X. Galea */ #ifndef MAPS_TB_MAP_H_ #define MAPS_TB_MAP_H_ #include "../ub_datastruct.h" #include "dr_defines.h" #include "dr_api.h" #include <stddef.h> /***********************************************************************...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <unistd.h> int randomNumber(int j) { srand(j); return rand()%20; } int main( ) { int fd[2]; int df[2]; int child1, child2; int a,b; int a_rec=0 ; int b_rec=0 ; ...
C
#include <stdio.h> #include <stdlib.h> /* Napisz funkcj, ktra otrzymuje cztery argumenty: dodatni liczb cakowit n oraz trzy n-elementowe tablice tab1, tab2 i tab3 o elementach typu int i zamienia zawartoci komrek otrzymanych w argumentach tablic w nastpujcy sposb: a) dla dowolnego i komrka tab1[i] powinna zawiera na...
C
#include <stdio.h> /** * main - prints the args * Return: return 0 on success * @argc: arg counter * @argv: arguments vector */ int main(int argc, char *argv[]) { int i; if (argc) { for (i = 0; i < argc; i++) { printf("%s\n", argv[i]); } return (0); } else return (-1); }
C
/* Student Name:Sunita Gosai Subject:Programming Fundamental Lab Sheet No:07 Program:WAP to enter any number and calculate its square Date:28 Nov,2016 */ #include<stdio.h> #include<conio.h> #include<math.h> int main(){ int a,square; printf("Enter the first number:\n"); scanf("%d",&a); square=pow(a,2); pr...
C
#include "time_client.h" /************************************************************************ * MAIN ************************************************************************/ int main() { int client_socket; // client side socket struct sockaddr_in client_address; // client socket namin...
C
#include "bounded_evasion.h" #include <stdlib.h> #include <stdio.h> #include <time.h> #include <math.h> #include <float.h> #include <string.h> void patrolling_adv(); void chasing_adv(); double main(int argc, char *argv[]) { srand ( time(0) ); if (argc == 2) { if (strcmp(argv[1], "-patrol") == 0) { patrolling_a...
C
#include <stdint.h> #include <stdio.h> #include <util/delay.h> #include <avr/io.h> #include "lcd_driver.h" uint8_t speed_pick() { LCD_print_String("Pick"); LCD_move_cursor_to_col_row(0, 1); LCD_print_String("Speed"); _delay_ms(1000); LCD_execute_command(CLEAR_DISPLAY); LCD_print_String("Slow");...
C
#include "holberton.h" /** * print_sign - Show the sing of the number * @n: the number to ocmpare * * Return: Returns the sing + if the number is positive or - if is negative * 0 otherwise */ int print_sign(int n) { if (n > 0) { _putchar(43); return (1); } else if (n == 0) { _putchar(48); return (0); } ...
C
#include<stdio.h> int main() { int arr[3][3],i,j; printf("enter the elements of the matrix"); for( i=0;i<3;i++) { for( j=0;j<3;j++) { scanf("%d",&arr[i][j]); } } for( i=0;i<3;i++) { for( j=0;j<3;j++) { pr...
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 euclid(int x,int y) { if( y == 0 ) return x; return euclid(y, x % y); } int main() { int a,b; scanf("%d %d", &a, &b); printf("%d %d",euclid(a, b), a*b/euclid(a,b)); }
C
#include<setjmp.h> #include<signal.h> #include<stdio.h> #include<stdlib.h> jmp_buf buf; void handler(int s) { if(s == SIGINT) printf("now got a SIGINT signal \n"); longjmp(buf,1); /* NOT REACHED*/ } int main() { signal(SIGINT, handler); if(setjmp(buf)) { printf("BACK IN THE MAIN BITCHES\n"); return 0; } els...
C
#include "Pantalla.h" #include <time.h> #include <stdlib.h> #include <stdio.h> #include "Personaje.h" #include "Enemigo.h" #include "Colision.h" #include "Estrella.h" #include "Estrellas.h" int main(int argc, char **argv) { srand(time(NULL)); Pantalla_Crea("Titulo", 700, 480); Imagen fondo = ...
C
#include <stdio.h> #include <stdlib.h> int helper(int a){ int hundreds = a / 100; int tens = (a / 10) % 10; int ones = a % 10; if (hundreds < 6 && tens % 2 == 0 && ones > tens) return 1; return 0; } int main() { for (int i = 100; i < 1000; i++) if (helper(i))...
C
#include <stdio.h> #include <sys/time.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <string.h> #include <fcntl.h> #include <sys/time.h> #include <sys/ioctl.h> #define BUFFER_SIZE 128 #define READ_END 0 #define WRITE_END 1 // Generate a random number between nMin and nMax. Example n...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* fillit_read.c :+: :+: :+: ...
C
#include<stdio.h> #include<string.h> #define MAX 1000 int input_string(char *ch); int palindrome(char *ch,int start,int end); void output(int x); int main(void) { int N; scanf("%d",&N); getchar(); for(;N>0;N--) { char ch[MAX]; int x,start=0,end=0; end=input_string(ch)-1; x=palindrome(ch,start,end); o...
C
#include<stdio.h> #include<string.h> /* a ab a abh ab a abhi abh ab */ void main(){ int n; /*printf("eneter the rows\n"); scanf("%d",&n); */ int i,k,j,z; char str[20]; scanf("%s",str); //puts(str); n=strlen(str); for(z=n;z>=0;z--){ for(i=n-z;i>0;i--){ for(j=0;j<i;j++) printf("%c",str[j]); for(k=n-i;...
C
/* This is myLinkedList.h */ #include <linux/list.h> #include <linux/sched.h> #include <linux/slab.h> #include <linux/types.h> /* GLOBAL VARIABLES FROM mp3.c */ /* GLOBAL VARIABLES */ struct list_head reg_list; unsigned int total_len; /* FUNCTION FROM mp3_given.h */ extern struct task_struct *find_task_by_pid(unsig...
C
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> #include "nthUglyNumber.h" int nthUglyNumber(int n){ int dp[n]; int i2 = 0; int i3 = 0; int i5 = 0; int i = 0; memset(dp, 0, sizeof(int) * n); dp[0] = 1; for (i = 1; i < n; i++) { ...
C
#include<stdio.h> #include<math.h> int main(){ int input=82; int i=0, ary[32]={0}, sum=0, count=0, result=0; while (input != 1) { //put input into ary[] for (i = 0; input; i++) { ary[i] = input % 10; input /= 10; } //sum power ary[i] up sum = 0; while (i) { i--; sum = sum + pow(ary[i], 2)...
C
#include "holberton.h" /** *_strcat - concatenates two strings *@dest: pointer for the first string we want to change *@src: pointer for the second string * *Return: the new string */ char *_strcat(char *dest, char *src) { int longdest; int j; for (longdest = 0; dest[longdest] != '\0'; longdest++) { } fo...
C
#include<stdio.h> #include<string.h> int main() { char a[50]; char b[]="宝塔镇河妖"; int x; printf("小霸王猜数字机器,请输入密码\n"); printf("天王盖地虎,_______________。\n"); scanf("%s",&a); if ( strcmp(a,b) == 0){ printf("Ours game begin!\n"); printf("请输入1到20以内的数字\n"); while(1) { scanf("%d",&x); if(x==15){ printf("小霸...
C
#include <stdio.h> #include <string.h> size_t countChar(const char * str, int ch) { size_t count = 0; while (*str != '\0') { if (*str++ == ch) { count++; } } return count; } size_t countLine(const char * str) { size_t strLength = strlen(str); size_t count = countChar(str, ...
C
#ifndef MATRIX_H #define MATRIX_H typedef struct matrix matrix; #include "linalg.h" #include "vector.h" /* Operation was not successful due to one or more of * the operands' dimensions */ #define LAMAT_INCOMPATIBLE_DIM 1 /* Operation was not successful due to one of the coordinates * being outside the bounds of ...
C
#include <stdio.h> #include <stdlib.h> int main() { /* switch(expressao) { case(expressao-cost): break; case(true): break; default: // NAO E NESSESARIO COLOCAR UM BREAK } */ printf("Digite um valor entre 0 e 9 \n"); int ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_putscreen.c :+: :+: :+: ...
C
#include "common.h" /* 名字与地址转换 过时,仅用于IPv4,线程不安全 gethostbyname */ extern int h_errno; int main(int argc, char *argv[]) { struct hostent *host; char str[128]; if( argc<2 | !argv[1] ){ printf("请输入主机名!\n"); return -1; } host = gethostbyname(argv[1]); printf("official name of host:%s\n", host->h_name); ...
C
// RUN: %clang_cc1 -analyze -analyzer-checker=core.NullDereference -analyzer-output=text %s -verify // RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=text %s -verify int test(int *pp) { if (!pp) { //expected-note@-1{{Assuming 'pp' is null}} //expected-note@-2{{Taking true branch}} return...
C
#include "includes/ft.h" void do_op(int argc, char **argv) { if (argc == 4) { int a; int b; a = ft_atoi(argv[1]); b = ft_atoi(argv[3]); if (*argv[2] == '+') ft_putnbr(a + b); else if (*argv[2] == '-') ft_putnbr(a - b); else if (*...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include "../include/mymkdir.h" #define MAXSIZE 200 int main(int argc, char * argv[]){ char path[MAXSIZE], target[MAXSIZE]; if(argc == 2) strcpy(target, argv[1]); else exit(0); getcwd(path, sizeof(path));...
C
#include<stdio.h> unsigned getbit(unsigned x,int p,int n); main() { } unsigned getbit(unsigned x,int p,int n) { return (x>>(p+1-n))&~(~0<<n); } /* 76543210 000xxx00 x>>(p+1-n) 00000xxx ~0 11111111 11111000 ~(~0<<n) 00000111-----------屏蔽码 00000xxx & 00000111 =00000xxx,而不论之前的0是什么,这里一定是0
C
/* smemcap - a tool for meaningful memory reporting Copyright 2008-2009 Matt Mackall <mpm@selenic.com> This software may be used and distributed according to the terms of the GNU General Public License version 2 or later, incorporated herein by reference. */ //applet:IF_SMEMCAP(APPLET(smemcap, BB_DIR_USR_BIN, B...
C
#include <stdio.h> #define NULLCHARSIZE 1 int main (void ){ char x[] = "abc"; int sizeOfX = sizeof(x)/sizeof(x[0]); printf("%d \n",sizeOfX - NULLCHARSIZE); return 0; }
C
#include <stdio.h> int main() { int a,b,temp; printf("Enter the value of a and b\n"); scanf("%d%d", &a, &b); printf("Before Swapping\n a = %d \n b = %d\n",a,b); temp =a; a=b; b=temp; printf("After Swapping\n a = %d\n b = %d\n",a,b); return 0; }
C
#include<stdio.h> int main() { int n,x,i,p; printf("enter size of array and element to be searched"); scanf("%d%d",&n,&x); int arr[n]; printf("enter array elements"); for(i=0;i<n;i++) scanf("%d",&arr[i]); int lo=0,hi=n-1; //since array is sorted ,element present in arr...
C
#include"def_c.h" int length_c(LinkList L){ int length; for(length=0; L->next!=NULL ;length++) L = L->next; return length; }
C
#include <stdio.h> #include <stdlib.h> typedef int elem_t; static void merge(elem_t a[], elem_t tmp[], const int start, const int mid, const int end){ int i, j, k; for(i = 0; i < end; i++){ tmp[i] = a[i]; } for(i = start, j = mid, k = start; i < mid && j < end; k++){ if (tmp[i] < tmp[...
C
/* ----------------------------- MNI Header ----------------------------------- @NAME : test_fix_dicom_coords.c @INPUT : argc, argv - name of one dicom stream file to read and fix @OUTPUT : Prints new (0x20, 0x32) and (0x20, 0x37) and (0x20, 0x1041) values @DESCRIPTION: Test program for fi...
C
/* * File: hello.c * -------------- * This program prints the message Hello, World * on the screen. */ #include <stdio.h> main() { printf ("Hello, World\n"); getchar(); }
C
#include<stdio.h> #include<stdlib.h> #define max 5 struct record { int element; struct record* next; }; typedef struct record record; void insert(int element,record*hashTable[]); void display(record*hashTable[]); int search_element(int key,record*hashTable[]); int hash_function(int key); int remove_function(int key,...
C
/* * File: main.c * Author: 21193460 * * Created on 4 de Novembro de 2021, 09:13 */ #include "config.h" #include <xc.h> #define _XTAL_FREQ 4000000 #define LEDVERM PORTDbits.RD5 #define LEDAMAR PORTDbits.RD6 #define LEDVERD PORTDbits.RD7 #define ATRASO(n) __delay_ms(n) void main(void) { ...
C
#include <stdio.h> #include <sys/types.h> #include <dirent.h> #define BOLD_CYN "\033[1m\033[36m" #define RESET "\033[0m" int check_dir_error(DIR *); int begins_with(char *, char *); int main (int argc, char *argv[]) { char *cur_dir = argv[1]; char *opt = argv[2]; int m_flag = 0; int D_flag = 0; ...
C
//Challenge 2: //Write a loop to process single-character input. //Copy it into a buffer and append a message to the buffer. //print the buffer one charater at a time. #include<stdio.h> #include<string.h> int main(){ char name[32]; char buffer[64]; char last[] = "passed the challenge."; char c; ...
C
//#define _CRT_SECURE_NO_WARNINGS //#include <stdio.h> //#include <stdlib.h> //int main(void) //{ // char input; // int i, j, k,n,size; // char end; // // printf("please enter a char:\n"); // scanf("%c", &input); // size = input - 'A'; // for (i = 0; i <= size; i++) { // for (j = 0; j < size - i; j++) // { // print...
C
#include "../irc.h" /* ** Action OPER. ** For now, username and password are both 'admin'. ** TODO: get credentials from configuration file */ void command_func_oper(t_app *app, int client_fd, t_irc_message *message) { t_fd_repository *client; client = app->fds + client_fd; if (message->params_size < 2) { clien...
C
// Scott Kuhl #include <stdio.h> #include <limits.h> int main(void) { // Overflowing an int: printf("INT_MAX + 1 = %d\n", INT_MAX+1); // undefined // The smallest negative number has no corresponding positive // number. printf("INT_MIN * -1 = %d\n", INT_MIN*-1); // undefined // What is the worst that can go w...
C
#include <stdio.h> /* * Function: main * ------------------ * reads expressions * * returns: Enter:1234 * c1 = 1, a = 234 */ int main() { int a; char c1; printf("Enter:"); scanf("%c%d", &c1, &a); printf("c1 = %c, a = %d", c1, a); }
C
int main(void) { float a=0,b=0,c=0,d=0; float aa=180; scanf("%f",&a); scanf("%f",&b); scanf("%f",&c); scanf("%f",&d); scanf("%f",&aa); aa=aa/180*3.1415926; float S=0; float s=(a+b+c+d)/2; if((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos((double)aa/2)*cos((double)aa/2)<0) printf("Invalid input"); el...
C
/** * C99 Header-only library for extensible logging facilities * Copyright (c) 2019 Elias Benali <stackptr@users.sourceforge.net> * Distributed under the terms of the MIT License */ /** * Library specifies some process-wide unique state data structures. Exactly * one translation unit must define LOGTEE_UNIQU...
C
#include <stdio.h> #include <cs50.h> int main(void) { // gets a number more than 9 digits long n; do { n = get_long("enter your credit card number: "); } while (n < 100000000); // sum of every other digit multiplied by 2 long m = n / 10; int sum_other = 0; for (int i = 16;...
C
#include<stdio.h> #include<conio.h> #include<math.h> void main(){ float t=10.0,x,r,a,b; FILE *q; clrscr(); q=fopen("C:/Data/cwork/out12.txt","w"); a=6220000.0; b=9421000.0; fprintf(q, "AP Method:\n"); r=(b - a)/t; x=b + (r*16.0/3); fprintf(q, "\nMid year population of 1996=%.4f", x); x=b + (r*31.0/3); fpri...
C
/************************************************************************* > File Name: srv.c > Author: > Mail: > Created Time: 2017年09月12日 星期二 20时04分38秒 ************************************************************************/ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/socket.h> #...
C
#define _POSIX_C_SOURCE 200809L #define LINE_SIZE 200 #include "tp2.h" typedef struct log{ char ip[20]; char fecha[30]; char metodo[20]; char url[145]; }log_t; typedef struct adhoc{ size_t file_num; log_t data; }adhoc_t; /************************* FUNCIONES DE COMPARACION********************...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> #include"tree.h" Tree *creatnode(data_t tdata) { Tree * ptree=(Tree*)malloc(sizeof(Tree)); if(NULL==ptree) { return ptree; } memset(ptree,0,sizeof(Tree)); ptree->data=tdata; return ptree; } Tree *creattree( data_t *tdata,int size) { ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* init_select.c :+: :+: :+: ...
C
int minmax(int board[9],int isMax); int get_min(int m,int v){ if(m>v){ return v; } return m; } int get_max(int m,int v){ if(m<v){ return v; } return m; } int min_val(int board[9],int isMax){ int m=INT_MAX; int i; int v; for(i=0;i<9;i++){ if(board[i]==0){ ...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> /* NOTE: throughout the code, change the name of each procedure or function to something else in order to compile */ #define TEN_POW 1000000 /* declare global var's */ int num_classes; int freq; int *cpi; float *inst_count; float total_inst; /***************...
C
#include<stdio.h> int main() { float tempc, tempk; float inicial=100, final=200, delta; int n=10; delta=(final-inicial)/n; tempc=inicial; while (tempc<=final){ tempk=tempc+273.15; printf("%f %f/n", tempc, tempk); tempc=tempc+delta; // tempc+=delta } return 0; }
C
//------------------------------------------------------------------------------- // // Biblioteka do obslugi klawiatury matryciwej 4x4 podpietej do jednego portu // //------------------------------------------------------------------------------- #include <avr/io.h> #include <avr/interrupt.h> #define INTERR...
C
#include <stdio.h> typedef struct rect { int x1, y1; int x2, y2; }RECT; int SumArea(RECT *rectarr, int n); int main() { RECT rec[3]; int i, j; for (i = 0; i<3; i++) { printf(" %d ° Էϼ : ", i + 1); scanf("%d %d %d %d", &rec[i].x1, &rec[i].y1, &rec[i].x2, &rec[i].y2); } printf(" : %d Դϴ", SumArea(rec, 3...
C
#ifndef __SIM5_H__INCLUDED__ #define __SIM5_H__INCLUDED__ typedef int WORD; // TODO: add forwarding into the MEM phase (for sw) /* duplicated from Hardware Project 4 */ typedef struct InstructionFields { // THESE ARE NOT ACTUALLY CONTROL BITS // // However, you have to fill them out. Fill out *all* of thes...
C
/* Greg Meaders gmeader@g.clemson.edu cpsc 102 summer 2014 5/21/15 Project 1 Vector.c */ #include "ray.h" #include "vector.h" //normalize function taken from notes PV_T normalize(PV_T v) { PV_T ret_v; double len; len = sqrt(v.x * v.x + v.y * v.y + v.z * v.z); ret_v.x = v.x / len; ret_v.y = v.y / len; ret_v...
C
/******************************** Author : Aravindhan V. The purpose of this script is to apply loose sanity cuts to triggered data/MC Split by year is only done for Run 2 data, to allow parallel processing of different years. For MC, all years are processed together. *********************************/ #in...
C
#include <stdio.h> int main(){ int n, j=0; scanf("%d", &n); while(n--){ j++; int b; scanf("%d", &b); printf("Case #%d: %d\n", j, b*2-1); } }
C
#include <stdio.h> #include <stdlib.h> struct Node{ int data; struct Node *left; struct Node *right; }; typedef struct Node Node; typedef struct{ int r, f; Node* a[40]; }Queue; Node* getNode(int data){ Node *t = (Node*)malloc(sizeof(Node)); t->data = data; t->right = t->left = NULL; return t; } void enQue...
C
#include<stdio.h> #include<conio.h> #include<math.h> int lcm(int a,int b); int main() { int a,b,LCM,max; printf("Enter any two number :"); scanf("%d %d",&a,&b); printf("Least Common Multiple between %d and %d are :",a,b); if (a>b) LCM=lcm(a,b); else LCM=lcm(b,a); printf("%d",LCM); return 0; ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "linkqueue.h" #include "linklist.h" //ҲһԱ //еҵݽṹ typedef struct _tag_LinkQueueNode{ LinkListNode node; void *item; }TLinkQueueNode; // ൱ Ա LinkQueue* LinkQueue_Create(){ return LinkList_Create(); } //ٶ ൱ Ա //ڴ void LinkQueue_Destroy(LinkQueue* que...
C
/***************************************************** * BTP100a * Ontario Personal Income Tax Return * with Functions and Robust Validation -version 1.01 * * Programmer: Timothy Duavis * ID: 019-261-049 * * Description: * Calculates the data for an Ontario taxpayer * on their Income Tax Retur...
C
/* ** gas_app.c ** wrtten by KimSeongHeon in 19/06/01 ** based on gasTest.c */ #include <unistd.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <sys/ioctl.h> #define IOCTL_MAGIC_NUMBER 'k' #define IOCTL_GAS_READ _IOR(IOCTL_MAGIC_NUMBER, 0, unsigned int)...
C
#include <stdio.h> #include <math.h> #define n 1200 int sorted_array (int a[], int x) { int i,f; for(i=0;i<n-1;i++) { if(a[i]>a[i+1]) { f=f+1; } else { f=0; break; } } if(f>0) { ...
C
#include<stdio.h> #include<string.h> int main(void) { int n;// scanf("%d",&n); int i,a,b,k,m1,m2,m3,j,aj; aj=0; j=0; char str[100],temp[5]; memset(str,0,sizeof(str)); memset(temp,0,sizeof(temp));//ַҲҪʼ for(i=0;i<=n-1;i++) { scanf("%d %d",&a,&b); for(k=a;k<=b;k++) { m1=k/100; m2=k/10-m1*10...
C
#include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/moduleparam.h> static int onevalue = 1; static char *twostring = NULL; module_param(onevalue, int, 0); module_param(twostring, charp, 0); static int hello_init(void) { printk("Hello, world [onevalue=%d:twostring=%s]\n", o...
C
#include <stdio.h> typedef unsigned short int myShort; extern void removeFromStencil(int kmin,int kmax, int jmin,int jmax, int imin,int imax, void *pstencilExtent, int stencilIDim, int stencilJDim, void *pstencilArr, void *pimageExtent, int imageIDim, ...
C
// // Simulated Annealing.c // MEB // // Created by Daniella Bacud on 27/07/2016. // Copyright © 2016 Daniella Bacud. All rights reserved. // #include "Simulated Annealing.h" void *dfs(int v, int num_nodes, edge** new_solution ,int visited[]) { int i; visited[v]=1; for (i=1; i<=num_nodes; i++) ...
C
/************************************************************************************ * This file was developed as part of CS3841 Design of Operating Systems at the * Milwaukee School of Engineering. This file is copyright 2008-2015 by MSOE. * * $Author: wws $ * $Revision: 1.1 $ * $Name: $ * This file m...
C
#include <stdio.h> #include <stdlib.h> main() { int i,j; for(i=0;i<5;i++) { for(j=0;j<5;j++) { printf("\n\n\t\t %d Hello", j); if (j==4) break; } if (i==2) break; printf("\n\n"); } getch(); }
C
#include "memory.h" #include <stdint.h> #include <stddef.h> #include <std/kheap.h> int memcmp(const void* aptr, const void* bptr, size_t size) { const unsigned char* a = (const unsigned char*) aptr; const unsigned char* b = (const unsigned char*) bptr; for (size_t i = 0; i < size; i++) { if (a[i] < b[i]) { ret...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <sys/wait.h> #include <sys/stat.h> #include <sys/types.h> #define MAX_CONT_SIZE 256 void error(char * msg){ perror(msg); exit(EXIT_FAILURE); } int main(int argc, char ** argv){ /// argv[1] = sciezka do ...
C
// Measure the cost of associativity misses #define __STDC_FORMAT_MACROS #include <stdio.h> #include <inttypes.h> #include <stdint.h> #include <sys/mman.h> #include "../../rdtsc.h" #include "../../stddev.h" // #define GRAPH // This is the dumbest thing ever. TODO: take an argument #define MAX_NUM_LINES 100000 #defi...
C
/* * Copyright (c) 2016 ETH Zurich. * All rights reserved. * * This file is distributed under the terms in the attached LICENSE file. * If you do not find this file, copies can be found by writing to: * ETH Zurich D-INFK, Universitaetstr. 6, CH-8092 Zurich. Attn: Systems Group. */ #include <string.h> #include <...
C
#include <stdio.h> #include <stdlib.h> #include <signal.h> #include <string.h> typedef enum{ IGNORE = 0, MASK, PENDING } MODE; MODE get_mode(const char *arg){ if(strcmp(arg, "ignore") == 0){ return IGNORE; }else if(strcmp(arg, "mask") == 0){ return MASK; }else if(strcmp(arg, "pending") == 0){ return PEND...
C
#include <stdio.h> int fun(int a,int b){ int c; c = a % b; while(c!=0){ a = b; b = c; c = a % b; } return b; } int main(){ int m, n; while(~scanf("%d%d",&m,&n)){ int min,max; if(m>n) min=fun(m, n); else min=fun(n, m); ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> int flag=0; //Initializing global variables. char palindrome[15]; void addflag() { flag=1; //Changing the value of the reference variable. } void palcheck(int l) //Function to check for a palindrome. { int i, j; for(i=0, j=(l-1); ...
C
/*Program to implement a Sparse Matrix in Triplet(Array) representation */ #include<stdio.h> #include<stdlib.h> void main() { int n,m; int i, j; printf("Enter row of matrix\n"); scanf("%d",&n); printf("Enter column of matrix\n"); scanf("%d",&m); int arr[n][m]; printf("Enter sparse matr...