language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
//Katalog gier, projekt 3 //Ireneusz Wróbel, Informatyka, grupa 5 #include <stdlib.h> #include <stdio.h> #include <string.h> #include "struktury.h" #include "gra.h" #include "gatunek.h" #include "sortowanie.h" #include "odczyt_z_pliku.h" #include "zapis_do_pliku.h" struct gatunek *poczatek = NULL; struct gra *pocz= N...
C
#include<stdio.h> int main() { int menu; printf("Enter your menu: "); scanf("%d",&menu); switch(menu) { case 1: { printf("Food item - Pizza\n"); printf("Price - Rs 239\n"); break; } case 2: { printf("Food item - Burger\n"); printf("Price - Rs 129\n");...
C
//5710110137 #include <stdio.h> int main () { float weight, height, bmi; printf("Enter your Weight (kg): "); scanf("%f", &weight); printf("Enter your Height (m) : "); scanf("%f", &height); bmi = weight/(height * height); printf("Your BMI = %f\n\n",bmi); if(bmi < 18.5) printf("Underweight"); else if((bmi>=18....
C
/**Altere a função do exercício anterior para copiar os elementos mas caso existam elementos repetidos na lista de origem, estes serão copiados apenas uma vez. A lista origem está desordenada.*/ #include<stdio.h> #include<Wall.h> int copia(Lista *origem, Lista *chegada); int main(){ Lista lista1, lista2; iniciali...
C
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <string.h> #define SIZE 2048 //Velicina buffera #define MAXBOD 30 //Maksimalan broj bodova na ispitu -> ovisno o datoteci typedef struct { char ime[20]; char prezime[50]; int bod; float prosjek; }student; int BrojRed(const char *I...
C
#include<stdio.h> #include<io.h> #include <stdlib.h> #include <string.h> #include <dirent.h> //Exit0o! int tamVirus=44249; //Tamaño fijo para saber cuando se ejecuta un programa infectado o el virus int printTam(char *str){ //Funcion que te devuelve el tamaño del nombre de archivo q le pases FILE *virus; virus=fop...
C
#include <stdbool.h> #include <stdio.h> #include <math.h> double rad_2_deg(double rad) { return rad * 180.0 / M_PI; } double deg_2_rad(double deg) { return deg * M_PI / 180.0; } double fact(double val) { double first = 1; while(val > 0) first = first * val--; return first; } double taylor_sin(double rad) {...
C
#include "el.h" #ifdef HAVE_EPOLL_H void epoll_init(el_loop *loop) { loop->ioid = epoll_create(EPOLL_FD_SIZE); if (loop->ioid < 0) error("epoll create error!"); } void epoll_add(el_loop *loop, event *ev) { struct epoll_event event; event.data.fd = ev->fd; event.events = ev->flags | EPOLLET; int n = ep...
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"function.h" void calculate_authority(struct Node_t nod[ONE_SIDE],struct group_total_number_t gtn){ int i; for(i=0;i<ONE_SIDE;i++){ nod[i].authority_value=0; if(nod[i].belong_authority==NO) continue; else if(nod[i].authority_group_name==MULTI) nod[i].authority_value=(double)(gtn.mu...
C
#include <stdio.h> #include "msp.h" #include "Motor.h" #include "BumpInt.h" #include "RobotUtil.h" #include "onboardLED.h" #include "LowLevel/T32.h" #include "HighLevel/MotorPID.h" #include "HighLevel/Odometry.h" #include "HighLevel/RobotDriver.h" #include "HighLevel/RobotKinematics.h" #include "Periph...
C
#include<stdio.h> static int count=0; int str_compare(char *str1, char *str2) { if(*str1== '\0' && *str2== '\0') { return count; } if(*str1== *str2) { str1++; str2++; count++; return str_compare(str1,str2); } else { printf("strings are not same\n"); return -1; } } int main() { ...
C
#include <stdio.h> int main() { int n1,n2; scanf("%d %d",&n1,&n2); printf("%.1f %.2f",(float)n1/n2,(float)n1/n2); return 0; }
C
#include "type.h" int write_file(int fd, char buf[], int bytes){ int lbk; int start; OFT *oftp = running->fd[fd]; int offset; char tempBuf[2048]; //tempBuf is what we're writing to MINODE *mip; int blk; char *cp; char *cq = buf; int remain; int i; int *pBlock; int count; int blk; if(fd < 0 || fd > 9){ p...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> #define PAGE_SIZE 256 #define FRAME_SIZE 256 #define THE_NUMBER_OF_FRAME 128 #define THE_NUMBER_OF_TLB 16 // made by Yu Sang Hyeon, VIRTUAL MEMORY MANAGER. // 2017 - 06 typedef enum {false, true} bool; FILE* txtLogicalAddress; FILE* BACKI...
C
// // 进程间通信 - 管道 // pipe() // #include <stdio.h> #include <string.h> #include <unistd.h> int main() { // 使用 pipe 创建一对文件描述符 // 通过这一对文件描述符操作内核中的管道 int fd[2]; int ret = pipe(fd); if (ret < 0) { perror("pipe"); return 1; } // fd[0] -> 读数据 // fd[1] -> 写数据 // char buf[1024] = "hehe"; // writ...
C
#include "lists.h" /** * pop_listint - deletes the head node of a listint_t linked list * * @head: list * * Return: the head nodes data (n) */ int pop_listint(listint_t **head) { int cpnum = 0; listint_t *temp; if (*head) { cpnum = (*head)->n; temp = (*head)->next; free(*head); *head = temp; } return (cp...
C
#include"revise.h" #include<stdio.h> #include<string.h> #include"show.h" int ReStdDat(Student *Dat1,Student *Dat2)//2滻1 { Dat1->Chinese = Dat2->Chinese; Dat1->English =Dat2->English; Dat1->Math =Dat2->Math; Dat1->Sum = Dat2->Sum; Dat1->Rank = Dat2->Rank; return 1; } Student Input() //û { Student...
C
#include <stdio.h> #include <stdlib.h> #define dim 1 typedef struct list_s{ int val; struct list_s *next; }list_t; list_t* push(list_t*, int); list_t* append(list_t*, int); list_t* increasing(list_t*, int); list_t* pop(list_t*); list_t* delete(list_t*, int); list_t* exists(list_t*, int); int lenght(list_t*); ...
C
#include <stdio.h> #include <wiringPi.h> #define SW1 1 // BCM_GPIO 18 #define LED1 4 // BCM_GPIO 23 #define LED2 5 // BCM_GPIO 24 int main (void) { printf("gpio input test~\n"); wiringPiSetup(); pinMode(SW1, INPUT ); pinMode(LED1, OUTPUT); pinMode(LED2, OUTPUT); while(1) { digitalWrite(LED1, 0)...
C
#include<stdio.h> #include "myheader.h" //Both quick sort functions long int partition(int arr[],long int low,long int high){ long int left, right; int pivotitem; int t; pivotitem =arr[low]; left =low; right=high; while(left<right){ while(arr[left...
C
#include<stdio.h> #include<stdlib.h> void main(){ int q[10],n,head,seek=0,diff,i; float avg; printf("Enter the size of the queue: "); scanf("%d",&n); printf("Enter the queue elements: "); for(i=1;i<=n;i++){ scanf("%d",&q[i]); } printf("Enter the head elem...
C
#include <stdio.h> #include <stdlib.h> #define MAX 40 void boy(char tab[MAX],int *canan) { int i; for(i=0;tab[i]!='\0';i++); *canan=i; } void ortak_harf(char tab[MAX],char can[MAX],int *t) { int i,j; int kelime1,kelime2; *t=0; boy(tab,&kelime1); boy(can,&kelime2); for(i=0;i<kelim...
C
#include <stdio.h> #include <unistd.h> #include <sys/mman.h> #include <dirent.h> #include <sys/types.h> #include <sys/stat.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <pwd.h> #include <time.h> #include <grp.h> #include <errno.h> #include <stdlib.h> #include <string.h> #include <pthread.h> #in...
C
/* qsort_list.c Implementation of quick sort algorithm for singly linked lists. */ #include <stdlib.h> #include "sort.h" #include "../data-structures/list.h" /* get_list_tail Returns a pointer to the last node of a linked list given another node. */ Node *get_tail(Node *current) { while (cur...
C
/* * @lc app=leetcode id=367 lang=c * * [367] Valid Perfect Square * * https://leetcode.com/problems/valid-perfect-square/description/ * * algorithms * Easy (40.43%) * Total Accepted: 127.9K * Total Submissions: 316.4K * Testcase Example: '16' * * Given a positive integer num, write a function which re...
C
#include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> void main(int argc, char *argv[]) { close(1); open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 644); printf("Hello, World\n"); }
C
/** * This file provides the interface for opponent control * @file computer.h * @author Ryan Petter * @date 10/26/2018 */ #ifndef OPPONENT_H #define OPPONENT_H #ifdef OPPONENT_C #define EXTERN_PFX #else #define EXTERN_PFX extern #endif /**************************************************************************...
C
#include <stdio.h> #include <stdbool.h> #include <stdlib.h> //required for the memory functions! #include <string.h> typedef struct User { char name[30]; int age; bool isVerified; } User; User *createUser(char name[], int age, bool isVerified) { User *newUser = malloc(sizeof(User)); strcpy(newUser...
C
// // Created by Jason Lyu on 8/24/19. // #include <stdio.h> #include <string.h> #include "student.h" NODE *Append(NODE *head, STUDENT student) { NODE *temp = (NODE *) malloc(sizeof(NODE)); temp->student = student; temp->next = head; head = temp; return head; } int Delete(NODE **head, int id) { ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct sDado{ int id; char nome[30]; }tDado; typedef struct sElemento{ tDado dado; struct sElemento * pProx; }tElemento; tElemento * inicializarLista(){ tElemento * pNovo = (tElemento*) calloc(1, sizeof(tElemento)); pNovo->dado.id ...
C
#include <stdio.h> #include <stdlib.h> // pass by value void swap_value(int a, int b) { int temp; temp = a; a = b; b = temp; } // pass by address (reference) void swap_address(int *a, int *b) { int temp; temp = *a; *a = *b; *b = temp; } // passing arrays as parameters (arrays are alwa...
C
#include <stdio.h> #include <string.h> #include <stdbool.h> #define MAX 100000010 #define clr(ar) memset(ar, 0, sizeof(ar)) #define read() freopen("lol.txt", "r", stdin) int phi[MAX]; short P[MAX] = {0}; void Generate(){ int i, j, k, d, x; P[0] = P[1] = 1; for (i = 4; i < MAX; i++, i++) P[i] = 2; f...
C
// Joe Moceri // 12/22/2011 // Tax Receipts Program #include <stdio.h> #include <string.h> #include <unistd.h> #define RECSIZE 50 // Constants const int TAXSIZE = 1500; const int PATHSIZE = 100; const int NAMESIZE = 50; const int SIZE = 10; // Structure for Receipt struct receipt { char name[RECSIZE]; int ...
C
#include <stdio.h> int main(void) { int n; printf("Enter size of the array: "); scanf("%d", &n); int arr[n] = {0}; for(int i = 0; i < n; i++) { printf("arr[%d] = %d\n", i, arr[i]); } return 0; }
C
#include "libft.h" int ft_pow(int nbr, unsigned int pow) { int res; res = 1; while (pow--) res *= nbr; return (res); }
C
#include <stdio.h> int main(void) { int a[5], i, max, min; for (i = 0; i < 5; i++) { printf("数値を入力して下さい:"); scanf("%d", &a[i]); } min = a[0]; max = a[0]; for(i =0; i < 5; i++){ if(max < a[i]){ max = a[i]; } else if(min > a[i]){ min = a[i];...
C
/** ****************************************************************************** * @file bsp_fric.c/h * @brief control friction motor speed. * @note attention, friction motors needs initialization, which should be * done in shoot task library. * pin: motor1->J26-1 ...
C
#include <linux/init.h> #include <linux/module.h> #include <linux/vmalloc.h> #include <linux/mman.h> void *p = NULL; static int __init vmalloc_to_page_init(void) { struct page *page = NULL; int ret = 0; printk(KERN_INFO "%s\n", __func__); #if 0 void *vmalloc(unsigned long size) #endif p = vmalloc(8192); if (NULL...
C
#include <queue.h> #include "skel.h" #define MAX_FILE_DIM 64265 #define LEN 20 struct arp_entry { __u32 ip; uint8_t mac[6]; }; struct route_table_entry { uint32_t prefix; uint32_t next_hop; uint32_t mask; int interface; } __attribute__((packed)); // citeste tabela de rutare din fisier void read_route_table(ch...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <string.h> #include <signal.h> struct Canaux { int vendeur_to_main[2]; int main_to_vendeur[2]; int cliente_to_main[2]; int main_to_cliente[2]; int caissiere_to_main[2]; int main_to_caissiere[2]; }; stru...
C
/* * Juego.c * Author: Gabriel Servia */ #include "Juego.h" /** * \brief Creates memory space for one Juego * \return pJuego Pointer to an Juego */ Juego* juego_new() { Juego* pJuego = (Juego*) malloc(sizeof(Juego)); return pJuego; } /** * \brief Juego setting parametres * \param nombreJuegoStr * \retur...
C
#include "program_options.h" popt_t * popt_init(char *keyword,char *description,char *value) { popt_t * p = MALLOC_PTR(popt_t); if (!keyword) { fprintf(stderr,"Cannot initialize a option with no keyword\n"); exit(EXIT_FAILURE); } p-> key = strdup(keyword); if (description) { ...
C
//2021-02-02 //calculate the size of file #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { int count = 0; FILE* fp = NULL; if(argc != 2) { fprintf(stderr, "Usage: %s\n", argv[0]); exit(0); } fp = fopen(argv[1], "r"); if(fp == NULL) { fcl...
C
/* * mapentry bitmap management */ #include <rpc/rpc.h> #include <nfs/nfs.h> #include <fcntl.h> #include "nfsd.h" char *freemap; /* pointer to bitmap */ static int mapsize; /* number of longs in map */ /* * flush bitmap cache to disk file. Should be done once every 30 seconds * or so. */ nfsstat flush_bitm...
C
/* ** my_strlen.c for my_strlen.c in /home/hervet_g//afs/rendu/piscine/Jour_04 ** ** Made by geoffrey hervet ** Login <hervet_g@epitech.net> ** ** Started on Thu Oct 7 16:19:09 2010 geoffrey hervet ** Last update Wed Dec 29 12:18:16 2010 geoffrey hervet */ int my_strlen(char *str) { int length; length = 0...
C
1234567..........886 ***************************************************** > File Name: dup.c > Author: > Mail: > Created Time: 2020年03月27日 星期五 20时23分13秒 ************************************************************************/ #include<stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #inclu...
C
/* */ #include <stdio.h> #include <memory.h> #include <stdint.h> #include <stdlib.h> #include <patcher.h> #if defined(__ICC) || defined(__INTEL_COMPILER) #else #ifndef __USE_GNU #define __USE_GNU #endif #endif #include <pthread.h> unsigned long g_foo_val = 0; unsigned long g_bar_val = 0; /* con...
C
/* ** EPITECH PROJECT, 2017 ** mixword ** File description: ** init_mixword.c */ #include <time.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include "macro.h" #include "struct.h" #include "proto.h" static void fill_tab(my_mixword_t *mixword) { srand(time(NULL) * getpid()); for (int i = 0 ; i <...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* hashmap_delete.c :+: :+: :+: ...
C
// // Created by lifan on 2021/5/12. // #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(int argc, char* argv[]) { printf("%d\n", getpid()); printf("%d\n", getppid()); printf("%d\n", getuid()); printf("%d\n", geteuid()); printf("%d\n", getgid()); printf("%d\n", getegid()); ...
C
#include<stdio.h> #include<conio.h> #include<stdlib.h> #include<string.h> #define size 100 char stack[size]; int top= -1; void push(char item) { if(top>=size-1) printf("Overflow!"); else { top++; stack[top]=item; } } char pop() { return(stack[top--]); } int is_operator(char symbol) { i...
C
//note: Saddle point M of a matrix is the smallest element in row 'i' and largest element in column 'j'. #include<stdio.h> int main(void) { int a[10][10], i, j, k, m, n, min, max, col; printf("enter order m, n of mxn matrix\t:"); scanf("%d%d",&m,&n); printf("enter elements row-wise\n"); for(i=0; i<m; i++...
C
/** * animals.c * Author: Garrett Lahmann * * Contains functions that operate on an binary file containing animal records. */ #include <stdio.h> #include <stdlib.h> #include "animals.h" void print_file(FILE *fptr) { char curr; int line = 1; // Length of the current print line printf("\n"); while (fscanf(...
C
/* read_bv.c This file defines a mex-Function to load an eeg-File from a location. data = read_bv(file, HDR, OPT); read_bv(file, HDR, OPT); / with opt.data and opt.dataPos set Arguments: file - Name of EEG file (.eeg) is appended) HDR - Information about the file (read from the *...
C
#include <stdio.h> #include "LP_Leitura.h" #include "LP_Utils.h" #include "estrutura.h" #include "FuncoesGerais.h" void listar_Quantidade(unsigned short quantidade) { printf("Quantidade: %hu\n", quantidade); } void listar_ProdutoEncomenda(PRODUTO_ENCOMENDA produtoEncomenda) { listar_ID(produtoEnc...
C
#include "m_general.h" #include "m_usb.h" #include "m_bus.h" #include "m_wii.h" #include "math.h" #include "m_rf.h" #define MORE 0.99 //Max Duty Cycle #define LESS 0.90 //Min Duty Cycle #define goal_1 -5 //Goal offset +y direction #define goal_2 -40 //Goal offset -y direction #define CHANNEL 2 #define RXADD 0X68 #d...
C
/** File which handles all game operations regarding the game board and game menu **/ #include "board.h" #include "gamelogic.h" #include <conio.h> #include <ctype.h> #include <time.h> /// /// Create a standard Reversi board for testing purposes. /// /// board: A pointer to the game state structure of the game. /// voi...
C
#include "stdint.h" #include "stdio.h" #include "stdarg.h" /*add main.c*/ #define NUMARGS(...) (sizeof(uint32_t[]){__VA_ARGS__})/sizeof(uint32_t) #define SUM(var1, ...) (sum(var1, NUMARGS(__VA_ARGS__), __VA_ARGS__)) void sum(uint32_t var1, uint32_t numargs, ...); int main(void) { uint8_t a; uint32_t b,c; ...
C
/* ======================================================================= * host_xt.h * * Purpose: * Defines the interface for the xt_host subsystem. * * License: * Copyright (c) 2015, Engicoder * All rights reserved. * See LICENSE.txt for license details. * --------------------------------------------...
C
// *************Interpreter.c************** // EE445M/EE380L.6 Lab 4 solution // high level OS functions // // Runs on LM4F120/TM4C123 // Jonathan W. Valvano 3/9/17, valvano@mail.utexas.edu #include "ST7735.h" #include "os.h" #include "UART.h" #include "efile.h" #include "eDisk.h" #include <string.h> #include <stdio....
C
// huffman.cpp : Defines the entry point for the console application. // #include "stdlib.h" #include "stdio.h" #include "string.h" #define MAX_ELEMENT 1000 #define MAX_BIT 10 #define MAX_CHAR 20 #define TRUE 1 #define FALSE 0 // Input data for huffman code typedef struct input_huff { char* data; // Character arr...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "holberton.h" /** * *string_nconcat - Entry point * @s1: string 1 * @s2: string 2 * @n: number * Return: Always 0 (Success) */ char *string_nconcat(char *s1, char *s2, unsigned int n) { unsigned int s1_len, s2_len, cp; char *dest; if (s1 == ...
C
#ifndef MONEY_H #define MONEY_H #include <stdbool.h> typedef struct { } Money; typedef enum { USD, CHF, } Currency; typedef struct Expression{ void* exp; Money* ( *reduce )( struct Expression *exp, Currency to ); } Expression; Money *franc( unsigned int amount ); Money *dollar( unsigned int amount ); Money...
C
#include <stdio.h> #include <stdlib.h> int *merge_sorted(int *arr_one, int len_one, int *arr_two, int len_two, int *reslength) { int a_idx, b_idx; int *result = malloc(sizeof(int) * (len_one + len_two)); int i; if (result == NULL) return NULL; for (a_idx = 0, b_idx = 0, i = 0; ((a_idx < l...
C
/******************************************************************** The bits-io module is used to encode bits into an output file. The bits-io module buffers output/input bits into an internal byte-sized buffer using a special format to know when it is supposed to write or read a full byte to the output or input...
C
#include<unistd.h> #include<stdio.h> #include<stdlib.h> int main(int argc,char*argv[]){ int rt; if(argc!=2){ exit(2); } else{ if((rt=unlink(argv[1]))!=0){ fprintf(stderr,"error"); exit(3); } } return...
C
#include<stdlib.h> #include<string.h> #include <stdio.h> #include "unhuff.h" int main(int argc, char **argv) { char *numchar = malloc(sizeof(char*)); char *extra = malloc(sizeof(char*)); char *filename = malloc(sizeof(char*)); strcpy(filename,argv[1]); FILE *fptr = fopen(filename,"r"); HuffNode *tree = NUL...
C
#include"global.h" #include"utility.h" #include"name_buf.h" /* to protect the name_buf when get_name_zone and put_name_zone is called */ static pthread_mutex_t name_buf_mutex = PTHREAD_MUTEX_INITIALIZER; struct list_head name_buf_list; void init_name_buf(void) { list_head_init(&name_buf_list); } static void add_name_z...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_lowlvl_graphics.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <unistd.h> #define NUMDATOS 64 #define NUMHILOS 4 #define NUMPROC 4 //Funciones int * reservaMemoria(); void llenaArreglo( int *arreglo ); void imprimeArreglo( int *arreglo ); void * productoPorIndice( void * args ); void procesoHijo(int np, int tub...
C
// // main() // // arg_c/arg_v #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(int arg_count,char* arg_values[]) { if(arg_count==0){ printf("only one default parameter\r\n"); printf("->arg_values[0]=%s\r\n",arg_values[0]); }else{ int i=0; for(;i<arg_count;i++){ printf("%d parameters:\...
C
#include <stdio.h> #include "Utilities.h" #include <stdarg.h> void fV_print(s8 *pvS8Fp_format, ...) { va_list vSt_ap; s8 *pvS8_p, *pvS8_sval; s32 vS32_ival; double dval; va_start(vSt_ap, pvS8Fp_format); for (pvS8_p = pvS8Fp_format; *pvS8_p; pvS8_p++) { if (*pvS8_p != '%') { putchar(*pvS8_p...
C
#include <stdio.h> static int count = 0; void path(int mat[21][21], int N, int i, int j) { if (i == N && j == N) { count++; return; } /*for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { printf("[%d] ", mat[i][j]); } printf("\n"); }*/ if (i == N) { path(mat, N, i, j+1); } else if (j ==...
C
#include<stdio.h> #include<conio.h> void main() { int n,a[1000],i,j,temp; clrscr(); printf("Enter number of elements\n"); scanf("%d",&n); printf("Enter %d integers\n",n); for (i=0;i<n;i++) { scanf("%d",&a[i]); } for (i=1;i<=n-1;i++) { j=i; while(j>=1 && a[j]<a[j-1]) { if(a[j]<a[j-1]) { te...
C
int negative(volatile int *in, volatile int *out, int size) int main(){ int data[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; int result[10]; int i; negative(data, result, 10); for(i = 0; i < 10; i++){ printf("data[%d] = %d, result[%d] = %d\n", i, data[i], i, result[i]); } }
C
/*********************************************************************************************** * Library for DS1307 Real Time Clock module * ds1307.c * 2019, Tibor Rojko * * pinout: * AtMega328 <--> DS1307 * PC5(SCL) SCL * PC4(SDA) SDA *************...
C
#include<stdio.h> #include<string.h> void main() { FILE *fpa, *fpb; char c,b,name[20],outf[20]; int s=0; printf("enter the file name to be opened: \n"); scanf("%s",name); printf("enter the file name to be copied: \n"); scanf("%s",outf); fpa=fopen(name,"r"); fpb=fopen(outf, "w"); if(fpa==NULL) { printf(...
C
#include <stdio.h> inline void scanint(int* x) { register char c = getchar_unlocked(); *x = 0; for(; (c<48)||(c>57);c = getchar_unlocked()); for(; (c>47)&&(c<58);c = getchar_unlocked()) *x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48); } int main() { int i,j,a,b,t,m[100],f[100],n; scanint(&t); while(t--) { a...
C
#include <stdio.h> long a[10] = {3, 2, 4, 5, 1, 9,7, 10, 13, 17}; void bubble(long*, long); int main(){ long count = 10; bubble(a, count); if(a[0] == 1){ printf("Y"); } } void bubble(long *data, long count) { long i, last; for (last = count - 1; last > 0; last--) { for (i = 0; i < last; i++) ...
C
/* * This file includes all the setup fo the IDT (interrupts Descriptor Table) * The IDT contains the ISRs (Interrupt Service Routines) that are called when * an interrupt is handled */ #include "stdio.h" #include "string.h" #include "stdlib.h" #include "idt.h" #include "isr.h" #include <kernel/hal.h> #include <...
C
#include <stdio.h> int severse(int num) { int flag = 0; int tmp = 0; int result = 0; if (num > 0) { flag = 1; } else if (num < 0) { flag = -1; } tmp = flag * num; while (tmp) { result = result * 10 + tmp % 10; tmp /= 10; } result *= flag; return result; } int main(int argc, char *argv[]) { ...
C
#include <windows.h> #include <stdio.h> #include <conio.h> // Программа для вывода символов и их кодов в текстовый файл и на экран FILE *fopenCon(char *way,char *format); void main() { int i,j; char sym; FILE *fp; //SetConsoleOutputCP(1251); //SetConsoleCP(1251); fp=fopenCon("C:\\KodTable.txt","wt");//создаем...
C
/* * Copyright 2010 Sébastien Aupetit <sebastien.aupetit@univ-tours.fr> * * This source code is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any...
C
#include <stdio.h> #include <stdlib.h> int main() { int i,T; scanf("%d",&T); for(i=1; i<=T; i++) { int a,b,c; scanf("%d %d %d",&a,&b,&c); if(a<=20 && b<=20 && c<=20) { printf("Case %d: good\n",i); } else { printf("Case %d: ...
C
#include <stdio.h> int f(int n) { if (n == 0) { return 0; } else { return n + f(n-1);; } } int main (void) { printf ("%d\n", f(4)); return 0; }
C
#include<stdio.h> int main() { int t, n, b; int i, j = 1, k = 0; double time, memory, downloaded; while(scanf("%d%d%d", &t, &n, &b) == 3) { if(t == 0 && n == 0 && b == 0) break; if(k) putchar('\n'); k = 1; for(time = 0.0, i = 0; i < t; i++) { ...
C
#include <avr/io.h> static void initTimer1() { TCCR1B |= (1 << CS10); // prescaling = 1 //start the timer TCNT1 = 0; } int main() { DDRD |= (1 << PD7); initTimer1(); while (1) { // We use >= 65345 instead of ==, as there is a possiblity for the loop code // miss it. so to be...
C
#include<stdio.h> #define length 100 #define max(a,b) ((a)>(b)?(a):(b)) int fun(char s[], char t[]) { int res = -1; int tarindex = 0; while (s[tarindex] != '\0') { int tarlen = tarindex; int patlen; for (patlen = 0; t[patlen] != '\0'; patlen++) { if (s[tarlen++] != t[patlen]) { break; } } ...
C
#include "sprintf.h" #include "stdarg.h" #include "errno.h" s16 sprintf_pic(char * str, const char* format, ...) { u16 i = 0; u16 argint = 0; bool_t PercentageFound = FALSE; bool_t ZeroFound = FALSE; bool_t ZeroFill = FALSE; bool_t LeftAlign = FALSE; u16 NoOfNonzeroChars, NoOfZeros; u16...
C
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <math.h> bool validaN(int n); void valoresVetor(int vet[],int n); int main() { int n; do { printf("\tDigite o valor n para popular o Vetor :\n\n"); scanf("%d",&n); } while(!validaN(n)); char vet[n]; // Popular...
C
#include "graphe.h" int grapheExistant = 0; void menu1(TypGraphe* G); void menu2(TypGraphe* G); void menu1(TypGraphe* G) { int choix; printf("1) Création d'un graphe\n"); printf("2) Lecture d'un graphe\n"); printf("3) Quitter\n"); scanf("%d",&choix); scanf("%*[^\n]s"); getchar(); switch(choix) { case 1: ...
C
#include "lists.h" /** * dlistint_len - Counts and returns the number of nodes. * * @h: Head of list. * Return: Number of nodes. */ size_t dlistint_len(const dlistint_t *h) { const dlistint_t *step; size_t count; count = 0; step = h; while (step) { step = step->next; count++; } return (count); }
C
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* * File: main.c * Author: Hp * * Created on April 11, 2020, 11:22 AM */ #include <stdio.h> #include <stdlib.h> /* * */ ...
C
#include <stdlib.h> #include <string.h> #include <stdbool.h> #include <check.h> #include "check_NumeralValidator.h" #include "../src/NumeralValidator.h" START_TEST(rejects_illegal_characters) { ck_assert_int_eq(NumeralValidator_isValid("pI"), false); ck_assert_int_eq(NumeralValidator_isValid("rV"), false); ck_as...
C
#include<stdio.h> int mine(void); int main(void) { mine(); printf("\n");return 0; } int mine(void) { int a[3][3]; int i, j, sum1=0, sum2=0; for(i=0;i<3;++i) for(j=0;j<3;++j) { scanf("%d", &a[i][j]); } for(i=0;i<3;++i) for(j=0;j<3;++j) { if(i==j) sum1+=a[i][j]; if(2-i==j) sum2+=a[i][j];...
C
int main(void) { int n,razn=0,x; scanf("%d",&n); while (n>=1) { scanf("%d",&x); if (x <= 0) { razn++; } n--; } printf ("%d\n",razn); return 0; }
C
#include <string.h> #include <stdlib.h> #include <stdio.h> #include "http.h" int create_tcp_socket(); char *get_ip(char *host); char *build_get_query(char *host, char *page, char *content_type, char *post_data); void usage(); char *cookie; char *build_get_query(char *host, char *page, char *content_typ...
C
#include <stdio.h> int* plusOne(int* digits, int digitsSize, int* returnSize) { for (int i = digitsSize - 1; i >= 0; --i) { digits[i] += 1; if (digits[i] < 10) break; if (0 != i) { digits[i] -= 10; } else { for (int j = digitsSize; j > 1; --j) { ...
C
#include<stdio.h> #include<malloc.h> #define true 1 #define false 0 typedef char bool; typedef struct node { int data; struct node *next; }NODE,*PNODE,**PPNODE; void push(PPNODE top,int no) { PNODE newn=NULL; newn = (PNODE)malloc(sizeof(NODE)); newn->data = no; newn->next = NULL; if(*top == NULL) { *top...