language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
/* * LedButton.c * * Created: 4/3/2021 2:38:56 PM * Author : remon */ #include <avr/io.h> #define F_CPU 8000000ul #include "DIO.h" #include "LED.h" #include "BUTTON.h" #include <util/delay.h> int main(void) { /* Replace with your application code */ for (int i=0;i<8;i++){ LED_init('A',i); } BUTTON_init('...
C
#include <stdio.h> #define YES 1 #define NO 0 /* ** 删除注释功能 */ static void cleancom(FILE *stream) { int c, nextc, nextcc, nextccc, linecount = 0; // 删除注释功能 while ((c=fgetc(stream)) != EOF) { if (c == '/') // 删除注释功能 if ((nextc = fgetc(stream)) == '/') { while(fgetc(stream) != '\n') ; if (lineco...
C
/** * @brief Set and display tty config bits. * * Surprisingly complete. * * We used to use Minix's stty, so I may have adopted some conventions from it * that aren't in other stty's, but I don't even remember any more. * * @copyright * This file is part of ToaruOS and is released under the terms * of the NCS...
C
/* CostPrice < SellingPrice => Profit CostPrice > SellingPrice => Loss CostPrice == SellingPrice => No profit / loss Input: -> Two inputs: costPrice and sellingPrice */ #include<stdio.h> int main() { float costPrice, sellingPrice; printf("Enter cost price and sellng price value: "); ...
C
// File: file-copy.c // Created by hengxin on 17-10-18. /** * Copying file character by character using getchar(). * * K&R Section 1.5.1 * * Practice: * - file-copy * - count lines */ /** * EOF: http://www.cplusplus.com/reference/cstdio/EOF/ (文件结束符):由宏定义的整型数 * \begin{itemize} * \item EOF 是整型数 (int c;...
C
#include <stdio.h> #include <stdlib.h> int max(int,int); int min(int,int); int main() { int i,numbers_len; printf("How many numbers? "); scanf("%d",&numbers_len); //int numbers[numbers_len]; //in this context this two lines are equivalent int *numbers = (int*)malloc(numbers_len*sizeof(int)); ...
C
/* * 结构本身不能含有同类型的结构,但是可以包含指向下一个结构的指针,这是链表的基础 * 使用结构链表 */ #include <stdio.h> #include <string.h> #include <stdlib.h> #define TSIZE 45 struct film { char title[TSIZE]; int rating; struct film * next; //指向下一个链表的结构 }; int main() { struct film * head = NULL; struct film * prev, * current; char...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> int main(int argc, char *argv[]) { if(sizeof(void *) == 8) (void)fprintf(stderr,"Pointers are 8 bytes (64 bit mode)\n"); else (void)fprintf(stderr,"Pointers are 4 bytes (32 bit mode)\n"); (void)fflush(stderr); exit(0); }
C
int maxProfit(int* prices, int pricesSize) { int i; int max_profit = 0; int min_price = 0x7fffffff; if (prices == NULL || pricesSize < 2) return 0; for (i = 0; i < pricesSize-1; i++) { min_price = min(prices[i], min_price); max_profit= max(prices[i+1] - min_price, max_pro...
C
// // Created by Najima Jaadari on 25.12.17. // #ifndef INFO2UEBUNG2_DATETIME_H #define INFO2UEBUNG2_DATETIME_H #include "datastructure.h" /*************************************************************************** * isLeapYear * check if the year is a leap-year * parameter: year to proof * return : boolea...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdint.h> // uint64_t #define max(a,b) ((a) > (b) ? (a) : (b)) #define min(a,b) ((a) > (b) ? (b) : (a)) #define BUF_SIZE 100050 // size: specify sizeof(str) int get_str(char *str, int size) { if(!fgets(str, size, stdin)) return -1; return 0;...
C
#include <stdio.h> #define inf 9999 #define max 10 void MST_PRIM(int[max][max], int); int extractMIN(int[max], int[max], int); void PRINT_PARENT(int[max][max], int[max], int); int main(int argc, char const *argv[]) { int vertices = 0, i = 0, j = 0; int graph[max][max]; printf("Input the number of vertice...
C
a): Write a program to find out the total number of prime numbers below 1,000,000 have the sum of their digits equal to 14? Answer : 1218 b) Write a program to find out the total number of prime numbers below 10,000,000 have the sum of their digits equal to 14? Answer: 3547 c) Write a program to find ...
C
/* * File: cslib.h * ------------- * This interface defines a basic set of definitions that are shared * among all interfaces in the package. These basic definitions include: * *<ol> * <li>Declarations for several new &ldquo;primitive&rdquo; types used * throughout the libraries as fundamental types. * ...
C
/* * PetMem Control utility * (c) Jack Lange, 2012 */ #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <sys/ioctl.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #include <string.h> #include <dirent.h> #include "../petmem.h" #define SYS_PATH "/sys/devices/system/memo...
C
#ifndef __SEQUENCELIST_H__ #define __SEQUENCELIST_H__ /************************结构体定义区**************************/ typedef int DataType; #define MaxSize 2000 typedef struct { DataType list[MaxSize]; int len; }SeqList; /************************函数定义区**************************/ //初始化一个顺序表 void initList(SeqList *L); /...
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
/* * buffer.h - define a buffer struct. * * this buffer struct is a circular buffer. * * Author: Shan Jiejing * Date: 2016.11.15 */ #ifndef _BUFFER_H_ #define _BUFFER_H_ #define BUFF_SIZE 32 typedef struct Buffer { unsigned char pBuffer[BUFF_SIZE]; unsigned char head; unsigned char end; unsigned char ful...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_outputtwo_four.c :+: :+: :+: ...
C
/* This program is a part of RW mudlib * See /doc/help/copyright for more info ----------------------------------------- * File : tail.c * Author : Clode@RevivalWorld * Date : 2001-07-11 * Note : tail OC * Update : * o 2002-09-17 Clode W[ -b -c -f -d Ѽ * ----------------------------------------- */ ...
C
/************************************************************************* > File Name: common.c > Author: > Mail: > Created Time: 2020年04月12日 星期日 19时18分31秒 ************************************************************************/ #include "./head.h" void printfName() { struct passwd *pwd; uid_t uid =...
C
#include "MainMenuState.h" #include "Keyboard.h" #include "Graphics.h" #include "Mouse.h" #include "Utilities.h" Rectangle* newRectangle(int x, int y, int width, int height) { Rectangle* rectangle = (Rectangle*) malloc(sizeof(Rectangle)); rectangle->x = x; rectangle->y = y; rectangle->width = width; rectangle->h...
C
#include <stdio.h> #include <stdlib.h> #include "fogefoge.h" #include <time.h> #include "mapa.h" #include <string.h> #include "ui.h" MAPA m; POSITION hero; int tempilula = 0; int praondeofantasmavai(int xatual, int yatual, int* xdestino, int* ydestino){ int opcoes[4][2] = { {xatual, yatual + 1}, ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* raycasting.c :+: :+: :+: ...
C
/* *@author João Victor *@date 29.08.2020 */ #include <stdio.h> int main() { int i, n, cont; int n_att = 1; while (1) { scanf("%d", &n); if (n == 0) break; while (1) { cont = 0; for (i = 1; i <= n; i++) { int aux; scanf("%d", &aux); if (aux == ...
C
/****************************************************************************** Online C Compiler. Code, Compile, Run and Debug C program online. Write your code in this editor and press "Run" button to compile and execute it. *****************************************...
C
#include"Stack.h" #include<stdio.h> #include<stdlib.h> int main() { stack *st; st=(stack *)malloc(sizeof(stack)); char k; int temp; create(st); while(1) { printf("\nOptions\n"); printf("1.Push in Stack\n2.Pop from Stack\n3.Top element in Stack\n4.Print the stack\n5.Tell the s...
C
#include <stdint.h> #include "FreeRTOS.h" #include "task.h" void vPeriodicTask(void *pvParameters) { // Establish the task's period. const TickType_t xDelay = pdMS_TO_TICKS(1000); TickType_t xLastWakeTime = xTaskGetTickCount(); for (;;) { // Block until the next release time. vTaskD...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* fillit_tools.c :+: :+: :+: ...
C
#include "WS2812B_RGB_Driver.h" //λ void RGB_Rst() { WS2812_1 = 0; WS2812_2 = 0; } //24λ void Send_2811_24bits(unsigned char *Line_1, unsigned char *Line_2, unsigned int n ) { unsigned char value_1,value_2,j; value_1 = Line_1[n]; value_2 = Line_2[n]; for(j = 0; j < 8; j ++) { EA = 0; //0룬ߵƽ850ns ͵ƽ4...
C
/* ============================================================================ Name : list.c Author : mahendra pratap singh Version : Copyright : Your copyright notice Description : Hello World in C, Ansi-style ============================================================================ */ ...
C
#include <stdio.h> int main() { float k; float c; printf("Digite uma temperatura em Kelvin: "); scanf("%f", &k); c = k - 273.15; printf("Essa temperatura convertida em graus Celsius: %f\n", c); return (0); }
C
/* disk.h: SimpleFS disk emulator */ #ifndef DISK_H #define DISK_H #include <stdbool.h> #include <stdlib.h> /* Disk Constants */ #define BLOCK_SIZE (1<<12) #define DISK_FAILURE (-1) /* Disk Structure */ typedef struct Disk Disk; struct Disk { int fd; /* File descriptor of disk image */ ...
C
#include <stdio.h> #include <stdbool.h> /** 是否为丑数。 丑数就是只包含质因数 2, 3, 5 的正整数。 */ bool isUgly0(int num){ if (num <= 0) { return false; } int count[] = {2,3,5}; for (int i = 0; i < 3; i++) { while (num%count[i] == 0) { num = num/count[i]; } } if (num == 1) { ...
C
#include <stdio.h> #include <stdlib.h> typedef struct NO { int key; struct NO *prox; }NO; typedef struct PILHA { NO *topo; }PILHA; void criar(PILHA *p){ p -> topo = NULL; } void inserir(int x, PILHA *p){ NO *novo_no = (NO*) malloc(sizeof(NO)); if(novo_no == NULL){ printf("Err...
C
#include "holberton.h" /** **_memset - replace the first characters of an array by a set char n times * *@s: character array * *@b: character which its going to replace the first chars of the main array * *@n: number of times in which our char variable its going to be put * *Return: char when succeed */ cha...
C
/* tcp protocol feature 1. data is reliable 2. data transport in order 3. data boundary is not exist because tcp is connection oriented protocol */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <arpa/inet.h> #include <sys/socket.h> void error_handling(char *mess...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* prompt.c :+: :+: :+: ...
C
#include <utmpx.h> #include <stdio.h> int main(void){ struct utmpx *utx; printf("LoginName Line\n"); printf("---------------\n"); while((utx=getutxent()) != NULL){ printf("%s %s\n", utx->ut_user,utx->ut_line); } return 0; }
C
#include <stdio.h> #include <math.h> #define MAXN 500001 #define lson l,m,n<<1 #define rson m+1,r,n<<1|1 char name[MAXN][10]; int count=1,a[MAXN],f[MAXN],ma[MAXN<<2]; int max(int a,int b) { return a>b?a:b; } void factor(int n) { if(f[n]) return; int i,r,ans=2,s=sqrt(n); for(i=2;i<=s;++i) if(n%i==0) ...
C
#include "interrupt.h" extern void int_crl_mask_able(unsigned int ctl, unsigned int mask); //r0表示设置哪个中断控制器,r1表示是否使能控制器 extern unsigned int int_get_offset(); //r0返回中断值 extern void clear_int_pnd(unsigned int clear_bits); //r0表示清除哪一位的中断 static irq_func_type irq_func_array[32] = {0}; void register_irq(int irq, irq_func...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> #include "output.h" void fillvec (double* vector) { int i; for (i = 0; i < 1000; ++i) { if (i % 2 == 0) { vector[i] = 0.5; } else { vector[i] = -0.5; } } } double L2norm (double* vector) { int i; double sum = 0; for (i=0;i<(s...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include "operations.h" void slotsfunction(int numofplayers, int *numofslots) { int i; //Counter int dice; //Used when we need a random number setbuf(stdout, NULL);//For scanf to function properly srand(time(...
C
#include <stdio.h> #include <math.h> int pd(int x){ int a,b,c; a = x/100; b = x/10%10; c = x%10; int s = 0; s += a*a*a; s += b*b*b; s += c*c*c; if(s == x){ return 1; } return 0; } int main(){ int m = 100,n = 999; // while(scanf("%d %d",&m,&n) != EOF){ int cz = 0; for(int i=m; i<=n; i++){ if(pd(i)){...
C
#include <stdio.h> /* Return 1 when any odd bit of x equals 1; 0 otherwise. Assume w = 32*/ int any_odd_one(unsigned x){ return !!(x & 0x55555555); } int main(){ printf("%d\n", any_odd_one(0x01010101)); printf("%d\n", any_odd_one(0x11111111)); printf("%d\n", any_odd_one(0x22222222)); pr...
C
// // cblas_srotg.c // COBLAS // // Copyright (c) 2013-2018 University of Colorado Denver. All rights reserved. // #include <coblas.h> #include <math.h> void cblas_srotg(float *A, float *B, float *C, float *S) { const float one=1.0f; const float zero=0.0f; float a=*A; float b=*B; float c=*C; ...
C
#include "./keyboard.h" // pointer to the first elem in linked list t_key *first = NULL; void add_tail(unsigned char scancode) { t_key *idx = first; t_key *new_node = NULL; // create new node new_node = (t_key *)kcalloc(1, sizeof(t_key), GFP_KERNEL); if (new_node == NULL) { pr_info("Malloc failure\n"); ret...
C
#include <stdio.h> #include <stdlib.h> int main(int argc, char const *argv[]) { FILE *fp; int a,b; a = 0; b = 0; fp = fopen("test.txt","r"); if(fp == NULL) { printf("ファイルを開けませんでした\n"); exit(-1); } fscanf(fp, "a = %d\n", &a); fscanf(fp, "b = %d\n", &b); fclose(fp); printf("a = %d\n...
C
#include "stdio.h" int main (void){ int i; //12 meses com três caracteres cada char nomeMes[12][4] = {"jan", "fev", "mar", "abr", "mai", "jun", "jul", "ago", "set", "out", "nov", "dez"}; for (i=0; i<12; i++){ printf("%2d - %s\n", i+1,nomeMes[i]); } }
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <pthread.h> pthread_cond_t s1_signal = PTHREAD_COND_INITIALIZER; pthread_cond_t s2_signal = PTHREAD_COND_INITIALIZER; int t1_gone = 0, t2_gone = 0, t3_gone = 0; pthread_mutex_t s1_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t s2_mutex = PTHREAD_M...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #define SIZEofFILE 2001 #define SIZEofLINE 200 #define TRUE 1 #define FALSE 0 void clearDuplicating(char array[SIZEofFILE][20]); void gamesThroughYears(float floatInfos[SIZEofFILE][7],char names[SIZEofFILE][SIZEofLINE]); void showAllInfos(float floatInfos[SIZE...
C
#include "directorios.h" #define CACHESIZE 100 static struct UltimaEntrada UltimasEntradas[CACHESIZE]; int cursor = 0; /* -Función: Extraer_camino. ** -Descripción: Dada una cadena de caracteres "camino", separa su contenido ** en dos(inicial o final). ** -Parámetros: Tiene el puntero a la cadena camino y los puntero...
C
#include <stdio.h> #include <malloc.h> #include <string.h> #define maxN (1 << 16) - 1 typedef struct G { int u, v, w; } Graph; int Cin(int flag) { int n; char ch; while (1) { if (scanf("%d", &n) != 1) { do { ch = getchar...
C
/** * @file main.c * @author Giancarlo Buenaflor <e51837398@student.tuwien.ac.at> * @date 18.12.2020 * * @brief Main program module. * * This program takes a list of strings in stdin as input and sorts them via a parallel mergesort algorithm (forksort) using forks and pipes **/ #include <stdio.h> #include <u...
C
#include <stdio.h> #include <libplayerc/playerc.h> #include <math.h> int main(int argc, const char **argv) { int i; float vlong=0, vrot=0; float destx, desty, distobst, angdest, campo_obst, ang_rot; int state; printf("Digitar as coordenadas:"); scanf("%f %f", &destx, &desty); //Cliente para conexão c...
C
#include<stdio.h> #include<stdarg.h> int avg(int args,...) { va_list ap; va_start(ap,args); int i=0,sum=0; for(i=0;i<args;i++) sum=sum+va_arg(ap,int); va_end(ap); sum=sum/args; return sum; } int main() { printf("Average =%d\n",avg(3,1,2,3)); return 0; }
C
#include<stdio.h> #include<ctype.h> void main() { int cse,cse_lab,phy,phy_lab,math,eng; float sgpa,cp,clp,mp,ep,pp,plp; int t_credit=14; float t_sub_credit; int t_persub_credit; float cse_spc; float cse_l_spc; float phy_spc; float phy_l_spc; float math_spc; float eng_spc; ...
C
/** * error_driver.c - Error output Driver * Part of the ALMOND Project * _ _ __ __ ___ _ _ ____ * / \ | | | \/ |/ _ \| \ | | _ \ * / _ \ | | | |\/| | | | | \| | | | | * / ___ \| |___| | | | |_| | |\ | |_| | * /_/ \_\_____|_| |_|\___/|_| \_|____/ * */ #include "error_driver....
C
/*գҪıйص䡣 һlooptimes (0<looptimes<10) looptimes 㣺 m n(1<=m,n<=1000) m n ֮Ӻȵ磬16 Ҫ岢ú factorsum(number)ĹǷnumberӺͣβnumberͣ͡磬factorsum(12)ķֵ16(1+2+3+4+6) ʹ䣺printf("%d ", i); ʾ˵ 룺 2 (looptimes=2) 20 500 (m=20 n=500) 1 100 (m=1, n=100) 28 496 (20500֮У28,496) 6 28 (1100֮У1,6,28) */ #include "stdio.h" #includ...
C
// // Created by Amaael Antonini on 2/10/17. // //317 lines (285 sloc) 7.11 KB /* for file and terminal I/O */ #include <stdio.h> /* for string manip */ #include <string.h> /* for exit() */ #include <stdlib.h> /* for fabsf() */ //#include <math.h> #include "Functions.h" #define BUFF_SIZE 1024 void reintegrate(float...
C
#include <time.h> #include <stdlib.h> #include <stdio.h> /** * main - Entry point * Description: creates a text whose * sum of characters in ASCII is exactly 2772 * Return: 0 Always */ int main() { char pswd[200]; int randn, sum = 0, i = 0; srand(time(0)); do { randn = rand() % (127 - 33) + 33; pswd[i...
C
#include<stdio.h> #include<stdlib.h> struct node { int data; struct node *left; struct node *right; }; struct node *newnode(int data) { struct node *node=(struct node *)malloc(sizeof(struct node)); node->data=data; node->left=NULL; node->right=NULL; return node; } struct node *insert(struct node...
C
#include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> #include <sys/types.h> int main(int argc,char **argv) { int fd; if((fd=open("example_62.c",O_CREAT|O_EXCL,S_IRUSR|S_IWUSR))==-1) { if((fd=creat("example_62.c",S_IRWXU))==-1) ...
C
#include "lead.h" void openAccount()//ڽṹһԱһϢ { int accNumber;//˺ char accName[9];//˻ char accPWD[7];//˻ double cash;//ֽ //ʼ accNumber = 0; memset(accName, 0, sizeof(accName)); memset(accPWD, 0, sizeof(accPWD)); cash = 0; accNumber = creatAccNumber(); getaccName(accName); getaccPWD(accPWD); cash = getcash(...
C
#include<stdio.h> int main(void) { char *str = "edge"; char *str1 = "edge"; int a = sizeof"global"; if("global" == "global") printf("----\n"); else printf("*****\n"); if(str == str1) printf("global"); else printf("not global"); printf("%s\n","punam"); printf("%d\n",a); }
C
#include "vec_file.h" int compare (gconstpointer a, gconstpointer b) { GString* str1 = (GString*)a; GString* str2 = (GString*)b; return strcmp(str1->str, str2->str); } gboolean traverse(void* key, void* value, void* data) { GString* key1 = (GString*) key; printf("%s\n", key1->str); return FALSE; } GTree...
C
/************************************************************************* > File Name: tcp_client.c > Author: > Mail: > Created Time: 四 6/14 15:35:28 2018 ************************************************************************/ #include <stdio.h> /* for EXIT_FAILURE */ #include <stdlib.h> /* for socket() */ ...
C
/* * ADCT_SIM900_LL.c * * Created on: May 12, 2017 * Author: Administrator */ #include <PZEM004T.h> #include <stdio.h> #include <string.h> #include "fifo.h" #include "ADCT_BGS_FPT_Delay.h" #include "ADCT_BGS_DataTypes.h" #include "string.h" #include "math.h" extern FPT_SystemStatus GstSystemStatus; static...
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
/***************************************************************************** File: lab7.c Author: Clare Bates Congdon Edited by: Adnan Fazeli and Casey Rosenthal Date: Tue Oct 27 00:17:47 2009 Description: Fitness function for Lab 7. Not sure if we got this exactly right. We had to make the popu...
C
#include<stdio.h> #include<stdlib.h> struct Node { int data; struct Node *next; }; struct Node *head =NULL; void push(int data) { struct Node *new_node = (struct Node*) malloc(sizeof(struct Node)); new_node->data=data; new_node->next=head; head=new_node; } void append(int data) { struct Node *new_node = (stru...
C
/* ** EPITECH PROJECT, 2020 ** COMPILE_POST_LABEL ** File description: ** Compile_post_label function */ #include <stdlib.h> #include <limits.h> #include "list.h" #include "my_str.h" #include "my_str_is.h" #include "my_math.h" #include "asm.h" #include "op.h" #include "strings.h" static int get_compiled_label(data_t ...
C
#include "arrayInit.h" int** getMemory(int N, int M, int callocFlag) { int** mas = NULL; if (callocFlag == 0) { mas = (int**)malloc(sizeof(int*) * N); for (int i = 0; i < N; i++) { mas[i] = (int*)malloc(sizeof(int) * M); } } else { mas = (int*...
C
//Arrays, Pointers, and Strings #include <stdio.h> #include <stdint.h> int main(void) { int32_t a = 0; // Depending on what compiler you have, the order in which variables are saved in memory locations may differ (upwards vs downwards) int32_t b = 0; int32_t array[2] = {0}; //array[0] // Equivalent ...
C
#include <stdio.h> #include <stdlib.h> #include "omp.h" int fila[200000]; int ultimo = 0; int primeiro = 0; int cheio = 0; void push(int x); int pop(); int main() { double t1, t2; int x = 200000; int tam = x; int opcao, numero; t1 = omp_get_wtime(); while (tam--) { push(tam); ...
C
typedef unsigned int size_t; /*@ predicate swap_in_array{L1,L2}(int* a, integer b, integer e, integer i, integer j) = b <= i < e && b <= j < e && \at(a[i], L1) == \at(a[j], L2) && \at(a[j], L1) == \at(a[i], L2) && \forall integer k; b <= k < e && k != j && k != i ==> \at(a[k], L1) == \at(a[k], L2); a...
C
#include "main.h" /** * print_alphabet_x10 - print alphabet 10 times * Description: prints alphabet 10 times * Return: 0 */ void print_alphabet_x10(void) { int round = 0; char c = 'a'; while (round < 10) { c = 'a'; while (c <= 'z') { _putchar(c); c++; } _putchar('\n'); round++; } }
C
#include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/param.h> #include <fcntl.h> #include <inttypes.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #include <time.h> #include <errno.h> #include <signal.h> #include <ctype.h> bool quiet = fa...
C
/** * @file search.h * * <JA> * @brief 2ѥǻѤ벾򰷤¤ * * Ǥϡ2ѥΥåǥǥ󥰤Ѥ벾ι¤ * Ƥޤ. NODE ʬʸݻץ丽ߤViterbi * 쥹٥ꤵ줿üե졼ʤɤ͡ʲ * ݻޤ. WordGraph ñ쥰˥ñ򤢤魯 * ΤѤޤ. NEXTWORD ñŸ˼ñɽޤ. POPNODE * õֲĻ벽ǽ (--enable-visualize) ˡõβĤƤ * Τ˻Ȥޤ. * </JA> * * <EN> * @brief Strucures for handling hypotheses on the 2nd pass. * </EN> * * ...
C
#include "holberton.h" /** * create_array - Create an array of characters * @size: Size of array * @c: Character inside array * * Return: Pointer to array of characters */ char *create_array(unsigned int size, char c) { char *p_arr; unsigned int count; if (size == 0) { return (NULL); } p_arr = malloc(siz...
C
#include <stdio.h> #include <stdlib.h> // malloc, rand #include <time.h> // time #include <assert.h> #define MAX_ELEM 20 typedef struct { int *heapArr; int last; int capacity; } HEAP; //재귀함수 쓰기위해서 함수 미리 선언 static void _reheapUp(HEAP *heap, int index); static void _reheapDown(HEAP *heap, int index); HEAP *heapCre...
C
#include<stdio.h> #include<stdlib.h> //the insert sort /** * @brief insert_sort * 将要排序的数插入到之前已经排好序的数列中 * * @param arr[] * @param len */ void insert_sort(int arr[], int len){ int i ; int j ; int key;//to rember the num you want to insert for(i = 1;i < len; i++){ key = arr[i]; j = i - 1; while(j>=...
C
#include <zephyr.h> #include <misc/printk.h> #include <uart.h> #define UART_DEV_NAME "UART_1" void main() { struct device *uart_dev = device_get_binding(UART_DEV_NAME); if(!uart_dev) { printk("Cannot get UART_1 device!\n"); return; } printk("Find UART_1!\n"); unsigned char ch...
C
#include <stdlib.h> #include <stdio.h> #include "pos.h" #include "logic.h" #include "board.h" void evidence_make_pos(){ printf("** testing make pos\n"); //test1 pos pos_new = make_pos(3,4); printf("expecting r: 3 c: 4 \n"); printf(" r: %d, c: %d \n",pos_new.r,pos_new.c); printf("\n"); //test 2 pos pos_two =...
C
#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #define PIPENAME "./named_pipe_file" int main(void){ int ret; char msg[512]; int fd; pid_t pid; //delete if named pipe is exists ret = access(PIPENAME, F_OK); if(ret =...
C
#include <stdlib.h> #include "avlTree.h" #include "node.h" typedef struct _dataContainer dataContainer; struct _avlTree { node * root; int (*cmp)(void *, void *); void (*dealloc)(void *); }; static void recursiveDeleteNode(node *, void (*dealloc)(void *)); static node * insertNode(node *, node *, int (*cmp)(void...
C
/*############################################################################## # # Copyright 2010-2012 Carlos Ramisch, Vitor De Araujo # # readline.c is part of mwetoolkit # # mwetoolkit is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # th...
C
/* * Video Lecture: 13 * Programmer: Arif Butt * Course: System Programming with Linux */ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int main(int argc, char * argv[]){ int accmode, flags; int fd = open(argv[1], O_RDONLY); flags = fcntl(fd, F_GETFL,...
C
#include<stdio.h> #include<sys/types.h> #include<sys/socket.h> #include<netinet/in.h> #include<arpa/inet.h> int main() { int sockfd1,len1,j,a,num1,sum1,num,Q,q; struct sockaddr_in sa1; sockfd1=socket(AF_INET,SOCK_STREAM,0); sa1.sin_family=AF_INET; sa1.sin_addr.s_addr=inet_addr("127.0.0.1"); sa1.sin_port=6002; ...
C
// Project 7 //Author: Clare Kinery #include <fstream> #include <stdio.h> #include <fcntl.h> #include <errno.h> #include "string.h" #include <iostream> #include <cmath> #include <stdlib.h> #include <unistd.h> #include <vector> #include <string> #include <math.h> #include <ctype.h> #include <iostream> #include <ioman...
C
#include "client.h" void inputaddr(char *addr, int* portnum){ system("clear"); printf("==================================================\n"); printf("==================================================\n"); printf("Input Server's Ipv4 Address : "); fgets(addr, BUFSIZ, stdin); printf("Input Port Num...
C
#include<stdio.h> int main() { int num,i,j,changer; int a[1000]; scanf("%d",&num); for(i=0;i<num;i++) { scanf("%d",&a[i]); } for(i=0;i<num-1;i++) { for(j=0;j<num-1;j++) { if(a[j]>a[j+1]) { changer=a[...
C
#ifndef __RPI_H__ #define __RPI_H__ // begin defining our r/pi library. /************************************************************ * The following routines are written by us. They are in * start.s: look at the implementations --- they are not * complicated! * * They are used to prevent the compiler from r...
C
// // editor.c: text editor with "modes", from hexidecimal monitor to ascii editing // #include "../include/C/stdint.h" #include "../include/C/string.h" #include "../include/gfx/2d_gfx.h" #include "../include/print/print_types.h" #include "../include/disk/file_ops.h" #include "../include/print/print_fileTable.h" #inclu...
C
/************************************ * Author: ChenR * * Reviewer: Tamir * * dllist * * 7/11/2019 * * * ************************************/ #include <stdlib.h> /* malloc */ #include <assert.h> /* assert */ #include "dllist.h" #include "../../chen/MyUtils.h" /* MAX2,MIN2 */ str...
C
// // Copyright (c) 2022 IOTech Ltd // // SPDX-License-Identifier: Apache-2.0 // #ifndef _IOT_FILE_H_ #define _IOT_FILE_H_ /** * @file * @brief IOTech File API */ #include "iot/os.h" #ifdef IOT_HAS_FILE #ifdef __cplusplus extern "C" { #endif /** * @brief Load string from file path, returns file contents as a ...
C
#include <stdio.h> #include <stdint.h> int main(){ int32_t check = 0; int32_t r = 0; int32_t n = 0 ; double ans = 0; printf("Please enter the resistance (1-100): "); scanf("%d", &check); while (!(check>=1 && check<=100)){ printf("input error!"); printf("PLease enter the resistance (1-100): "); scanf("%d...
C
extern int printf(const char *str, ...); int a = 42; int b = 13; int main(void) { int res = a; /* firm inverted the condition code instead of negating it when swapping * the inputs of a cmov (so it could use address mode) */ if (b != 0) res = b; printf("%d\n", res); return 0; }
C
/* Name: Andrew Nishimura Assignment: Project 1 Instructor: Ravi Narayan Descrption: this program shows a menu and takes user input from comand line to create a record */ # include <stdio.h> # include <string.h> # include <stdlib.h> # include "record.h" void showmenu(); void takeusercommand( char[]); struct reco...
C
#include <unistd.h> #include <fcntl.h> #define RWX_ALL (S_IRWXU | S_IRWXG | S_IRWXO) int main(int argc, char *argv[]) { char *filename = "sparse.file"; int fd = -1; umask(0111); if ((fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, RWX_ALL)) == -1) { if ((fd = open(filename, O_WRONLY | O_TR...