language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdlib.h> #include <stdio.h> struct ListNode { int val; struct ListNode *next; }; struct ListNode* swapPairs(struct ListNode* head) { struct ListNode *p, *pre, dummy; pre = &dummy; pre->next = p = head; while(p) { struct ListNode *p1, *p2; p1 = p->next; if(p1 ...
C
#include "vendor/unity.h" #include "../src/stack.h" #include <stdlib.h> #include <string.h> #define STACK_CAPACITY 1024 void setUp(void) {} void tearDown(void) {} static void test_push_stack(void) { Stack *stack = new_stack(STACK_CAPACITY, sizeof(int)); TEST_ASSERT_NOT_NULL(stack); for (int i = 0; i ...
C
#include<stdio.h> int main() { int n,f,f1=0,f2=1,i; printf("\n enter the n value"); scanf("%d",&n); printf("%d%d",f1,f2); for(i=2;i<n;i++) { f=f1+f2; f1=f2; f2=f; printf("%d",f); } }
C
#include <stdint.h> #include <stdio.h> #include <string.h> #include <stm8s.h> #include <uart.h> #include <delay.h> // brief: // Mode: 8-N-1, flow-control: none. // uart 115200 baud on following pins: // * PD5 -> TX // * PD6 -> RX // use console: // $ picocom -b 115200 --imap lfcrlf /dev/ttyUSB0 // to exit: CTRL + A...
C
#include "linkedlist.h" typedef struct NodeTag { nodeData data; Node* next; }Node; Node* MakeNode(nodeData data) { Node* new_node=(Node*)malloc(sizeof(Node)); if(new_node != NULL) { new_node->data=data; new_node->next=NULL; } return new_node; } void push_back(Node** head,Node** tail,N...
C
/******************************************************************************************* * * raylib - sample game: snake * * Sample game developed by Ian Eito, Albert Martos and Ramon Santamaria * * This game has been created using raylib v1.3 (www.raylib.com) * raylib is licensed under an unmodified zlib/l...
C
#include<stdio.h> int main() { int n,m; long int sum1,sum2,t,temp; long long int sum; while(scanf("%d %d",&n,&m)==2) { if (n>m) { temp=n; n=m; m=temp; } t=n-1; sum1=(m*(m+1))/2; sum2=(t*(t+1))/2; sum=sum1-sum...
C
#ifndef _MY_SPI_H #define _MY_SPI_H #include "main.h" /* SPIݸʽ 0 Head̶ 0x86 1 DevId 2 CmdType 3 CmdLen 4~֮CmdData 4DataTypeЧ/ack/ǷҪǰ֡ 5Ƶ 6~֮跢͵2.4G */ #define SPI_LINK_OFFSET_HEAD (0) #define SPI_LINK_OFFSET_DEV_ID (1) #define SPI_LINK_OFFSET_CMD_TYPE (2) #define SPI_LINK_OFFSET_CMD_LEN (3)...
C
int main() { int n, i, j, k, l; scanf("%d", &n); if(n==1) { printf("End"); return 0; } do { if(n%2!=0) { k=n*3+1; printf("%d*3+1=%d\n", n, k); n=k; } if(n%2==0) { j=n/2; printf("%d/2=%d\n", n, j); n=j; } }while(n>1); printf("End"); return 0; }
C
#include "cidade.h" //https://programacaodescomplicada.wordpress.com/2012/11/09/aula-64-alocacao-dinamica-pt-6-alocacao-de-matrizes/ //Adaptado int** alocarMatriz(int Linhas, int Colunas) { //Recebe a quantidade de Linhas e Colunas como Parâmetro int i, j; //Variáveis Auxiliares int **m = (char**) malloc(Lin...
C
#include <getopt.h> #include <stdio.h> #include <libapp.h> #include <errno.h> #include <string.h> extern int archFlag; elf_info g_elf; static int get_machine_type(int machine){ dbgprintf("Machine architecture is:"); switch ( machine ) { case 0x02: strcpy(g_elf.cmachi...
C
#include <stdio.h> ///basic input-output functions #include <time.h> ///time & date related functions #include <string.h> ///string related functions #include <conio.h> ///for using getch() functions #include <windows.h> ///windows console related functions ///a function that returns cur...
C
/** @file UART.c * @see UART.h for description. * @author Adrien RICCIARDI */ #include "UART.h" #ifdef WIN32 // Windows #include <windows.h> // This variable is global in this module in order to avoid passing it as a parameter. static HANDLE COM_Handle; int UARTOpen(char *Device_File_Name) { DCB COM_Paramete...
C
#include<graphics.h> void fillrectangle(int,int,int,int,int); void pattern(int,int,int,int,int,int); void fillrectangle(int x1,int y1,int x2,int y2,int color) { int let; for(let=x1;let<x2;let++) { setcolor(color); rectangle(let,y1,let,y2); } } void pattern(int x1,int y1,int x2,int y2,int pat,int col...
C
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> unsigned long long max(unsigned long long a, unsigned long long b) { if (a > b) return a; return b; } int main() { unsigned long long N, a[1000000], i, j, count[1000000], length = 0; scanf("%llu", &N); if(N==0) { ...
C
/* * Led.c * * Created on: Mar 7, 2021 * Author: */ #include "Led.h" #include "derivative.h" static void timerHandler(); void Led_init(){ SIM_SCGC5=SIM_SCGC5|((1<<10)+(1<<11)); //ͨ߼1ʹPORTCʱ PORTB_PCR16=0x0100; PORTB_PCR17=0x0100; PORTB_PCR18=0x0100; PORTB_PCR19=0x0100; PORTC_PCR0=0...
C
/* Mandy La, mla1 * CS152, Spring 2019 * Project 1 */ #include <stdlib.h> #include <stdio.h> #include "board.h" board* board_new(unsigned int side, enum type type){ if (side==0 || (side%2 != 0)) { fprintf(stderr, "error board_new: odd or 0 side length\n"); exit(1); } unsigned int n=0, m; board* new...
C
#include<stdio.h> int main (void){ int n, a, b, c; int i = 1; scanf("%d", &n); a = n / 100; b = (n - 100 * a) / 10; c = n % 10; while(a > 0){ printf("B"); a--; } while(b > 0){ printf("S"); b--; } while(i <= c){ printf("%d", i); i++; } return 0; }
C
/* atexit( void (*)( void ) ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdlib.h> #ifndef REGTEST #include "_PDCLIB_io.h" /* TODO: 32 is guaranteed. This should be dynamic but ATM gives problems with my mallo...
C
// // Yating Zhou(aka syscl)'s lib // #ifndef __SYSCL_LIB_H__ #define __SYSCL_LIB_H__ #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> // // define kDEBUG, 1 = turn on // , 0 = turn off(default) * // #define kDEBUG true // // common constant place here // #define kTRUE...
C
#include "sim.h" // C library headers #include <stdio.h> #include <stdint.h> #include <string.h> #include <stdbool.h> // Linux headers #include <fcntl.h> // Contains file controls like O_RDWR #include <errno.h> // Error integer and strerror() function #include <termios.h> // Contains POSIX terminal control definition...
C
/********************************************************************************************************* * * File : hexstring.c * Version : V1.0 * By : alireza roozitalab * email : alireza.roozitalab@gmail.com * git user : ARoozitalab * ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <pwd.h> #include "common.h" char *add_user(json_value *param, int *success) { char *username = NULL; if (param->type != json_object) return "Invalid parameters"; if (!strcmp(param->u.object.values[0].name, "user")) { printf("Creating new use...
C
#include <GL/glut.h> #include <math.h> #include <string.h> #include <stdio.h> #include <unistd.h> #include <errno.h> #include <arpa/inet.h> #include <netinet/in.h> #include <sys/socket.h> #include <stdlib.h> #include <pthread.h> #include <time.h> #include "messages.h" // populates image packet ImagePacket* set_imag...
C
/*Q8. Passing 1D, 2D arrays to a function – sum, min, max of array elements – Matrix operations */ #include<stdio.h> #define r 2 #define c 3 void sum(int (*)[r][c]); void min(int (*)[r][c]); void max(int (*)[r][c]); int main(){ int arr[r][c]={{8,7,6},{5,4,1}}; sum(&arr); min(&arr); max(&arr); } void sum(int...
C
#include <stdio.h> #include "Stack.h" status createStack(stack_t ** stack , stackSize_t size){ status currentStatus = E_OK; if(stack==NULL){ currentStatus = E_NOT_OK; }else{ /*create stack from the type stack_t to carry the pointers of the stack*/ stack_t* newStack = (stack_t*)mal...
C
#include "open.h" #include "scan.h" int main(int argc, char* argv[]) { char * openData = argv[1]; char * openTemplate = argv[2]; char * outputFile = argv[3]; // FILE * openData; // FILE * openTemplate; // FILE * outputFile; // char line[255]; char value[255]; char key[255]; ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* string.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> float sqrt_min(float x) { // Approximate the square root of x float guess = 1.0; int iter = 10; while (iter) { float quot = x / guess; guess = 0.5 * (guess + quot); iter = iter - 1; } printf("%f\n", guess); printf("%f\n", guess ...
C
#include<stdio.h> int main() { int a=15,b=37; printf("%dȥ%dĽ%d\n",a,b,a-b); return 0; }
C
#include "logger.h" #include <SDL_plus.h> #include <stdarg.h> void LogVerbosely(void) { SDL_LogSetAllPriority(SDL_LOG_PRIORITY_VERBOSE); } static void logv(SDL_LogPriority priority, const char * fmt, va_list ap) { SDL_LogMessageV(SDL_LOG_CATEGORY_CUSTOM, priority, fmt, ap); } void Log(const char * fmt, ...
C
#include<stdio.h> int main() { int n,i; printf("How many todos would you like to add?\n"); scanf("%d", &n); char todo[n][20]; for(i = 1; i<=n; i++) { printf("Enter a todo: "); scanf("%s",&todo[i]); } for ( i = 1; i <=n; i++) { printf("%s\n", todo[i]); } ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdint.h> #include "opcode.h" struct opcode_desc *lookup_1byte_opcode_map(uint8_t index) { return &one_byte_opcode_map[index]; } struct opcode_desc *lookup_2byte_opcode_map1(uint8_t index) { } struct opcode_desc *lookup_2byte_opcode_map2(uint8_t...
C
#include "parser.h" /* Variveis utilizadas: 'e' representa o valor a ser utilizado no critrio de paragem. 'f' um apontador para a funo que calcula o valor da expresso. 'f_d' um apontador para a funo derivada de 'f'. 'i' acumula o nmero de iteraes. */ #include <math.h> #define PI M_PI double ...
C
#include <stdio.h> #include <stdlib.h> /* Ej-iterativas: 2. Escriu un programa que demana a l'usuari un valor i quantes vegades ho vol sumar i mostri el resultat de totes les sumes fins a arribar a les vegades demanades. */ int main () { //Iniciar variable. int num, sum, res, i; //Ttulo. print...
C
#include <stdio.h> #include <stdlib.h> #define LIMIT 1001000 long find_smallest_nsubtract(void); double find_largest(void); long match_time[LIMIT]; long L, R, num_of_matches, smallest_present; int main() { long i=0, Q; double largest; scanf("%ld",&num_of_matches); while(num_of_matches--) sc...
C
#include<stdio.h> #include<stdlib.h> typedef struct employee_s{ char name[20]; float basicSalary; int hra; struct employee_s *pNext; }employee_t; employee_t* addEmpdata(void); vioid printEmpList(void); employee_t *pHead = NULL; main() { employee_t *emp1, *emp2,*emp3; emp1 = addEmpdata(); em...
C
#include<stdio.h> #include<unistd.h> #include<sys/types.h> int main() { printf("\t\t\t\t\t*****************************************************\n"); printf("\t\t\t\t\t****\t\tWELCOME TO MY PROGRAM\t\t ****\n"); printf("\t\t\t\t\t*****************************************************\n"); int choice; printf("\n->E...
C
#include <stdio.h> int main() { int h1, m1, h2, m2; int min0, minf,mint; while(scanf("%d %d %d %d", &h1, &m1, &h2, &m2) && (h1 || m1 || h2 || m2)) { min0 = h1*60 + m1; minf = h2*60 + m2; mint = (min0>=minf) ? ((1440 - min0) + minf) : (minf -min0); printf("%d\n",mint); } }
C
#include <stdio.h> #include <stdlib.h> #include "fileops.h" int GetFileLen(const char* szFilename); int LoadFile(const char* szFilename, char** ppBuffer) { int iBytesRead = 0; int iFileLen = GetFileLen(szFilename); if ( 0 < iFileLen ) { *ppBuffer = (char*) malloc(iFileLen); if ( NULL != *ppBuffer ) { FI...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> void swap(char s[],int i,int j) { char tmp=s[i]; s[i]=s[i]; s[j]=tmp; } int foo(char*s,int n) { int i,j,len=strlen(s); n=n%len; for (i = 0,j = len-n; i<j; i++) swap(s,i,--j); for (i = len-n, j = len; i<j; i++) swap(s,...
C
/* File : hw2_p2.c Description : APES Homework 2, Problem 2. This is program demonstrates the use of basic file operations. Author : Jeff Schornick (jesc5667@colorado.edu) Version : Version and history information is available at the GitHub repository: https://gi...
C
/** * Task: Assignment name : ft_split Expected files : ft_split.c Allowed functions: malloc -------------------------------------------------------------------------------- Write a function that takes a string, splits it into words, and returns them as a NULL-terminated array of strings. A "word" is defi...
C
#include "../includes/pushswap.h" void ft_strat_zero(t_a *a) { int i; i = -1; if (a->use_rr) { if (a->strat_tab[a->strat] > 2) { i++; ft_rr(a); } else ft_ra(a); a->use_rr = 0; } while (++i < a->strat_tab[a->strat] - 2) ft_rb(a); ft_pa(a); a->use_rr = 1; } void ft_strat_one(t_a *a) { int...
C
// // Created by Salman S on 2018-11-26. // #include "stdio.h" #include "stdlib.h" #include "string.h" #include "datatype.h" //duplicate the string char *string_dup(char *str){ char *string=strdup(str); return string; } //generate a new key type Key key_gen(char *skey, char *skey2){ ...
C
#include <stdio.h> #include <stdlib.h> #include <errno.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <string.h> #include <sys/mman.h> #include <unistd.h> #include "dmalloc.h" #define DMALLOC_DEVICE "/dev/dmalloc" #define DMALLOC_FREE 1 #define DMALLOC_GETPHYS 2 #d...
C
#include <stdio.h> #include <cs50.h> #include <ctype.h> #include <string.h> #include <stdlib.h> int main (int argc, string argv[]) { if (argc==2) { string z; int k=atoi(argv[1]); z=get_string("plaintext: "); printf("cyphertext: "); for(int i=0;i<strlen(z);i++) if(isalpha(z[i])) { ...
C
#include <stdio.h> void swap(int a, int b); void swap_add(int * a, int * b); void changeArray(int* ptr); int main_pointer2(void) { //迭 Ϳ ִ. int arr[3] = { 5,10,15 }; int* ptr = arr; // ptr ͺ for (int i = 0; i < 3; i++) { printf("迭 arr[%d] : %d\n", i, arr[i]); } for (int i = 0; i < 3; i++) { printf(" ptr[%...
C
#ifndef HEADER_H_INCLUDED #define HEADER_H_INCLUDED #include <stdio.h> #include <stdlib.h> #define boolean unsigned char #define Nil NULL #define true 1 #define false 0 ///elemen Queue typedef int infotype; typedef struct ElmtQueue *address; typedef struct ElmtQueue{ infotype INFO; address NEXT; }ElmtQueue; ...
C
// pe12-2a.c #include "pe12-2a.h" static int smode; static double distance; static double fuel; void set_mode (int mode) { if (mode == 0) smode = 0; else if (mode == 1) smode = 1; else { smode = mode % 2; printf ("Invalid mode specified. Mode %d (%s) used.\n", smode, smode == 0 ? "metric" : "US"); } } ...
C
#include<stdio.h> int a[100]={10, 30, 70, 16, 95, 22}; void Insert() { int x,m,n=6,i; printf("Enter the value of x & m: "); scanf("%d %d",&x,&m); if( 0<=m && m<= n-1){ for(i=n-1 ;m<=i;i--){ a[i+1]=a[i]; } a[m]=x; n+=1; } else { printf("So...
C
#include<stdio.h> int S, E, val, mid, i; int maximo(int a[10010], int b, int ideal, int target) // funcao que procura o maior valor possivel para o tamanho do pao { S=1; E=ideal; while(S<E) { val=0; mid = (S+E+1)/2; for(i=0;i<b;i++){ val+=a[i]/mid; } i...
C
/* ** bienvuenue.c for bienvenue in /home/qu_j/DicoWesh ** ** Made by QU Juliette ** Login <qu_j@etna-alternance.net> ** ** Started on Thu Oct 15 11:00:31 2015 QU Juliette ** Last update Sat Oct 17 15:26:50 2015 QU Juliette */ #include "juliette.h" void bienvenue() { t_mot *dico; char *commande; dico = di...
C
#include <linux/init.h> #include <linux/module.h> #include <linux/cdev.h> #include <linux/fs.h> #include <linux/device.h> #include <linux/slab.h> #include <asm/uaccess.h> //指定的主设备号 #define MAJOR_NUM 250 //自己的字符设备 struct mycdev { int len; unsigned char buffer[50]; struct cdev cdev; }dev_led; MODULE_LICENS...
C
#ifndef EPOCHCONVERTER_h_ #define EPOCHCONVERTER_h_ #include<stdio.h> #include<stdint.h> #include "stm32f4xx.h" typedef uint32_t epochTime; typedef struct TimeElements{ uint8_t Second; uint8_t Minute; uint8_t Hour; uint8_t Wday; // day of week, sunday is day 1 uint8_t Day; uint8_t Month; ...
C
/* ** EPITECH PROJECT, 2020 ** libjzon ** File description: ** JSON object parser */ #include "my/my.h" #include "jzon/jzon.h" #include "jzon/parser.h" #include "priv.h" static char *read_key(const char **str) { char *key = NULL; OPT(jzon_parser_res) res = jzon_parse__ws(*str); res = jzon_parse_string(re...
C
/* * * */ #include <stdlib.h> #include <stdarg.h> #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <string.h> #define streq(s1, s2) (strcmp((s1),(s2)) == 0) #define PATHSIZE 1024 #define MCDIR "/.mx" #define MCDIR_L 9 char root_dir[PATHSIZE]; void usage() { printf("USAGE: Not really u...
C
/* * Copyright (C) 2017 Niko Rosvall <niko@byteptr.com> */ #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <getopt.h> #include "cmd_ui.h" #include "entry.h" #include "db.h" #include "utils.h" #include "pwd-gen.h" #include "crypto.h" static int show_password = 0; static int force = 0; static int...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <signal.h> #include <errno.h> #include <fcntl.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> #include <string.h> #define MAX_NAME_LENGHT 256 #define BUF_SIZE 128 int main(int argc, char **argv) { int lo...
C
#include<stdio.h> #define MAX 100 #define infinity 9999 #define nil -1 #define white 0 #define grey 1 #define black 2 void push(int stack[],int *top,int i); int pop(int stack[], int *top); void enqueue(int q[],int *front,int *rear,int i); int dequeue(int q[],int *front,int *rear); void bfs(int arr[][MAX], int v,int s,...
C
#include<stdio.h> #define sqr(x) ((x)*(x)) #define cube(x) ((x)*(x)*(x)) #define abs(x) ((x) > 0 ? (x) : (-x)) #define min_of(x,y) ((x) > (y) ? (y) : (x)) #define max_of(x,y) ((x) > (y) ? (x) : (y)) #define diff(x,y) ((x) > (y) ? ((x)-(y)) : ((y)-(x))) #define swap(type,x,y) do{ type tmp = x; x = y; y = tmp; }while(0)...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <linux/input.h> void usage ( int argc, char *argv[] ) { printf("Usage:\n\t%s key\n\nvalid keys are:\n" , argv[0]); printf("\tlshift\t- Left Shift key\n"); printf("\trshift\t- Right Shift key\n"); printf("\tlalt\t- Left Alt key\n"); ...
C
#include "monty.h" #define NO_PINT ("L%d: can't pint, stack empty\n") #define NO_POP ("L%d: can't pop, an empty stack\n") #define NO_MALLOC ("Error: malloc failed\n") #define NO_SWAP ("L%d: cant swap, stack too short\n") /** * p_all - print all values on the stack * * @stack: double pointer to the head of a doubly...
C
#include "uart.h" #define BAUD_RATE 115200 void init_UART() { RCC->APB2ENR |= RCC_APB2ENR_USART1EN; /* Set PA9 to USART1_TX */ GPIOA->CRH &=~GPIO_CRH_CNF9_0; GPIOA->CRH |= GPIO_CRH_CNF9_1 | GPIO_CRH_CNF9_0; GPIOA->CRH |= GPIO_CRH_MODE9_1 | GPIO_CRH_MODE9_0; /* Assuming Baud Rate of 230400 by a clock...
C
// ĐẶng Lâm San 20170111 #include <stdio.h> #include <conio.h> int main() { char s; int n; printf("Nhap vao ky tu "); scanf("%c",&s); printf("\n So tuong ung %d",s); printf("\nNhap vao so "); scanf("%d",&n); printf("\n ky tu tuong ung %c",n); printf("\nDANG LAM SAN 2017...
C
// // Created by Stefan Andonov on 11/18/20. // /* * Да се напише програма за „диплење на број во десно“. Диплење во десно е дефинирано на следниов начин: Секоја цифра од левата половина на бројот се додава на соодветната спротивна цифра од десната половина на бројот (и се отстранува од бројот) – првата се додава на...
C
/* Roman calculator: performs addition and subtraction of roman values Author: Vinay vittal Karagod File dependents: main.c, calculator.h, calculator.c,calculator-test.check Date: 08/21/2016 calculator.h: Header file where all the functions are refered */ #ifndef calculator_H #define calculator_H char * calculate(ch...
C
/*三角形判定*/ #include <stdio.h> #include <stdlib.h> #include <math.h> int main() { int temp; int a, b, c; while(scanf("%d %d %d", &a, &b, &c) != EOF) { if(a > b){ temp = b; b = a; a = temp; } if(b > c){ temp = b; b = c; ...
C
/** *************************************************************************************************** * @file equ_Hygrometre.c * @author j.daheron * @version 1.0.0 * @date 21 sept. 2014 * @brief Gestion de l'Hygrometrie. ****************************************************************************************...
C
#include <Library/BaseLib.h> #include <Library/BaseMemoryLib.h> #include <Library/DebugLib.h> #include <Library/PrintLib.h> #include <stdio.h> int vsnprintf(char *str, size_t size, const char *format, va_list ap) { CHAR8 localfmt[100]; UINTN i; UINTN fmtlen = AsciiStrSize(format); // copy fmt to our buffer ...
C
#include <stdio.h> #include <conio.h> #include <stdlib.h> struct node { struct node* next; int val; }; struct queue { struct node* tail; struct node* head; }; void push(int wartosc, struct queue* kolejka) { struct node* el = (struct node*)malloc(sizeof(struct node)); el->val = wartosc; if (kolejka->tail == N...
C
#include<stdio.h> #include<stdlib.h> int main(){ long long int n_cut,s,i; while(scanf("%lld",&n_cut)!=EOF){ if(n_cut<0) break; s=0; for(i=1;i<=n_cut;i++) s+=i; printf("%lld\n",s+1); } return 0; }
C
#include <stdio.h> #include <ctype.h> #include <stdlib.h> int main(void) { char ch; int i, j = 0; char str[50]; char a[20], b[20], op; int fp = 0; while ((ch = getchar()) != EOF) { str[i++] = ch; //입력되는 문자를 str문자열에 저장 if (ch == '\n') { //개행 입력 //입력되는 문자가 숫자이거나 '.'이면 str문자열을 연산자 앞의 수인 a문자열에 저장 for(i ...
C
#include<stdio.h> #include<stdlib.h> int binarySearch(int key, int array[], int n); void selectionSort(int array[], int n); #define ARRAYSIZE 256 int main(int argc, char *argv[]) { int space,i; int j=0; int *arrayOne; int *arrayTwo; int *arrayThree; int a,b,c; if(argc!=2) { fprintf(stderr, "Usage...
C
#include <stdio.h> #include <stdlib.h> #define MAX 10 #define INIFITY 65535 typedef char POINTTYPE; struct graphyic { POINTTYPE points[MAX]; int edges[MAX][MAX]; int pointNum; int edgeNum; }; typedef struct graphyic Graphyic; typedef struct graphyic* pGraphyic; void initGraphyic(pGraphyic pgraphyic) { int i,j;...
C
#include <stdio.h> void main() { int i; enum month { JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, DEC }; for (i = JAN; i <= DEC; i++) printf("\n%d", i); }
C
#include<stdio.h> #include<stdlib.h> #include<stdbool.h> struct node { int data; struct node *next; struct node *prev; }; struct node *start=NULL; void display() { struct node *p,*temp; p=start; do { printf("%d",p->data); p=p->next; }while(p!=start); } void insertatbeg() { int item; struc...
C
/* Sets the ascii codepage * Returns 1 if successful or -1 on error */ int info_handle_set_ascii_codepage( info_handle_t *info_handle, const system_character_t *string, libcerror_error_t **error ) { static char *function = "info_handle_set_ascii_codepage"; size_t string_length = 0; uint32_t featu...
C
/* * fat.c * * R/O (V)FAT 12/16/32 filesystem implementation by Marcus Sundberg * * 2002-07-28 - rjones@nexus-tech.net - ported to ppcboot v1.1.6 * 2003-03-10 - kharris@nexus-tech.net - ported to uboot * * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> #include <config.h> #include <exports.h> #inclu...
C
#include <stdio.h> #define ANSI_COLOR_RED "\x1b[31m" #define ANSI_COLOR_GREEN "\x1b[32m" #define ANSI_COLOR_YELLOW "\x1b[33m" #define ANSI_COLOR_BLUE "\x1b[34m" #define ANSI_COLOR_MAGENTA "\x1b[35m" #define ANSI_COLOR_CYAN "\x1b[36m" #define ANSI_COLOR_RESET "\x1b[0m" int main (int argc, char const *a...
C
/** * \file doubly_linked_list_insert_before.c * * Implementation of doubly_linked_list_insert_before * * \copyright 2019 Velo Payments, Inc. All rights reserved. */ #include <cbmc/model_assert.h> #include <vpr/doubly_linked_list.h> /** * \brief Insert a new element before a specified element in a doubly lin...
C
#include <stdio.h> #include <stdlib.h> #include "linked_list.h" #include "float_linked_list.h" #define TARGET_LIST_SIZE 10 int main(int argc, char** argv) { printf("float_linked_list|start\n"); //ia simple float list ListHead float_list; List_init(&float_list); for (u_int16_t i = 0; i < TARGET_LIST_SIZE; ...
C
#include<stdio.h> typedef long long int ll; int main() { int tes; scanf("%d",&tes); while(tes--) { ll a[10110],n,k,j,i,min; scanf("%Ld %Ld",&n,&k); for(i=0;i<n;i++) { scanf("%Ld",a+i); } ll tmp=0; min=a[0]; for(i=0;i<k;i++) { if(a[i]<min) { min=a[i]; } } if(k==n) { printf("...
C
/* main.c Created : 7/21/2020 12:07:21 PM Author : eisendani */ #include "AT89C51AC3.h" void write_port(unsigned char this){ P4 = this; } void main(void) { /* Replace with your application code */ unsigned char test = 0b11111111; while (1) { write_port(test); } }
C
// struct untuk node struct node{ char data; struct node *next; }; typedef struct node node; // struct untuk front back dan count struct queue{ node *front; node *back; }; typedef struct queue queue; // Alvito Ikramu Walidain <2006577624> // inisialisasi nilai front, back, dan count 0 void initialize...
C
//nome:Layanne Roberta Silva Oliveira //matrícula: 11811ETE012 #include <stdio.h> int main () { int estado=0, i=0; char bits[256]; printf("\nDigite um numero binario: "); scanf("%[^\n]",bits); while (bits[i] != '\0') { if (bits[i]=='0') { if (estado==0) estado=0; else if...
C
/////////////////////////////////////////////////////////////////////////////// // File Name: test.c // // Author: Varun Naik // CS email: vnaik@cs.wisc.edu // // Description: Unit tests for a4. As a reminder, even if you pass all of // these tests, you are not yet guaranteed 90/90...
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> main() { long num[1000], digit[1000], factor[1000], rem[1000], r[1000], count[1000], remainder[1000], bin[1000], pdrem[1000], biny[1000], temp[1000], rev[1000], key[1000]; long range, i, real,b, x, n, t, j, y, base, a , pdrange ; clrscr(); printf("ENTER RANGE:"); scanf(" %ld", &range); real=...
C
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <modbus.h> #include "sensorhandler.h" extern void sensors_poll(void); modbus_t *mb1 = NULL; modbus_t *mb2 = NULL; modbus_t *initModbus_RTU(char *pdevpath, uint32_t sec, uint32_t usec) { modbus_t *mb = NULL; //1-打开端口 ...
C
#include "vm.h" #include <stdlib.h> #include <assert.h> #include <string.h> ArResult arCreateVirtualMachine(ArVirtualMachine* pVirtualMachine, const ArVirtualMachineCreateInfo* pInfo) { assert(pVirtualMachine); assert(pInfo); assert(pInfo->sType == AR_STRUCTURE_TYPE_VIRTUAl_MACHINE_CREATE_INFO); cons...
C
#include <unistd.h> #include <stdint.h> #include <types.h> #include <stdio.h> #include <sys/vmm.h> /* This must be initialized data because commons can't have aliases. */ static void *__curbrk = NULL; /** * brk - 设置断点值 * @addr: 设置的地址 * * 成功返回0,失败返回-1 */ int brk(void *addr) { void *newbrk; /* 保存新的brk值 */ ...
C
#include"stdio.h" #define n 3 void main() { int m[n][n],m1[n][n],sub[n][n],i,j; printf("enter the element in an array:-"); for(i=0;i<n;i++) { for(j=0;j<n;j++) { scanf("%d",&m[i][j]); } } printf("enter the element in second in an array:-"); for(i=0;i<n;i++) { for(j=0;j<n;j++) { scanf("%d",&m1[i][...
C
/* * graph.c * Copyright (C) 2016 DerShokus <lily.coder@gmail.com> * * Distributed under terms of the MIT license. */ #include <string.h> #include "../src/lexer.h" int main(int argc, char *argv[]) { if (argc != 2) return -1; const char *source = argv[1]; const char *end ...
C
#include <stdlib.h> #include <stdbool.h> #include "lib/contracts.h" #include "lib/xalloc.h" #include "queue.h" //implementation typedef struct list_node list; struct list_node { void* data; list* next; }; typedef struct queue_header queue; struct queue_header { list* front; list* back; ...
C
#define _GNU_SOURCE #include <stdio.h> #include <sched.h> // see man CPU_SET int main() { int cpu=0; cpu_set_t mask[1]; // cpu=sched_getaffinity(getpid(),size,cpu_set_t); cpu=sched_getaffinity(0,sizeof(cpu_set_t), mask); // see man CPU_SET fprintf(stderr,"Process/Thread affinity is CPU #%x.\n", *mask); re...
C
#ifndef _SINGLELL_H #define _SINGLELL_H #include <stdio.h> #include <stdlib.h> #include <stdint.h> typedef struct node { uint8_t data; struct node *next; } node_t; uint8_t list_length(node_t*); void print_list(node_t*); void add_first(node_t**, uint8_t); void add_last(node_t**, uint8_t); void add_element(nod...
C
#include <stdio.h> #include <math.h> int main() { int a, b; float c; scanf("%f", &c); a = (int)c; c -= (float)a; printf("%f\n",c); if (c < 0) { for (int i = 1; i < 6; i++) c *= 10; } else { for (int i = 1; i < 7; i++) c *= 10; } if (c >= 0) { c = c + 0.5; c = floor(c); } b = (int)c; wh...
C
/* * numtowords.c * * Copyright (c) 2012 Cihangir Akturk * */ #include <stdio.h> #include <string.h> #include <errno.h> static char *out_buf; static char *out_ptr; static size_t out_buf_size; static int digit_count = 0; static char *numbers[] = { "bir", "iki", "uc", "dort", "bes", "alti", "yedi", "sekiz...
C
//4 - Utilizando a mesma matriz, exiba a soma dos elementos da diagonal principal. #include <stdio.h> #include <time.h> #include <stdlib.h> int main(void){ srand(time(NULL)); int matrizInteiros[20][20]; int somaLinha = 0; int maiorLinha; int posicaoMaiorLinha = 0; int somaDiagonal = 0; fo...