language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <time.h> #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <arpa/inet.h> #define PORT 1111 int main(){ int sockfd, ret; struct sockaddr_in serverAddr; int newSocket; struct sockaddr_...
C
#include<stdio.h> struct Choice { int g_pos; int m_pos; int now_player; }; struct State { int g_pos; int m_pos; int now_player; int win_player; }; int V; char winner[233][233][3]; char degree[233][233][3]; struct State queue[233*233]; int head, tail; int edge[233][100010]; int top[100010]; int generPrevChoi...
C
#include <stdio.h> #include "holberton.h" /** * print_binary - Print out the binary representation of an unsigned long int * @n: int to print in binary */ void print_binary(unsigned long int n) { unsigned long int rev; unsigned long int i; rev = i = 0; if (n == 0) _putchar('0'); while (n > 0) { rev = rev...
C
/* Ders22 Koda bakarak algoritmanın zaman karmaşıklığını çıkartabilir miyiz? Aslında evet, dikkatli bakarsak, bazı temel kavramları da biliyorsak evet. Eğer yapısındaki öğe sayısından bağımsız, tek bir kod yürütülüyorsa o zaman O(1) Eğer bir döngü varsa, ve döngü veri yapısındaki öğe sayısı kadar ya da bunun bir ç...
C
/* * Description: USART lib for Atmel Studio * Name: USART * Reference: * Created: 13.08.2017 * Author: Ali Gholami * License: Open-source * Core: 8 bit ATMEL_MiCROCHIP * Last update: 15.1.2018 * Test Des: OK for atmega328p,8mhz * Website: h...
C
#include "aps.h" #include "prolog_gen.h" #include <stdio.h> #include <stdlib.h> #define PL_PATH "tmptypes.pl" int main(int argc, char* argv[]) { FILE* fp; // Open program if (! (fp = fopen(argv[1], "r"))) { fprintf(stderr, "Error, can't open %s\n", argv[1]); exit(1); } // AST! Program* prog = ast_...
C
//This file includes initialization for timers #include "init.h" ///Initialize GPIO Port B for Servos and Sonar readings /* * Pin B5 is used for the servo and Pin PB3 is used for Sonar. * Alternate digital functions are used. */ void init_PortB() { //Enables clock for portB. SYSCTL_RCGCGPIO_R |= 0x02; ...
C
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> typedef struct stack{ long long int data; int day; struct stack *next; }stack; int max=0; void push(stack** top,long long int data){ stack *p=(stack*)malloc(sizeof(stack)); p->data=data; p->next=*top; *top=p; } void pop(stack** top){...
C
#include <stdio.h> #include <stdlib.h> #include "linked_list.h" //global variables node* head = NULL; //prototypes void Print(node* first); node* NewNode(int value); void AddToList(int value, node* first); void InsertNode(int position, int value); void DeleteNode(int position); void Reverse(node* ptr); int main(...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* lst_square.c :+: :+: :+: ...
C
//Vincent Chi 304576879 vincentchi9702@gmail.com #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <getopt.h> #include <pthread.h> #include <time.h> #include <sched.h> int exit_status = 0; int c; int option_index; int num_threads = 1; int num_iters = 1; int opt_yield; char sync_arg; int sync_typ...
C
#include <stdio.h> int array_sum(int *p, int n) { int a = 0; for (int i = 0; i < n; i++) a += p[i]; return a; } int main() { int n, a[100]; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d ", &a[i]); printf("%d", array_sum(a, n)); return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <unistd.h> #include <time.h> #include "debug.h" pthread_mutex_t mtx,main_done; pthread_cond_t queue[2]; int nOfcars, carsBrigde; volatile int crossing[2]={0,0}; // index 0:red , index 1:blue volatile int blocked[2]={0,0}; // index 0:red , index 1:bl...
C
#include <stdio.h> #include <sys/time.h> #include <sys/types.h> int main(int argc, char *argv[]){ FILE *fstart, *fend, *frec; double timeUse, start, end, rec; if(argc==4){ fstart = fopen(argv[1], "r"); fend = fopen(argv[2], "r"); frec = fopen(argv[3], "r"); fscanf(fstart, "%lf", &start); fscanf(fe...
C
int main(){ int n,i,j; char s[999][256]; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%s",s[i]); } for(i=0;i<n;i++){ for(j=0;s[i][j];j++){ if(s[i][j]=='A'){ s[i][j]='T'; } else if(s[i][j]=='T'){ s[i][j]='A'; } else if(s[i][j]=='C'){ s[i][j]='G'; } else if(s[i][j]...
C
#include <stdio.h> #include <stdlib.h> #include "strings.h" #include "inttypes.h" #include "fat16.h" FILE *in, *out; // Provide disk access function for FAT16 library void FAT16_seek(uint32_t offset) { fseek(in, offset, SEEK_SET); } int8_t FAT16_read(uint8_t *ptr, uint8_t bytes) { return (i...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_memcpy.c :+: :+: :+: ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* function_stop_death.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> int main() { //Vergleichsoperatoren int a = 5; int b = 12; int c = 7; a < b; /* WAHR */ b < c; /* FALSCH */ a + c <= b; /* WAHR */ b - a >= c; /* WAHR */ a == b; /* FALSCH */ a + c == b; /* WAHR */ a != b; /* WAHR */ a = b < c; /* mglich: a = 0 */ printf("%i", a); a = c < b; /* ...
C
/* * Usage: insmod reset.ko hijack=int */ #include <linux/module.h> #include <linux/kernel.h> #include <asm/io.h> static int hijack = 0; volatile unsigned* gpio = 0x00; int g1 = 22; // Pin 22 attached to LED int g2 = 24; int g3 = 2; // Pin 2 (controlled by I2C) attached to Adafruit PWM controller module_param(hijac...
C
#include <stdio.h> #include <stdlib.h> int main() { int *num = (int)malloc(sizeof(int)*10); for (int i = 0; i < 10; i++) { scanf_s("%d", num[i]); } for (int i = 0; i < 10; i++) { printf("%d", num[i]); } }
C
/*** File system utilities. @module fs @copyright 2012 Adrian Perez <aperez@igalia.com> @license Distributed under terms of the MIT license. */ #include "../lua/lua.h" #include "../lua/lauxlib.h" #include <sys/types.h> #include <sys/stat.h> #include <sys/dir.h> #include <libgen.h> #include <unistd.h> #include <stdl...
C
#include <stdio.h> int main() { int a1, a2, a3, a4, a5, a6; scanf("%d" "%d" "%d" "%d" "%d" "%d", &a1, &a2, &a3, &a4, &a5, &a6 ); printf("Valor: R$%d.00", ((a1*a4)+(a2*a5)+(a3*a6))); return 0; }
C
/* 10. Faa um programa para ler dois nmeros inteiros A e B e informar se A divisvel por B. */ int main(){ int a,b; scanf("%d %d",&a,&b); printf("%f\n",a/(float)b); if(a%b==0){ printf("e divisivel"); }else{ printf("nao e divisivel"); } return 0; }
C
const int constA=10,constB=20; const char constC='2'; int globalArr[20]; int fibArr[10]; int i,n; int fib(int x) { if(fibArr[x]==0) fibArr[x]=fib(x-1)+fib(x-2); return(fibArr[x]); } void sort() { int i,j; int temp; for(i=0;i<n;i=i+1) { for(j=i+1;j<n;j=j+1) { if(globalArr[i]>globalArr[j]) { temp=...
C
#include <R.h> #include <stdlib.h> /* check if a vector contain any 0 */ int checkZero(int* vect, int n) { int i; for (i=0; i<n; i++) { if (vect[i] == 0) return i; } return 0; } /* connex components analysis for WEAK definition, mutual-kNN graph */ void weakConnexSym(double* binMat, int n, int...
C
#include "../../include/my_head.h" int tcp_connect(char *ip, int port) { int sfd = socket(AF_INET, SOCK_STREAM, 0); if(sfd == -1) { perror("socket"); exit(1); } struct sockaddr_in serveraddr; memset(&serveraddr, 0, sizeof(struct sockaddr)); serveraddr.sin_family = AF_INET; se...
C
/*---------------------------------------------------------------------------*/ /* Copyright (c) 1996 by Charles A. Measday */ /* */ /* Permission to use, copy, modify, and distribute this software and its */...
C
#include <stdio.h> #include <conio.h> #include <stdlib.h> main() { FILE *fp; char ch,st[20]; if((fp=fopen("D:\\a.txt","wt"))==NULL) { printf("ܴļ˳"); getch(); exit(1); } printf("һַ\n"); scanf("%s",st); fputs(st,fp);//ļõĶָ fclose(fp); if((fp=fopen("D:\\a.t...
C
#include <avr/io.h> #include <avr/interrupt.h> #include <util/delay.h> #include "UltraSonic.h" static unsigned char sonic_value = 0; // volatile unsigned int pulse_count = 0; // ޽ ̿ īƮ Ǵ . ISR(TIMER2_COMP_vect) // 58us { pulse_count++; } ISR(INT0_vect) { static unsigned char toggle = 0; if(toggle == 0) //...
C
/******************************************* * To compile use: * $gcc -o foo foo.c -lpthread * *****************************************/ #include <stdio.h> #include <pthread.h> #include <semaphore.h> void myfunc1(void *ptr); void myfunc2(void *ptr); char buf[24]; sem_t mutex; int main(int argc, char **argv) { ...
C
/* * lab0_tests.c - Tests for lab 0 programming puzzles * * Created on: Apr 19, 2018 * Author: deemer * Updated 17 May 2018 */ #include <msp430.h> #include <puzzle_tests.h> #include <puzzles.h> #include <string.h> // Prototypes void test_linear(void); void test_gt20(void); void test_setBit(void); void te...
C
#include <stdio.h> int main() { int x; int a[] = { 6, 5, 4, 3, 1 , 0}; int *p = a ; // a: x = *p; // b: x=p[3]; // c: x=++p[3]; // d: x=*++p; // e: x=++*p; // f: x=*p++; // g: x=(*p)++; x=p[*(p+2)]; printf("x = %d\n", x); printf("p points to: %d\n", *p); printf("a: { "); ...
C
/*10. Faa um algoritmo em portugues estruturado que leia tres valores numricos e encontre qual o menor deles, mostrando-o no final. Faa o chinesinho ao lado do seu algoritmo. */ #include<stdio.h> #include<locale.h> int main(){ setlocale(LC_ALL, "Portuguese"); float valor1, valor2, valor3; printf("Digite o val...
C
/* Código usado apenas para gerar os dados de entrada das simulações, gera um arquivo texto com a seguinte configuração: A primeira linha tem na respectiva ordem: andar máximo, número de eventos e carga máxima As próximas linhas serão da seguinte forma: 1ª coluna -> andar de origem 2ª coluna -> andar de destin...
C
/* * Copyright (c) 2006, з * All rights reserved. * * ļƣwordprop.h * */ #ifndef _WORD_PROP_H_ #define _WORD_PROP_H_ //ԼtypeԵĴʶǽôʡ #define WORDTYPE_INTERPUNCTION 0x01 // #define WORDTYPE_ENDSENTENCE 0x02 //ӽ־ #define WORDTYPE_LINKWORD_ENGLISH 0x04 //ӢӴ 2004:03:05 2004/03/05 #d...
C
// // https://www.codeeval.com/open_challenges/108/ // computerterminal // // Created by Stephan Warren on 12/30/14. // /* COMPUTER TERMINAL CHALLENGE DESCRIPTION: In this problem you are writing the software for a small terminal with a 10-row, 10-column display (perhaps for a point-of-sale terminal). R...
C
// read.c // backpackcod3r // 03/11/17 // standard c include headers #include <stdio.h> //declare CHUNK Variable and SIZE #define CHUNK 1024 // read 1024 bytes at a time // read from file function void readFile(const char *filepath){ char buf[CHUNK]; size_t nread; FILE *file = fopen(filepath, "r"); if(file) ...
C
#include <stdio.h> int Add(int val); int num=1; /* 전역변수와 동이한 이름의 지역번수가 선언되면? - 해당 지역 내에서는 지역변수가 가리워지고, 지역변수의 접근이 이뤄짐!! */ int main(void) { int num=5; printf("num : %d \n", Add(3)); printf("num : %d \n", num+9); return 0; } int Add(int val) { int num=9; num += val; return num; }
C
/* calculate time difference in sencond */ #include <stdio.h> #include <stdlib.h> #include <time.h> #include <unistd.h> double time_diff_in_second(struct timespec t1, struct timespec t2) { struct timespec diff; if (t2.tv_nsec - t1.tv_nsec < 0) { diff.tv_sec = t2.tv_sec - t1.tv_sec - 1; diff.tv_nsec = t2.tv_ns...
C
/* ////////////////////////////////////////////////////////////////////////////////////// * includes */ #include "../demo.h" /* ////////////////////////////////////////////////////////////////////////////////////// * test */ static tb_void_t tb_demo_database_sql_test_done(tb_database_sql_ref_t database, tb_char_t...
C
/*NIDHI SAINI,SY-E 38 ASSIGNMENT:Write a RemoveDuplicates() function which takes a list sorted in increasing order and deletes any duplicate nodes from the list.Ideally,the list should only be traversed once.*/ #include<stdio.h> #include<stdlib.h> struct abc { int num; struct abc *next; }; typedef struct abc Node; i...
C
/* ======================================================================== * Copyright (c) 2006 The University of Washington * * 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 * * ht...
C
/**************************************** * File Name: briupBasePeriph.h * Date: 2017年8月24日 09点42分 * Author: muxiaozi * Description: 基础外设接口 ****************************************/ #ifndef __BASEPERIPH_H__ #define __BASEPERIPH_H__ #include <stm32f10x.h> //颜色 #define LED_R 0x4 //PC2 #define LED_G 0x2 //PC1 #define LE...
C
/* Title: Polymorphic Add root user (r00t) with no password ( 85 bytes) * Author: pktmonky * Description: Polymorphic version of shell-storm linux x86 shellcode titled * 'Add root user (r00t) with no password to /etc/passwd' by Kris Katterjohn. * All strings have been XOR encoded. */ #include<stdio.h> #include<s...
C
/* ヘッダファイルのインクルード */ #include <stdio.h> /* 標準入出力 */ /* main関数 */ int main(void){ /* 変数の宣言 */ FILE *fp; /* ファイルポインタfp */ FILE *new; /* ファイルポインタnew */ /* 存在しないファイルをわざと開く. */ fp = fopen("test.txt", "r"); /* fopenで"test.txt"を開く. */ if (fp == NULL){ /* NULLなら. */ /* 既存のストリームのリダイレクト. */ new = freopen(...
C
#include<stdio.h> #include<stdlib.h> main(){ char nome[30]; float horas,salario; int nivel; printf("Digite o nome do professor: "); scanf("%s",&nome); printf("Digite as horas trabalhadas: "); scanf("%f",&horas); printf("Digite o Nivel do Professor:\n1-Nivel 1\n2-Nivel 2\n3-Nivel 3\n"); scanf("%...
C
// // Queue.c // CP2_WEEK13 // // Created by stu2017s10 on 2017. 6. 7.. // Copyright © 2017년 stu2017s10. All rights reserved. // #include "Queue.h" struct _Queue { Node* _front; Node* _rear; int _size; }; // Queue 객체의 생성과 소멸 Queue* Queue_new(void){ // Queue 객체의 생성 Queue* _this; _this = NewObj...
C
#include <stdio.h> #include <stdlib.h> #include "colaCircular.h" int main(){ int dato; Cola cola00; iniciarCola(&cola00); while(1){ printf("\nCola circular, elija una opcion:\n"); switch(menu()){ case 1: printf("\n1. Ingresar dato\nDato: "); ...
C
#include <stdlib.h> #include <string.h> #include <memory.h> #include <stdio.h> #define NCHUNKS 16 #define CHUNK0SIZE 1024 typedef unsigned int u_int; struct chunk { u_int n_left; void *m; }; struct blocks { int id; int mark; int data; }; static struct chunk chunks[NCHUNKS]; static int cur_chunk; void * n...
C
#include <stdio.h> #include <curses.h> #include <ctype.h> #include "array.c" // Game Board Constants #define EMPTY ' ' #define AI 'O' #define HUMAN 'X' // Game State Constants #define PLAYING 0 #define TIE 1 #define O_WIN 2 #define X_WIN 3 // Function declarations void humanMove(char board[]); void aiMove(char board...
C
#include "lcd.h" #include "common.h" void init_lcd(struct device* pDev) { gpio_configure_direction(GPIO_RS_IDX, OUTPUT, pDev); gpio_configure_direction(GPIO_RW_IDX, OUTPUT, pDev); gpio_configure_direction(GPIO_EN_IDX, OUTPUT, pDev); gpio_configure_direction(GPIO_D4_IDX, OUTPUT, pDev); gpio_configure_direction(GPI...
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 (int argc, char *argv[]) { printf("location of code : %p\n", main); printf("location of heap : %p\n", malloc(100e6)); int x = 3; printf("location of the stack : %p\n", &x); return x; }
C
#include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <string.h> int main() { FILE *fpr; FILE *fpw; char buffer [BUFSIZ + 1]; memset(buffer, '\0', sizeof(buffer)); fpr = popen("who", "r"); fread(buffer, sizeof(char), BUFSIZ, fpr); fpw = popen("sort","w"); fwrite(buffer, sizeof(char), strlen(buff...
C
#include "stdint.h" #include "mem.h" /* Your first step shall be to implement a good Physical Memory Allocator And when the time comes to turn on Paging, You need a good Memory Management System Altogether Checkout github.com/AshishKumar4/Aqeous for help */ uint32_t* frame_stack_end = (uint32_t*)(16*1024*...
C
//Exercise 1: Create a function called labinfo. void labinfo(){//Displays some information about the lab.# cout<< "Stephen McDonagh\n";//Name. cout<< "Lab #2\n" << endl;//Lab number 2. } //Exercise 2: Create a function that takes two numbers and return the largest. void Largest_Val(){//Ret...
C
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<unistd.h> void main() { char str[6]="hello"; pid_t pid=fork(); if(pid==0) { str[0]='b'; printf("子进程中str=%s\n",str); printf("子进程中str指向的首地址:%x\n",(unsigned int)str); } else { sleep(1); printf("父进程中str=%s\n",str); printf("父进程中str指向的首地址:...
C
// Forward declaration of isBadVersion API. bool isBadVersion(int version); int my_bsearch(int lo, int hi); int my_bsearch(int lo, int hi) { printf ("%d --- %d \n", lo, hi); int mid; if (lo > hi) { return -1; } if (lo == hi) { return (hi); } mid = lo + ...
C
#include <stdio.h> #include <stdarg.h> #include <ctype.h> #include <stdlib.h> /* Exercise 7-4. Write a private version of scanf analogous to minprintf from the previous section. */ #define BUFSIZE 100 static int getch(void); static int ungetch(int c); void minscanf(char *fmt, ...) { int c, bp, *ip; char io_bu...
C
#include <stdlib.h> #include <stdio.h> int main(int argc,char ** argv) { int max=0; int max_val=0; for(int i=2;i<=1000;i++) { double n=(double)1/i; //printf("%f\n",n ); n=n-(int)n; //printf("%f\n",n*10 ); int* numStr=malloc(sizeof(int)*32); for(int j=0;j<32;j++) { int temp=n*10; ...
C
#include "TCPFunctions.h" #define MAXSIZE 255 /* Maximum Buffer size */ FILE *openFile(char* localPath, char *operation){ char cwd[MAXSIZE]; if (getcwd(cwd, sizeof(cwd)) != NULL) { strcat(cwd,"/"); FILE *fp; fp = fopen(strcat(cwd, localPath), operation); if(fp == NULL) { ...
C
unsigned int P(unsigned int n) { int i; unsigned int res = 1; for (i = 1; i <= n; i++) { if (UINT_MAX / i > res) res *= i; else return UINT_MAX; } return res; }
C
/* Write a program using function which calculate the sum and average of two numbers. Use pointer and print the values of sum and average in main().*/ #include <stdio.h> void sum_and_avg(int a, int b, int *sum, float *avg) { *sum = a + b; *avg = (float)*sum / 2; } int main(void) { int a = 456, sum = 0, b ...
C
// // main.c // VTV3007_TinhGiaTriHam2 // // Created by Chel Long on 2/24/19. // Copyright © 2019 Chel Long. All rights reserved. // #include <stdio.h> #include <math.h> double tinhGiaTri(int n, int count) { if(count==n) return sqrt(n); return sqrt(count+tinhGiaTri(n, count+1)); } int main(int argc, const ...
C
#include <stdio.h> //For printf() #include <stdlib.h> //for exit() and atoi() /* masuram timpul dintre -> dif dintre perioade , cuantele de timp cu FIFO, un program simplu while(1) care are un sleep in while ---------|--------------- -> pt jitter masuram timpul dintre cat ruleaza programul si urmatoare planificare l...
C
#include<stdio.h> #define maxsize 101 //Making stack int stack[maxsize]; //Declaring the top counter int top =-1; //making push function void push(int x) { if(top==maxsize-1) { printf("Stack is overflowed\n"); return; } stack[++top] =x; // Can be written as top++ then A[top]=x; but her...
C
#include<stdio.h> #include<sys/socket.h> #include<arpa/inet.h> #include<errno.h> #include<string.h> #include<stdlib.h> #include<sys/types.h> #include<netdb.h> #include<netinet/in.h> #include<unistd.h> #include<time.h> #include<sys/stat.h> #include<sys/select.h> #define PORT "15095" #define WAIT_CONN 0 #define BUFFSIZE...
C
/* ************************************************************************** */ /* */ /* :::::::: */ /* free_data.c :+: :+: ...
C
/** * @file * * @brief A melting pot of basic functions * * See the basic_function.h file for more informations. * *@author Lucy Linder, Mathieu Clement, Yves Kalberer *@version 0.1 *@date 11.11.2012 */ /** * This method is an alternative to the KJunior_delay_s * which is badly implemen...
C
/* * gamerules.h * * Created on: May 10, 2010 */ #ifndef GAMERULES_H_ #define GAMERULES_H_ #define WIN_NUMBER 4 typedef struct { int width; int height; int lastColumn; int totalGameTime; int playerOneTime; int lastMoveTime; char** boardMatrix; // Usage: boardMatrix[column][row] } Board; typedef struct {...
C
/* 19.02.15 <Queue implemented with list> input value 8 size enqueue 4 enqueue 3 front size dequeue front size output value 0 4 2 3 1 */ #include <stdio.h> #include <stdlib.h> #include <assert.h> #include <stdbool.h> struct queue_node{ int data; struct queue_node* next; }; struct queue{ struct queue_node* front; ...
C
#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]){ FILE *fichier = NULL; char chaine[100] =""; fichier = fopen("test.txt","r"); printf("%d\n",fichier); if(fichier == NULL){ exit(0); } fgets(chaine,100,fichier); printf("%s\n",chaine); fclose(fichier); return 0; }
C
#include <stdio.h> #include <stdlib.h> #include<conio.h> #include<ctype.h> #include "funciones.h" #include<string.h> #define TAM 3 int main() { EMovie movie[TAM]; int confirm; char seguir='s'; inicializarPeliculas(movie,TAM); do{ switch(menu()) { case 1: ...
C
#include "mutex.h" #include "utils.h" /* * Paranoid locking ops. */ void init_mutex(struct mutex *m) { *m = (struct mutex)INIT_MUTEX; } void lock(struct mutex *m) { int err = pthread_mutex_lock(&m->mutex); if (err) panic("pthread_mutex_lock: %s\n", strerror(err)); m->owner = pthread_self(); } void unlock(...
C
#include<stdio.h> #include<stdlib.h> struct ListNode { int val; struct ListNode* next; }; typedef struct ListNode Node; struct ListNode* swapPairs(struct ListNode* head) { if (head == NULL || head->next == NULL) { return head; } Node* head1 = head; Node* head2 = head->next; Node* end1 = head; Node* end2 = ...
C
#include "stdio.h" #include "stdlib.h" #include "string.h" //ַ01 void copystr(char *from,char *to) { for(;*from!='\0';from++,to++) { *to=*from; } *to='\0'; } //ַ02 void copystr1(char *from,char *to) { while(*from!='\0') { *to=*from; from++; to++; } *to='\0'; } void copystr2(...
C
/* helloworld.c - Hello World program for OpenCL, modified from an example from the web * Adrian Sai-wah Tam <adrian.sw.tam@gmail.com> * Sun, 19 Dec 2010 01:35:33 -0500 */ #include "helper.h" const char *KernelSource = "__kernel square(__global float* input, \n" \ " __global float* output, \n" ...
C
#include <stdio.h> #include <ctype.h> int main (void){ char ch; printf("Enter input: "); ch = getchar(); if (isdigit(ch)){ printf("this is the output: %c\n", ch); } return 0; }
C
#include <stdio.h> int factorial(int n) { if (n == 0) return 1; else return factorial(n-1)*n; } int main() { printf("%d", factorial(5)); }
C
#include "IntList.h" struct stats { size_t tally; long sum; }; void tally_up(Generic handle, IntListItem value) { struct stats *sp = handle; sp->tally++; sp->sum += value; } void print(Generic meanRef, IntListItem value) { if(value > *((float *)meanRef)) { printf("%d\n"); }...
C
/** @file opcontrol.c * @brief File for operator control code * * This file should contain the user operatorControl() function and any functions related to it. * * Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ * * PROS contains FreeRTOS (http://www....
C
#include <stdio.h> // Inisialisasi atau identifikasi sub program yang dipakai void fuzzifikasi(); unsigned char fuzzifikasi_beban_ringan(); unsigned char fuzzifikasi_beban_sedang(); unsigned char fuzzifikasi_beban_berat(); unsigned char fuzzifikasi_ketinggian_rendah(); unsigned char fuzzifikasi_ketinggian_sedang(); u...
C
#include "Qz/QzTable.h" #include "Qz/QzMemory.h" #include <stdio.h> #include <string.h> #define QZ_START_CAP (17) #define QZ_NEXT_CAP(x) (((x) - 1) * 2 + 1) #define QZ_MAX_LOAD_FACTOR (0.667) struct _qztableentry { QzTableEntry *next; char *key; char *value; qzuint hash; }; static qzui...
C
//conditional operator : ( ? : ) //finding large number between two #include<stdio.h> int main() { int a, b, x; printf("Input two numbers : "); scanf("%d%d",&a,&b); x = (a>b)? a:b; printf("Large number is : %d",x); return 0; }
C
/* ------------------------------------------------------ */ /* PROGRAM game of life : */ /* This is a finite implementation of John H. Conway's */ /* Game of Life. Refere to my book for detail please. */ /* */ /* Copyright Ch...
C
/* Author: lab * Partner(s) Name: Jim Poon * Lab Section: * Assignment: Lab #6 Exercise #3 * Exercise Description: [optional - include for your own benefit] * * I acknowledge all content contained herein, excluding template or example * code, is my own original work. * * Demo Link: * https://drive.google....
C
#include <stdio.h> void Print(int arr[], int sz)//ӡĺ { int i = 0; for (i = 0; i < sz; i++) { printf("%d ", arr[i]); } printf("\n"); } int main() { int arr1[] = {1, 3, 5, 7, 9}; int arr2[] = {2, 4, 6, 8, 10}; int sz = sizeof(arr1) / sizeof(arr1[0]); Print(arr1, sz); Print(...
C
/**===========================================================================+ * * @Author rosenkranz * @file servo.c * @brief Servo driver * * Change: where possible, variables declared as "const" * *============================================================================*/ #include "ch.h" #in...
C
#include<stdio.h> struct studentinformation { char studname[100]; char usn[100]; float coa,dm,ds,ld,java,mp; } main() { struct studentinformation s1; printf("Enter the Name of the student: \n"); scanf("%s",&s1.studname) printf("Enter the USN of the student: \n"); scanf("%s",&s1.usn)...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #define N 20 #include <sys/time.h> double time_diff(struct timeval x , struct timeval y); double time_dif(struct timeval m , struct timeval n); double time_difff(struct timeval p , struct timeval q); //#define size 7 /* Function Prototypes */ int is_sorted(in...
C
#include<stdio.h> void main() { int num; printf("\n Enter the Number : "); scanf("%d",&num); int temp, x=0; temp=num; for(int i=1 ; i<=temp/2 ; i++) { if(temp%i==0) x+=i; } if (x==num) printf("\n The Number is Perfect !\n"); else printf("\n The Number is Not Perfect !\n"); }
C
//---------------------------------------------------- // #### DEXEL 2CH PROJECT - Custom Board #### // ## // ## @Author: Med // ## @Editor: Emacs - ggtags // ## @TAGS: Global // ## // #### TEMPERATURES.C ############################### //---------------------------------------------------- // Includes -------------...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* clone_list.c :+: :+: :+: ...
C
#include <stdio.h> void push(int x); void display(); int top=-1; struct Node{ int data; struct Node* next; }; struct Node* head=NULL; struct Node* head2=NULL; int main(){ int n; printf("Enter number of elements.->"); scanf("%d",&n); int a; for(int i=0;i<n;i++){ scanf("%d",&a); push(a); } ...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> typedef struct Cliente { int identificador; struct Carreta *carreta; struct Cliente *siguiente; } Cliente; typedef struct Caja { int no_caja; Cliente *actual; int tiempo_servicio; char *estado; struct Caja *sig...
C
int main() { int judge=1; int dayofmonth[13]={31,28,31,30,31,30,31,31,30,31,30,31}; int year,month,day; cin>>year>>month>>day; int time=(year-1)/400; for(int i=time*400+1;i<year;i++) { if(i%4==0&&i%100!=0||i%400==0) judge+=2; else judge+=1; } dayofmonth[1]=28; if(year%4==...
C
#pragma once #include "Array.h" #include "Color.h" #include <stdio.h> #include <stdlib.h> #include <time.h> void TestThreshold() { cv::Mat SrcImg = cv::imread("..\\..\\Data\\OtherImages\\kobe.jpg"); cv::Mat GrayImg; clock_t start, finish; start = clock(); cv::cvtColor(SrcImg, GrayImg, CV_BGR2GRAY); cv::Ma...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* print_vtab.c :+: :+: :+: ...
C
#ifndef FORMAH #define FORMAH #include<stdio.h> #include<stdlib.h> #include<string.h> //TAD FORMA typedef void* Forma; /* * cria a forma circulo/retangulo * necessita de que o comando c/r tenha sido chamado * retorna a forma criada */ Forma criarForma (char id[],char tipo[], double x, double y, double r, double...