language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <setjmp.h> #include <stdio.h> static jmp_buf buf; static int mul(int depth) { int i=0; if (depth == 0 && setjmp(buf)) { printf("Return final depth: %d\n",depth); return 0; } else{ switch (scanf("%d", &i)) { case -1 : printf("Ok\n"); return 1; /* neutral element */ case 0 : printf("Ok\...
C
#include "head.h" int menu() { system("cls"); printf("==========================================\n"); printf("Yeon's ýۿ Ű ȯմϴ.\n"); printf("==========================================\n"); printf("޴ Ͻÿ.\n"); printf("1. \n"); printf("2. ֹ\n"); printf("3. \n"); printf("=========================================...
C
/* ============================================================================ Name : Advent_2020_Day_13.c Author : Version : Copyright : Your copyright notice Description : Hello World in C, Ansi-style ============================================================================ */ #include...
C
#include <stdio.h> int main(void){ char s[4]; int value=700; scanf("%s",s); if(s[0]=='o') value+=100; if(s[1]=='o') value+=100; if(s[2]=='o') value+=100; printf("%d\n",value); return 0; } ./Main.c: In function main: ./Main.c:5:2: warning: ignoring return value of scanf, declared with attribute warn_un...
C
#include "queue.h" struct Customer{ int window; unsigned int time; }; int bestWindow(Queue<Customer> windows[],int nWin); void simulate(int nWin, int servTime) { Queue<Customer>* windows = new Queue<Customer>[nWin]; for(int now = 0;now < servTime;now++){ if(rand() % (1 + nWin)){ C...
C
#include "includes.h" #include "string.h" #include "app_cfg.h" #include "delay.h" #include "debug.h" #include "led_task.h" OS_TCB LED_TASK_TCB; CPU_STK LED_TASK_stk[LED_TASK_STK_SIZE]; uint8_t Led_Mode = HAL_LED_MODE_FLASH_SLOW; void LED_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; /* GPIOD Periph clock e...
C
#include <stdio.h> float przelicz(float w_dolarach); main() { float dolary,funty; printf("podaj kwote w dolarach\n"); scanf("%f",&dolary); funty=przelicz(dolary); printf("%f $ to %.2f funta/funtow\n",dolary,funty); } float przelicz(float w_dolarach) { return w_dolarach/1.98; }
C
#include <stdio.h> #include <conio.h> #include <stdlib.h> void main() { int num,d[50],count=0,i; printf("Enter a number: "); scanf("%d",&num); if(num!=1) { printf("Factors of %d are: ",num); for(i=1;i<=num;i++) { if(num%i==0) { count++; d[c...
C
/* * Write a program that accepts a positive integer as input and then displays * all the prime numbers smaller than or equal to that number. */ #include <stdio.h> int isprime(int i) { for (int j = 2; j * j <= i; j++) { if (i % j == 0) return 0; } return 1; } int main (void) { ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <malloc.h> struct huffman{ char deger; int tekrar; int toplandiMi; struct huffman* next; struct huffman* left; struct huffman* right; }; struct huffman* start=NULL; struct huffman* temp; struct huffman* temp2; struct huffman*...
C
#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { float cent=5; float alv; alv=9.0/5.0*cent+32; printf("%f\n",alv); system("PAUSE"); return 0; }
C
#include <std.h> #include "../keep.h" inherit KEEP; void create() { ::create(); set_short("%^YELLOW%^Keep Blacktongue%^RESET%^"); set_long("This is the eastern part of the Keep. To the west of you are "+ "the ruins of an alchemist shop. A wooden %^YELLOW%^sign%^RESET%^ has been planted in the "+ "ground next t...
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 <stdint.h> #include <stdlib.h> #include "boardset.h" static union boardset_node *alloc_node(bool is_leaf) { union boardset_node *node = malloc(sizeof(union boardset_node)); if (is_leaf) { node->l[0] = false; node->l[1] = false; } else { node->b[0] = NULL; node->b[1] = NULL; } return node; } b...
C
#include <stdio.h> int main(void) { // your code goes here int H,W,h,w; scanf("%d %d %d %d", &H, &W, &h, &w); printf("%d", H*W-h*W-w*(H-h)); return 0; } ./Main.c: In function main: ./Main.c:6:2: warning: ignoring return value of scanf, declared with attribute warn_unused_result [-Wunused-result] scanf("...
C
#include <stdio.h> int main() { // 将输出的前面补上0,直到占满指定列宽为止 int a = 4; printf("%02d", a); // 输出:04 // 也可以用 * 代替位数,在后面的参数列表中用变量控制输出位数 int b = 4; int n = 3; printf("%0*d", n, b); // 输出:004 return 0; }
C
/* * Implementation of 'dlist,' a simple doubly linked list. * This version of the program has memory leak issues * and segmentation fault issues. Students are supposed * to fix these problems with the tools of 'gdb' and * 'Valgrind'. * * Xiannong Meng * 2015-12-07 */ #include <stdio.h> #include <string.h> ...
C
#include <stdio.h> #include <stdlib.h> #include <vffi_user.h> //int setenv(const char *name, const char *value, int overwrite); //int unsetenv(const char *name); //char *getenv(const char *name); //char *secure_getenv(const char *name); vffiLine_t* c_getenv(vffiNaturalDimArr_t* name) { assert(name != NULL); char...
C
#include <stdio.h> #define MAXLENGTH 1000 int getline2(char [],int); void copy(char [],char []); void cleanline(char line[], int length); int main() { int len = 0; char line[MAXLENGTH]; while((len=getline2(line,MAXLENGTH))>0){ /* printf("%d\n",len); */ cleanline(line, len); printf("%s", l...
C
#include "stdafx.h" #include <stdio.h> #include "tipos.h" #include <stdlib.h> #include <string.h> #define NUMERO_ITEMS 7 #define OPCOES_MENU 5 void menu(void){ char *item_menu[OPCOES_MENU] = {"Criar", "Remover", "Listar", "Pesquisa Geral", "Pesquisa Personalizada"}; char *sub_item_menu[NUMERO_ITEMS] ...
C
#include <stdio.h> #include "malloc.h" int main() { int *p, *p2, *p3; p = calloc(1, 1000000); p = realloc(p, 2000000); p2 = calloc(1, 1000); p3 = calloc(1, 100); free(p2); p3 = realloc(p3, 500); p2 = malloc(600); free(p); free(p2); free(p3); printf("lel\n"); return 0; }
C
/* BL_SLIST functions */ /*////////////////////*/ #include "bl_slist.h" struct bl_slist_t { size_t size; struct bl_slist_elm { void *data; struct bl_slist_elm *next; } *head; }; bl_slist *bl_slist_new(void) { bl_slist *slist = malloc(sizeof(bl_slist)); /* might need to be "sizeof(struct bl_slist_t)" */ s...
C
/* ** free.c for Corewar in /CPE_2015_corewar/src/asm ** ** Made by Antoine Baché ** Login <bache_a@epitech.net> ** ** Started on Thu Feb 25 23:22:18 2016 Antoine Baché ** Last update Fri Mar 4 02:20:59 2016 Antoine Baché */ #include <stdlib.h> #include "asm.h" void free_elems(t_data *data) { int i; t_parsi...
C
#include <stdio.h> /** *main - void function *Return: nothing */ int main(void) { char c = 'a'; char d = 'A'; char s = '\n'; int n = 0; while (n < 26) { putchar(c); c++; n++; } n = 0; while (n < 26) { putchar(d); d++; n++; } putchar(s); return (0); }
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #include <errno.h> #include "infi.h" /** @brief usage error message */ #define USAGE_ERROR "Usage: NumericalAnalyzer <function number> <a> <b> <N> <x0> <h>\n" /** @brief Invalid input message */ #define INVALID_INPUT "Invalid input\n" /*...
C
#include "variadic_functions.h" #include <stdarg.h> #include <stdlib.h> #include <stdio.h> /** * print_stngs - function that prints strings * @separator: pointer holds the string that separates the strings * @n: number of strings * * Return: Always 0. */ void print_strings(const char *separator, const unsigned in...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct { char building_name[100]; int room_number; char room_name[100]; } Handong; int main() { // Create structure type (Handong) variable room1 Handong room1; // Create structure type (Handong) variable room2, room3 // Your c...
C
#include <stdio.h> #include <stdlib.h> #include <getopt.h> #include <limits.h> #include <unistd.h> #include <sys/un.h> #include "seqnum.h" #define PROGRAM_NAME "client" char buffer[BUFFER_SIZE]; void usage(int status) { printf("Usage: %s\n", PROGRAM_NAME); exit(status); } int main(int argc, char *argv[]) { ...
C
#include "library_header.h" error_t searchBooks(const char *FILE_NAME) { error_t found_status = SUCCESS; char bookName[MAX_BOOK_NAME] = {0}; s_BooksInfo Book = {0}; FILE *fp = NULL; int status = 0; fp = fopen(FILE_NAME,"rb"); if(fp == NULL) { printf("\nFile is not opened\n"); ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* sort_three.c :+: :+: :+: ...
C
#include "uart.h" // Initialize UART interface void UART_init(uint32_t baudrate) { // Select pin function RXD (sec 7.4.40) *iocon_register[UART_RXD_PORT][UART_RXD_PIN] &= ~BIT(1); *iocon_register[UART_RXD_PORT][UART_RXD_PIN] |= BIT(0); // Select pin function TXD (sec 7.4.41) *iocon_register[UART_TXD_PORT][U...
C
#include<stdio.h> void main() { int i,j,a[5],*p=a,temp; printf("\nEnter ele of array:"); for(i=0;i<5;i++,p++) scanf("%d",p); p=a; for(i=0;i<5;i++) { for(j=0;j<4;j++) { if(*(p+j)>*(p+j+1)) { temp=*(p+j); *(p+j)=*(p+j+1); *(p+j+...
C
#include<stdio.h> #include<stdlib.h> typedef struct element{ int x; struct element *next; }element; void createElement(int a){ element *p=(element *)malloc(sizeof(element)); p->x=a; p->next=NULL; } int main(){ int *x=(int *)malloc(10*sizeof(int)); return 0; }
C
//teste mudança #include<stdio.h> #include<stdlib.h> int main(){ int x; x = sizeof(int); printf("tamanho int: %i\n",x); x = sizeof(float); printf("tamanho float: %i\n",x); x = sizeof(double); printf("tamanho double: %i\n",x); x = sizeof(char); printf("tamanho char: %i...
C
#include "utils/utils.h" #include <stdbool.h> /* Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0. 0 1 2 +----- 0|1 2 3 1|0 2 3 2|1 2 3 f(1,0) -> (0,0) (1, 0) (2, 0) * (1, 0), (1, 1), (1, 2) 0 1 2 +----- 0|1 2 3 1|1 0 3 2|1 2 3 f(1, 1) -> (0,1) (1, 1) (2...
C
#include "pipe_funcs.h" void safe_pipe(int pipefd[2]) { if(pipe(pipefd) == -1) { perror("pipe create failed"); exit(EXIT_CHILD); } } struct pipe_node* make_pipe(void) { struct pipe_node* p = malloc(sizeof(struct pipe_node)); safe_pipe(p->pipe_io); p->next = NULL; r...
C
/* * charge.c * * Created on: 2020617 * Author: loyer */ #include "charge.h" void Init_BAT_Charge(void) { GPIO_InitTypeDef GPIO_InitStructure; //ṹ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pi...
C
#include<stdio.h> int main(){ int n, k, height[100], max = 0; scanf("%d %d",&n, &k); for(int i=0; i<n; i++){ scanf("%d ", &height[i]); if(height[i]>max){ max = height[i]; } } if(max > k){ printf("%d", max - k); } else if(max < k){ printf("...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ag_lstmapif.c :+: :+: :+: ...
C
#include <stdio.h> int main() { printf("\tCash Register 3.0 SoftWare\t\n"); printf("**************************************************\n"); int quantity; double pr; double total=0.0; while(1) { printf("Give price of product:"); scanf("%lf",&pr); if(pr==0...
C
/************************************************************************* Module: MISC_sig.c Description: Miscellaneous Services replacements for the Standard C signal() and raise() functions. The POSIX signal mechanism is regarded to be superior to the Standard C signal mechanism (see, for example, Ch...
C
//buzzer.c #include "buzzer.h" #define BIT0 0x00000001 #define BIT1 0x00000002 #define BIT2 0x00000004 #define BIT3 0x00000008 #define BIT4 0x00000010 #define BIT5 0x00000020 #define BIT6 0x00000040 #define BIT7 0x00000080 //delay ~ simple void D...
C
#include "QueueInterface.h" #include <string.h> #include <stdio.h> #include <stdlib.h> int main(void) { /* Declaration of variables */ FILE * file; char buffer[100]; char * op; char * name; char * gr; int i; int grade; Item student; Queue myQ; Initialize(&myQ); file = fopen("test.txt","r"); if (file...
C
#ifndef INPUT_H #define INPUT_H unsigned short __key_curr = 0x0; unsigned short __key_prev = 0x0; #define REG_KEYINPUT (* (volatile unsigned short*) 0x4000130) #define KEY_A 0x0001 #define KEY_B 0x0002 #define KEY_SELECT 0x0004 #define KEY_START 0x0008 #define KEY_RIGHT 0x0010 #define KEY_LEFT...
C
/* * Opdracht_B4.c * * Created: 2/12/2020 1:52:19 PM * Author : Chiem */ #define F_CPU 8000000UL #include <avr/io.h> #include <util/delay.h> #define DisplayA 0x01 #define DisplayB 0x02 #define DisplayC 0x04 #define DisplayD 0x08 #define DisplayE 0x10 #define DisplayF 0x20 #define DisplayG 0x40 #define DisplayD...
C
#include <stdio.h> #include <stdlib.h> #include <mpi.h> #include <stddef.h> #include <string.h> typedef struct Book_s { char title[255]; char author[255]; int pages; double price; } Book; const int messagesPerProcessor = 1000; void prepareBook(Book *book); void createMpiDatatypeDefault(MPI_Datatype *mpiBookT...
C
/*---------------------------------------- ** 3. 设N是一个四位数,它的9倍是其反序,求N。 ** 反序数就是将整数的数字倒过来形成的整数。 ** 例如:1234的反序数4321 **---------------------------------------- */ #include <stdio.h> void main() { int i, j, k; for (i = 1000; i < 10000; i++) { j = i/1000 + i/100%10*10 + i/10%10*100 + i%10*1000; if (9 * i == j) { ...
C
#include <stdio.h> // int main(void) // { // // コメントアウト // /* コメントアウト */ // // printf("%d\n", 5 + 3); // // printf("ものつくり\nC言語"); // // getchar(); // // return 0; // int calc; // int result; // calc = 10 * 20; // result = calc / 5; // printf("%d\n", result); // resul...
C
#include <stdio.h> int main() { char a[100]; int i,l,s=0; gets(a); l=strlen(a); for(i=0;i<l;i++) { if((a[i]=='a'||a[i]=='b')) { s++; } } if((s==l)||(s==l-1)) { printf("yes"); } else printf("no"); return 0; }
C
/* * grbl_pause_via_tiny.c * * Version: 1.0 * License: MIT * Copyright: Beau Barker (https://github.com/barkerest/) */ #include <avr/io.h> #include "tiny_ticks.h" #define MASK_PAUSE 0x01 #define MASK_HOLD 0x02 #define MASK_RESUME 0x04 #define MASK_ABORT 0x08 #define PAUSE_TRIGGERED ((...
C
#include <stdio.h> int main(){ int distancia = 0; float tempo = 0.0; scanf("%d", &distancia); tempo = (distancia * 2); printf("%.0f minutos\n", tempo); return 0; }
C
#include <stdint.h> #include "types.h" const char* orca_strerror(ORCAcode code) { switch (code) { case ORCA_OK: return "Success: The request was a success"; case ORCA_HTTP_CODE: return "Failure: The request was a failure"; case ORCA_UNUSUAL_HTTP_CODE: return "Failure: The request was a failure"; ...
C
// Dwarven Newbie Area: Created By Mist Fall 1994 // Addition to the Dwarven Newbie Area: Mist Spring 1997 #include "path.h" inherit ROOM+"baseroom2.c"; object caverat; void setup () { my_setup(); set_short("Realm of the Dwarf: Tunneled out Cavern"); set_zone("CAVE"); set_light(40); set_long("\n Realm ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #define BIND_PORT 4444 int main() { //Defintion of the structers and variables int server_socket; int client_socket; char *arg[]={"/bin/sh",0}; struc...
C
#include <stdio.h> int main() { int x; float y,z; x = 10/3; y = x/3; z = x+y; printf("y= %f, z=%f\n",y,z ); return 0; }
C
#include <stdio.h> #include <stdlib.h> #define MAX 100000 int sorted[MAX]; void merge(int list[], int left, int mid, int right); void merge_sort(int list[], int left, int right); int main (void) { int i,j,n; int max_weight = 0; int count = 0; int max_carriers = 0; int bag[MAX]; scanf("%d", &max_weight); i =...
C
#include <stdio.h> #include <stdint.h> #include <math.h> #include <stdlib.h> #include <assert.h> #include <string.h> /* n! means n × (n − 1) × ... × 3 × 2 × 1 For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. Find the sum of the di...
C
#include<stdio.h> #include<string.h> struct index { int srno; char region[30]; char ip[30]; int load; float lat; float lon; }; int main() { int i; struct index arr_index[7]; arr_index[0].srno = 1; strcpy(arr_index[0].region, "Malaysia" ); strcpy(arr_index[0].ip, "202.18...
C
#include <ctype.h> #include <stdio.h> #include <string.h> /* * Exercise 20 * Page: 126 * Expand dcl to handle declarations with function argument types , qualifiers * like const, and so on * */ /* * Basically, this exercise is implementing the grammer described in Appendix * A.8 (declarations) more or less * */...
C
#include <stdio.h> #include <math.h> #define N 100 int n; long double x[N]; long double y[N]; long double c0, c1; void scanVector(long double *v) { for (int i=0;i<n;i++) { scanf("%Lf", v+i); } } void getLine() { long double sumX = 0; long double sumY = 0; long double sumX2 = 0; long d...
C
#pragma region Một số lưu ý (PHẢI ĐỌC) //Bài này tui code theo cách nhập điều kiện từ bàn phím (VD mng muốn tìm lớp CTK44 thì phải nhập CTK44 vô). //Tui biết thầy yêu cầu phải thực hiện trực tiếp (không nhập điều kiện từ bàn phím) nhưng đây là 1 bài tập để ôn //và tui cần phải kiểm tra xem hàm có chạy đúng với mọi trư...
C
source: http://www.securityfocus.com/bid/511/info WinGate stores encrypted passwords in the registry, in a subkey where Everyone has Read access by default. The encryption scheme is weak, and therefore anyone can get and decrypt them. #include "stdafx.h" #include <stdio.h> #include <string.h> main(int argc, char *ar...
C
// // LCBXXZDChapterThreeAlgorithmDesignEleven.c // DataStructurePractice // // Created by ly on 2018/5/28. // Copyright © 2018年 LY. All rights reserved. // #include "LCBXXZDChapterThreeAlgorithmDesignEleven.h" #define MaxSize 10 typedef struct { int data[MaxSize]; int frontHead ; int frontTail ; }DS...
C
#ifdef COMMENT Proprietary Rand Corporation, 1981. Further distribution of this software subject to the terms of the Rand license agreement. #endif #include "../h/stat.h" #include "../h/dirent.h" struct dirinfo { struct dirent dir; char null; int dotino; int dotdotino; }; char *rootlist[] { "/", "/rnd/", ...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <setjmp.h> #include <signal.h> static void ssu_signal_handler1(int signo); static void ssu_signal_handler2(int signo); sigjmp_buf jmp_buf1; sigjmp_buf jmp_buf2; int main(void){ struct sigaction act_sig1; struct sigaction act_sig2; int i, ret; p...
C
/************************************************************************************************************************************************************ Title : Read int using char datatype Author : T VINODH KUMAR Date : 12/11/2017 description : Read the character from the user using getchar and put in one var...
C
#include <stdio.h> int main() { // printf("%tipo_de_saida", valor_a_ser_impresso); // printf("%tipo1 %tipo2", var1, var2); //int num = 11; //printf("%i\n", num); //float f = 2.2; //printf("%f\n", f); //integer %i ou %d //float ou double %f //char %c ...
C
#include<stdio.h> int main() { float sum,term; int x,n; printf("enter value of x\n"); scanf("%d",&x); sum=1; term=1;n=1; while(n<=100) { term=term*x/n; sum=sum+term; n++; } printf("sum= %f",sum); return 0; }
C
//Librerias usb y main #include <stdio.h> #include <stdlib.h> #include <string.h> #include <libudev.h> #include <mntent.h> /*mtab*/ #include "funciones_usb.h" /*ESTRUCTURAS*/ //Estructura que representa a un dispositivo //Tiene el mismo formato de retorno que el diccionario //En la funbcion listar_dispositivos typede...
C
#include "timerone.h" void timerQuarterCallback(Timer_Handle timerHandle) { //dbgOutputLoc(MAIN_TASK_DLOC_ENTER_TIMERONE_ISR); //dbgOutputLoc(MAIN_TASK_DLOC_BEFORE_COMM_WITH_QUEUE_IN_TIMERONE_ISR); uint32_t timerCount = Timer_getCount(timerHandle); sendTimeMsgToQ1(timerCount); //dbgOutputLoc(MAIN_...
C
// // lex.c // hash // // Created by bikang on 16/9/23. // Copyright (c) 2016年 bikang. All rights reserved. // #include <ctype.h> #include <stdlib.h> #include <string.h> #include "lex.h" #include "cntbl.h" //#include "symbol.h" typedef struct Symbol_{ char* lexeme; Token token; }Symbol; const char* next_...
C
/* Copyright 2013-present Barefoot Networks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
C
//dp ٽ Ģ ߰ϰ ȭ #include <stdio.h> int d[1001]; int dp(int x) { if (x == 1) return 1; if (x == 2) return 2; if (d[x] != 0) return d[x]; return d[x] = (dp(x - 1) + dp(x - 2)) % 10007; } int main(void) { int x; scanf("%d", &x); printf("%d", dp(x)); }
C
#include<stdio.h> #include<stdlib.h> struct fcfs{ char process; int arr_time,ser_time,start_time,finish_time; }; void sort(struct fcfs *a,int x); int main() { int n; printf("How many processes?\n"); scanf("%d",&n); struct fcfs p[n]; int i; for(i=0;i<n;i++) { fflush(stdin)...
C
/* * network/network.c: implementation of the MNP process. * ROSS GUJU * * CS60, March 2018. */ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <string.h> #include <arpa/inet.h> #include <signal.h> #include <netdb.h> #include <assert.h> #inc...
C
// CS1010E Programming Methodology // Problem Set 4 Exercise #11: perimeter.c // // This program reads the lengths of two sides // of a rectangle, and computes the minimum // perimeter after folding the rectangle // once along the x-axis or y-axis. // // Lau Yan Han #include <stdio.h> typedef struct { double side1, ...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> int main(void) { srand(time(NULL)); int a; for (a = 0; a < 50; ++a) { int x; x = rand() % 10; printf("%d ", x); } printf("\n"); return 0; }
C
#include <stdio.h> #include <stdlib.h> #include "string.h" int main() { char cadena[] = "Hola Mundo"; char cadena2[] = "Adios Mundo"; char cadena3[20] = ""; printf("%d", strlen(cadena)); printf("%d", strcmp(cadena, cadena2)); strcpy(cadena, cadena3); printf("%s", cadena3); printf("%d", ...
C
#include <stdio.h> #include <string.h> #include "task.h" #include "task_sched.h" #include "cid.h" //when malloc size > 128KB, malloc will call mmap, //and only if the space is read/writed, the physical memory will be mapped. //by default, use 1MB stack size #define RUN_STACK_SIZE (1<<18) #define TASK_RUN(t) (t->contex...
C
/* MIT License Copyright (c) 2019 Marcin Borowicz Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish...
C
#include <stdlib.h> #include "task_queue.h" task_queue_t *create_task_queue(mempool_t *pool) { //task_queue_t *queue = pmalloc(pool,sizeof(task_queue_t)); task_queue_t *queue = malloc(sizeof(task_queue_t)); if (queue == NULL) { return NULL; } queue->pool = pool; pthread_mutex_init(&queue->mutex, ...
C
//Author: Saurabh Patil //e-mail: er.saurabhpatilgmail.com //Program to specify whether entered number is even or odd #include<stdio.h> int main() { int number; printf("\nEnter a number: "); scanf("%d",&number); if(number % 2 ==0) printf("\n%d is an even number",number); else printf("\n%d is an odd number",num...
C
// Program to reverse the digits of a number #include <stdio.h> int main(void) { int number, right_digit, tempNumber; printf("Enter your number.\n"); scanf("%i", &number); if (number < 0) tempNumber = -number; do { right_digit = tempNumber% 10; print...
C
/*Program to print pattern 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 */ #include<stdio.h> int main() { int i, j, n; printf("\nEnter line count: "); scanf("%d", &n); for(i=1; i<=n; i++) { for(j=1; j<=i; j++) { printf("%d ", i); } printf("\n"); } }
C
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> int debug=0; int gcd(int a,int b){ if(a%b==0)return b; return gcd(b,a%b); } int main(int argc , char **argv) { if(argc>1 && strcmp(argv[1],"DEBUG")==0) debug=1; int n,i,m,count=1;scanf("%d",&n);n=n*2; float limit=sqrt(n); for(i=2;i<limit;++i...
C
#include <stdio.h> #include <stddef.h> #define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) //TODO: iterator whole list by list_head #define ITER_LIST(list, item) \ for ( ...
C
#ifndef _LINALGLIB_H_ #define _LINALGLIB_H_ typedef struct { float x; float y; float z; float w; } vec4; /* * matrix where each column is a vec4 (column-major) */ typedef struct { vec4 x; vec4 y; vec4 z; vec4 w; } mat4; void print_v4(vec4 v); vec4 scale_v4(float s, vec4 v); vec4 add_v4(vec4 v1, vec4 v2);...
C
#include <ctype.h> /* isdigit(c), isspace(c) */ /* atof: convert string s to double */ double atof(char s[]) { double val, power; int i, sign; return sign * val / power; }
C
#include <shell/cmd_read.h> #include <stdlib.h> #include <string.h> #include "hal.h" #include "chprintf.h" #include "shellcommands.h" void cmd_read(BaseSequentialStream *chp, int argc, char *argv[]) { (void) argv; (void) argc; uint32_t channel; if (argc == 2) { if (strcmp(argv[0], "voltage") == 0) ...
C
#include <stdio.h> void show_array(int A[], int len); void inserstion_sort(int A[], int array_len); void blank_line(void); int main(void){ int Array[] = {23,7,2,8,43,6,78,2,7890,7,235346,23}; show_array(Array, sizeof(Array)/sizeof(int)); inserstion_sort(Array, sizeof(Array)/sizeof(int)); show_array(Ar...
C
#include <time.h> #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <fcntl.h> #define CSONEV "FIFO" /* 6. Irjon C nyelvu programokat, ami letrehoz egy nevesitett csovezeteket (bejegyzes az fs-en) megnyitja olvasni probal belole kozben egy masik program ir bele egy random szamot ...
C
#ifndef Graph_List_h #define Graph_List_h /*Gruppo 25 - Progetto 2 - Giuliano Galloppi N86001508; Piero Junior Gaetani N86002210; Luigi Audino N86001513*/ struct TList { int target; //citt del nodo int price; //peso1 int km; //peso2 struct TList* next; //prossimo vertice nella di adiacenza del vertice...
C
#include <stdio.h> int main() { // 输出整数 int number; // printf() 输出字符串 printf("输出一个整数:"); // scanf() 格式化输入 scanf("%d", &number); // printf() 显示格式化输入 printf("你输入的整数是:%d", number); return 0; }
C
#include <netinet/in.h> #include <sys/socket.h> #include <netdb.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include "messages.h" #include "headerinfo.h" /* oppretter klient og kobler til server. INPUT: brukerinput */ void createclient(char* machinename, char* portnb, char* in){ int port = ...
C
/*********************************************************************** * Program: * Lab C_lab, ECEN 324 Learning C Lab * Brother Jones, ECEN 324 * Author: * Donovan Gregory * Summary: * Converting a premade c++ program into c. ************************************************************************/ #in...
C
#include <stdlib.h> #include <time.h> #include "random.h" // randInt returns a random integer between 0 and the given parameter int randInt(int upper) { srand(time(0)); return rand() % upper; } // randString returns a random string of the given length char* randString(int length) { char* result = (char*) malloc...
C
#include "test.h" #include <stdio.h> #include <stdlib.h> #include "manipCompte.h" #include "gereClients.h" #include "manipCompte.h" void testManipCompte() { printf("**************************\n"); printf("* DEBUT TEST manipCompte *\n"); printf("**************************\n\n"); CPTEBQUE ...
C
/* * @file z_test.c * @author DLSZ * @date 2018-05-15 */ #include "include.h" #include "common.h" ///////////////////////////////// //////////////////////////////////// #define SECTOR_NUM (FLASH_SECTOR_NUM-1) //FLASHȷȫ ///////////////////////////////// ////////////////////////...
C
/* ----------------------------------------------------------------------- PRA1: Pipes Codi font: controlador.c Joel Aumedes Serrano ---------------------------------------------------------------------- */ #include "all.h" int N; int PROCESSES; int main(int argc, char *argv[]) { PROCESSES = atoi(argv[1]); c...
C
// // main.c // 加减乘除 // // Created by student on 15-10-19. // Copyright (c) 2015年 student. All rights reserved. // #include <stdio.h> double math(double a, double b, char sign) { switch (sign) { case '+':return a+b; case '-':return a-b; case '*':return a*b; case '/': ...