language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> #include <stdlib.h> //#include <conio.h> # define CHAR_UP 72 # define CHAR_DOWN 80 # define CHAR_LEFT 75 # define CHAR_RIGHT 77 //# define CHAR_DELETE 127 # define CHAR_ENTER 13 # define CHAR_ESC 27 # define MAIN_MENU "\nMENU \ \n------------------\ \n1- New Game\ \nESC | q - Quit\ \nOption...
C
// SMT-Timer.c // FOSC at 4 MHz, External Oscillator for accuracy // UART at 9600 bps // LED on RD2 // // SMT1 using FOSC/4, Prescaler = 1, period = 16,000,000 us = 16 seconds // WARNING! period must be bigger than expected signal time. // Timer Mode, Timing code execution & non-blocking delay // // Modes ...
C
#ifndef _LIST_OP_H #define _LIST_OP_H #ifdef __cplusplus extern "C" { #endif #define IN #define OUT typedef struct list_head { struct list_head *next, *prev; }COMMON_LIST_HEAD,*COMMON_P_LIST_HEAD; #define COMMON_LIST_HEAD_INIT(name) { &(name), &(name) } // 定义LIST并静态初始化一个空的通用双向链表 #define COMMON_LIST_HEAD(name...
C
#include <assert.h> /* * Adapted from "Automated Error Diagnosis Using Abductive Inference" by Dillig et al. */ void main(int n, int flag) { assume(n>=0); int k = 1; int m; if(flag) { k = m; assume(k>=0); } int i = 0, j = 0; while(i <= n) { i++; j+=i; } int...
C
#include<stdio.h> int main() { int T,R,i; int arr[4][2]; scanf("%d",&T); while(T--) { scanf("%d",&R); for(i=0;i<3;i++) scanf("%d %d",&arr[i][0],&arr[i][1]); arr[3][0]=arr[0][0]; arr[3][1]=arr[3][1]; int d[3],flag=0; for(i=0;i<3;i++) { d[i]=(arr[i][0]-arr[i+1][0])*(arr[i][0]-arr[i+1][0])+(arr[i]...
C
#include "userprog/syscall.h" #include <stdio.h> #include <syscall-nr.h> #include "threads/interrupt.h" #include "threads/thread.h" #include "threads/vaddr.h" #include "userprog/pagedir.h" #include <user/syscall.h> static void syscall_handler (struct intr_frame *); void exit (int status); pid_t exec (const char *cmd_l...
C
#include<stdio.h> #include<stdlib.h> void accept(int *); void bubble(int *); void selection(int *); void insertion(int *); void display(int *); int main() { int arr[4]; char ch; insertion(arr); while(1) { printf("Enter accept = a, display=d, selection = s, bubble=b, insertion...
C
#define F_CPU 8000000 #include <math.h> #include "AD.h" #include "ntc_10k.h" long int get_resistence_ntc(double vin) { //Res of NTC (Ohm) = ((VCC + R1)/Vin) - R1 return ((VCC * R1) / vin) - 10000; } double steinhart_hart(unsigned int resistence) { double temperature; /* Temperature (K) = 1 / (a...
C
/* ID:lxlenovos1 LANG:C TASK:palsquare */ #include <stdio.h> #include <stdlib.h> #include <stddef.h> #include <string.h> char palindromes[50]; char result[50]; char map[256]; int get_palindromes(int base, int seq) { int i, num, remainder; if (base < 2 || base > 20) return -1; for (i = 0; ; ++i){ ...
C
#include <stdio.h> int main(void) { int Y[5]; /* Array declaration of 5 elements */ Y[0] = 1; /* Assign 1 to Y[0] */ Y[1] = Y[0] * 2; /* Assign Y[0] * 2 expression to Y[1] */ Y[2] = Y[1] * 3; /* Assign Y[1] * 3 expression to Y[2] */ Y[3] = Y[2] * 4; /* Assign Y[2] * 4 expression to Y[...
C
/* ** EPITECH PROJECT, 2019 ** cpp_d03_2019 ** File description: ** Created by thomas1.bastien@epitech.eu */ #include <criterion/criterion.h> #include "../string.h" Test(str, copy) { string_t s; char *buff = malloc(sizeof(char) * 7); string_t s2; string_init(&s, "Hello World salut les amis"); str...
C
#include <Arduino.h> #include <Wire.h> #include <LiquidCrystal_I2C.h> #define Volataje_VF1 2 #define Volataje_VF2 3 #define Volataje_VF3 4 LiquidCrystal_I2C lcd(0x27, 16, 2); //config LCD int Valor; const int sensorPin1 = A0; // seleccionar la entrada para el sensor int sensorValue; // variable que almacena el...
C
// Generates the ASCII table of printable characters. #include <stdio.h> int main(){ const char A[]="* THE ASCII TABLE BY JOSEF ZIEGLER *"; int i = -1, j = 0; while(j < 3) { while(++i < sizeof(A)-1) { // because of the '\0' if(j%2 == 0) putc('*', stdout); else putc(*(A...
C
#include <wos/gdt.h> #include <wos/asm.h> #include <wos/vga.h> void __put_c(char c, int x) { asm("movw $0x18, %%ax\n\t" "movw %%ax, %%gs\n\t" "movb $0x07, %%ah\n\t" "movb %0, %%al\n\t" "movl %1, %%edi\n\t" "movw %%ax, %%gs:(%%edi)\...
C
#include<stdio.h> #include<stdlib.h> #include<conio.h> #include<malloc.h> #include<windows.h> #include<string.h> void close(void) { system("cls"); printf("\n\n\n\t\t THIS WAS C-DATA STRUCTURES MINI PROJECT \n\n\t\t DEVELOPED BY TSEC STUDENTS : - ASHISH GANGWANI \n\t\t -...
C
/** * \file majPlateau.h * \brief Fonctions gérant la mise à jour du plateau * \author * \version 1.0 * \date */ #ifndef __MAJ_Plateau__ #define __MAJ_Plateau__ #include "position.h" #include "coup.h" #include "plateau.h" #include "placerCoup.h" #include "position.h" #include "pion.h" #include <stdio.h> #inc...
C
#include <stdio.h> void PrintBill(float units,float a[5],float extraCharge,char firstName[100],char lastName[100],int range[8]); int main(){ int i,choice; float units,extraCharge,totalBill,sum=0.0; char firstName[100],lastName[100]; printf("Enter\n1.To Calculate electricity of your own c...
C
#include <stdio.h> #include <stdlib.h> #define TAM 50 #define ES_MAT_IDEN 1 #define NO_ES_MAT_IDEN 0 void mostrarMatriz(int mat[][TAM], int orden); int esMatrizIdentidad(int mat[][TAM], int ff, int cc); /*Desarrollar una funcin que determine si una matriz cuadrada de enteros de orden N es matriz identidad (matri...
C
#include <stdio.h> int main() { int edad;//variable printf("Introduce tu edad: "); scanf("%d",&edad);//lectura de teclado if (edad >17 && edad <35) { printf("Tienes %d anios, eres mayor de edad\n",edad); } else if (edad < 17) { printf("Tienes %d anios, eres menor de edad\n",edad); } else if (edad >= ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <arpa/inet.h> #include <sys/socket.h> #define BUF_SIZE 1024 void error_handling ( char * msg ); int main ( int argc, char * argv[] ) { int sock; struct sockaddr_in serv_adr; char buf [ BUF_SIZE - 5 ]; char msg [ BUF_SIZE ]; ...
C
#include <stdio.h> #include <string.h> int my_strcmp(const char *s1,const char *s2); int main(void) { char str1[80]; char str2[80]; printf("Input String1>"); scanf("%s",str1); printf("Input String2>"); scanf("%s",str2); printf("ref Result : %d\n",strcmp(str1,str2)); printf("Result : %d\n",my_strcmp(str1,str...
C
#include <stdio.h> int main() { int n; int isPrime = 0; scanf_s("%d", &n); for (int i = 2; i < n; i++) { if (n % i == 0) isPrime = 1; } if (isPrime == 1) printf("Not Prime"); else printf("Prime!"); }
C
#include <stdio.h> int main(void) { //code up a switch statement int num1; int num2; int result = 0; printf("Enter two numbers separated by a space: "); scanf("%d %d", &num1, &num2); //fflush(stdin); char selection; printf("Enter a for add or s for subtract:"); //fflush(stdin); while(getchar() ...
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
/* Simple program demonstrates to do simple FILE access with fopen, fwrite, fseek and fread http://manpages.courier-mta.org/htmlman3/fread.3.html */ #include <stdio.h> #include <string.h> int main() { FILE *fp; char c[] = "this is tutorialspoint"; char buffer[100]; /* Open file for both reading an...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.c :+: :+: :+: ...
C
// Compute mean and median temperatures // g++ -g -o vector_sort.exe vector_sort.C 2>&1 | tee tmp.txt //#include "std_lib_facilities.h" #include<iostream> #include<vector> // this is where standard vector is defined #include<algorithm> // this is where sort is defined using namespace std; // if you don't want to...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <pthread.h> #include <math.h> #include <sys/time.h> long GB_DATA = 1000000000; int BLOCK_SIZE = 8; int NUMBER_OF_ITERATIONS = 1000; int NUMBER_OF_THREADS =1; char TYPE = 'W'; //To perfrom Sequential Read Write struct sequential_read_write{ char * ...
C
// N-Queens problem to print all possible solutions. // Place n number of queens in n x n chessBoard so that no 2 queens attack. // Note: Using Backtracking // @author Mohammed Ataaur Rahaman // School: Dayananda Sagar // Date: 22 April, 2018 #include<conio.h> #include<stdio.h> int N, vector[100]; int...
C
#include <stdio.h> #include<math.h> int main() { float x1,x2,y1,y2,dist; printf("enter the point (x1,y1)\n"); scanf("%f%f",&x1,&y1); printf("enter the point (x2,y2)\n"); scanf("%f%f",&x2,&y2); dist=(y2-y1)/(x2-x1); printf("the distance between the two points is %f",dist); return 0; }
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdbool.h> #include<ctype.h> char oper[500], ident[500][50], integer[500][50], real[500][50], keyword[500][50], invalid[500][50]; int oplen, idenlen, intlen, reallen, keylen, invlen; bool isDelimiter(char ch){ if (ch == '+' || ch == '-' || ch == '*'...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> void main() { char str[100]; int i,j,n; printf("Input please:"); gets(str); n=strlen(str); for(i=0;i<=n;i++) { for(j=0;j<=i;j++) { if(str[i]==str[j]) { break; ...
C
#include "rtc.h" #include "kheap.h" #include "common.h" static RTC *rtc = 0; #define CMOS_ADDRESS 0x70 #define CMOS_DATA 0x71 #define SECONDS_KEY 0x00 #define MINUTES_KEY 0x02 #define HOURS_KEY 0x04 #define DAYS_KEY 0x08 #define MONTHS_KEY 0x07 #define YEARS_KEY 0x09 #defin...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> int main(void) { int i,j,x, aleatorio, condicao, maxLinha, maxColum, intervaloAleatorio, numTotal, maior, menor, lMaior, lMenor,Total; int sorteio[5000][6]; int listQDN[59]; //QDN Quantidade de Numero int listSUP[59]; //List...
C
#include <stdio.h> #include <stdlib.h> typedef struct no No; struct no{ int valor; No* anterior; No* prox; }; typedef struct lista Lista; struct lista{ No* inicio; No* fim; }; Lista* criarLista(){ Lista* l = malloc(sizeof(Lista)); l->inicio=NULL; l->fim=NULL; } void inserirFim(Lista* l,int valor){ No* n...
C
// COMP2521 20T2 Assignment 1 // tw.c ... compute top N most frequent words in file F // Usage: ./tw [Nwords] File #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <assert.h> #include <string.h> #include <ctype.h> #include "Dict.h" #include "WFreq.h" #include "stemmer.h" #define STOPWORDS "stopwor...
C
#include "unity.h" #include "angleFiring.h" void setUp(void){ } void tearDown(void){} /* * Given a percentage, convert it to firing times(negativeHalf and positiveHalf). */ void test_computeValueToPutIntoDmaBufferFromTicks_2(void) { int i,y; int negativeHalf = 75; int positiveHalf = 30; int busyFlag = 0; c...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include "utils.h" #define MSG_S 60 #define MSG_L 1024 #define PORT_NUM 3655 void main(void) { int server_sockfd, client_sockfd; int server_len, client_len; struct...
C
/****************************************/ /* Information from password structure */ /* */ /* Author: Tilak S Naik */ /****************************************/ #include <stdio.h> #include <pwd.h> #define B_SIZE 4096 int main() { struct passwd *p; char nam...
C
#include "msp430.h" #include "lcd.h" #define SEG_A 0x01 #define SEG_B 0x02 // -A- #define SEG_C 0x04 // F B #define SEG_D 0x08 // -G- #define SEG_E 0x40 // E C #define SEG_F 0x10 // -D- #define SEG_G 0x20 #define SEG_H 0x80 static const char lcd...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_printf_p.c :+: :+: :+: ...
C
#define FUSE_USE_VERSION 30 #include <fuse.h> #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <time.h> #include <string.h> #include <stdlib.h> static int sffs_getattr(const char *path, struct stat *st) { printf("getattribute called \n"); printf("Requested %s \n", path); st->st_uid ...
C
/** * \file privtab.h * * \brief Defines a privilege table entry for general use */ #ifndef __PRIVTAB_H #define __PRIVTAB_H #include "copyrite.h" #include "mushtype.h" typedef struct priv_info PRIV; /** Privileges. * This structure represents a privilege and its associated data. * Privileges tables are used ...
C
#include<stdio.h> #include<unistd.h> #include<fcntl.h> int main(){ int fd = open("temp.txt",O_RDONLY); int fd1 = creat("temp_copy7.txt",0777); char buff[50]; int size = read(fd,buff,50); //read function will return how many byte has been written //printf("%s",buff); write(fd1,buff,size); close(f...
C
//Lista Encadeada Simples #include <stdio.h> #include <stdlib.h> typedef int TipoItem; typedef struct no{ TipoItem info; struct no * prox; }Lista; //Verifica se a cabeça da lista é nula. int VerificaLista(Lista* novo){ return(novo == NULL); } //Insere um elemento na cabeça. Lista* insere(Lista* l,TipoItem...
C
#include <SDL/SDL_image.h> #include "segmentation.h" #include "utils.h" #include "rotation.h" SDL_Surface *extract_text(char *source_location, int threshold) { SDL_Surface *image; Uint8 r, g, b; // Get the image image = IMG_Load(source_location); show_image(image, -1); // Show the image when it ...
C
/* * adc.c * * Created on: Jul 20, 2013 * Author: Nate */ #include "adc.h" int16_t get_temp_raw() { unsigned int temp =0; unsigned int IntDegC =0; int i=0; ADC10CTL0 = 0; ADC10CTL1 = INCH_10 + ADC10DIV_3; // Temp Sensor ADC10CLK/48 ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON; whi...
C
// C program to illustrate pipe system call in C #include <stdio.h> #include <unistd.h> #include <stdlib.h> #define MSGSIZE 16 void msg_pipe() { char* msg1 = "Abhay"; char* msg2 = "Good Morning"; char* msg3 = "hello"; char inbuf[MSGSIZE]; int msg[2], index; if (pipe(msg) < 0) exit(1); /* cont...
C
#include<stdio.h> #include<conio.h> #include<stdlib.h> #include<ctype.h> struct node{ struct node *prev; int data; struct node *next; }; struct node *head = NULL; struct node *tail = NULL; struct node *ptr = NULL; struct node *searchPtr; struct node *newNode; struct node *prePtr; void createNode(){ new...
C
#include <stdio.h> int main() { int n=3; printf("n=%d......n+1=%d\n",n,n++); return 0; }
C
#include <msp430g2553.h> #include "game.h" #include "LCD_Driver.h" unsigned char initPlayer() { return 0x80; } void printPlayer(unsigned char PLAYER) { writeCommandByte(PLAYER); writeDataByte('*'); } void clearPlayer(unsigned char PLAYER) { writeCommandByte(PLAYER); writeDataByte(' '); } unsigned char movePlay...
C
static int hash_table_enlarge(HashTable *hash_table) { HashTableEntry **old_table; unsigned int old_table_size; unsigned int old_prime_index; HashTableEntry *rover; HashTableEntry *next; unsigned int index; unsigned int i; /* 复制一份旧表结构并存储 */ old_table = hash_table->table; old_table_size = hash_table->table_s...
C
/* ********************* TEXTO SIN ACENTOS *********************/ // Recuerda documentar tus codigos #include <stdio.h> #include <stdlib.h> #include <math.h> int main(){ int i; float max = RAND_MAX*1.0; for (i=1; i<=4; i++){ printf("%f\n", (float)rand()/max); } return 0; }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* check_flags_di.c :+: :+: :+: ...
C
#include <stdio.h> #include <string.h> typedef struct fruit_t { char name[20]; double price; char taste[20]; } Fruit; void fillFruit(Fruit *aFruit, char *name, double price, char *taste) { strcpy(aFruit->name, name); aFruit->price = price; strcpy(aFruit->taste, taste); } void printFruit(Frui...
C
#include <stdio.h> #include <stdlib.h> typedef struct treeNode { char key; struct treeNode* left; struct treeNode* right; } treeNode; typedef char element; treeNode* insertNode(treeNode *p, char x) { treeNode *newNode; if (p == NULL) { newNode = (treeNode *)malloc(sizeof(treeNode)); newNode->key = ...
C
#include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> struct char_print_parms { char character; int count; }; void *char_print (void* parameters) { struct char_print_parms *p = (struct char_print_parms*) parameters; int i; for (i = 0; i < 10; i++) { printf("%d\n", p -> count +i)...
C
// INT31-C: Compliant Solution (Unsigned to Signed) #include <limits.h> void func(void) { unsigned long int u_a = ULONG_MAX; signed char sc; if (u_a <= SCHAR_MAX) { sc = (signed char)u_a; /* Cast eliminates warning */ } else { /* Handle error */ } }
C
#include "renderer.h" #include "shader.h" #include <assert.h> #include <glload/gl_2_0.h> #include <glload/gl_load.h> #include <GL/freeglut.h> #include <stdio.h> static const char *FRAGMENT_SHADER_LOC = "../../glsl/fragment.frag"; static const char *VERTEX_SHADER_LOC = "../../glsl/vertex.vert"; static Shader *fragSha...
C
#include "decs.h" /* diagnostics subroutine */ void diag(call_code) int call_code ; { char dfnam[10] ; int i,j,k ; double rho,v,u,ek,eth,etot,e_fin,m_fin ; FILE *dump_file ; void dump() ; double U[NP],px,py,pz,e,rmed,divb,divbmax ; void primtoU(double *p, double *U) ; static int dump_cnt ; static double e_...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #define DATA_SIZE 32768 static int DATA[DATA_SIZE]; #define ITERATIONS 102400 static const int RAND_MID = RAND_MAX / 2; void initialise(void) { srand(time(NULL)); int i; for (i = 0; i < DATA_SIZE; ++i) DATA[i] = rand(); } static clock...
C
#include "utils.h" #include <stdio.h> #include <string.h> #include <sys/stat.h> static bool str_equals(const char*, const char*); static void drop_newline(char*); bool file_exists(const char* filename) { struct stat st; return stat(filename, &st) == 0; } bool get_yes_or_no_answer(bool default_answer) { char buf[6...
C
/** * @file gpex.c * @brief Driver for Generic PCI Express Bridge Emulator. Refer to * http://www.kernel.org/doc/Documentation/devicetree/bindings/pci/host-generic-pci.txt * for more details * * @author Denis Deryugin <deryugin.denis@gmail.com> * @version * @date 14.08.2019 */ #include <assert.h> #include <st...
C
#include <stdio.h> #include <unistd.h> #include <signal.h> void catchusr(int); void do_child(int i, int *bpid){ int i,pid; static struct sigaction act; act.sa_handler==catchusr; sigaction(SIGUSR1, &act, NULL); printf("%d-th child is created ... \n", i); // pause(); if(i!=1){ pause(); } pid = getpid();...
C
/****************************************************************************** * @author: David Anderson * Question: * Would this code work? * Solution: * No it would not! Notice you are trying to use a pointer on the heap after * you gave it back. You don't own it after you've given it back to the memory ...
C
/* * Copyright (c) 2017 Intel Corporation * * SPDX-License-Identifier: Apache-2.0 */ #include "test_queue.h" #define TIMEOUT K_MSEC(100) #define STACK_SIZE (512 + CONFIG_TEST_EXTRA_STACK_SIZE) #define LIST_LEN 2 static K_THREAD_STACK_DEFINE(tstack, STACK_SIZE); static struct k_thread tdata; K_SEM_DEFINE(sem, 0, ...
C
#include <stdio.h> #include "holberton.h" /** * mul - Multiplies two values given as input and displays the product * @a: First integer * @b: Second integer * Return: Success */ int mul(int a, int b) { int product; product = a * b; return (product); }
C
uint8_t ADCV[2]; //!< Cell Voltage conversion command. uint8_t ADAX[2]; // GPIO conversion command. void LTC_wakeup_sleep(){ LTC6804_CS_P &= ~(1<<LTC6804_CS); _delay_ms(1); LTC6804_CS_P |= (1<<LTC6804_CS); } /*!********************************************************************************************************...
C
#include "holberton.h" /** * print_rev - print a string in reverse * @s: the string to print */ void print_rev(char *s) { int length; for (length = 0; *s != '\0'; s++) length++; s--; length--; for (; length >= 0; length--, s--) _putchar(*s); _putchar('\n'); }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <winsock.h> #include <ctype.h> #include <winsock2.h> #include <windows.h> #define Len 256 #pragma comment(lib,"ws2_32.lib") //Winsock Library #define bzero(a, b) memset(a, 0, b) #define BUFFER_SIZE 1024 #define FILE_NAME_...
C
#include <stdio.h> // Function to return the // minimum of two numbers int Min(int Num1, int Num2) { return Num1 >= Num2 ? Num2 : Num1; } // Utility function to calculate LCM // of two numbers using recursion int LCMUtil(int Num1, int Num2, int K) { // If either of the two nu...
C
#include <stdio.h> int main(){ int massa = 0; printf("Informe uma massa em kg \n"); scanf("%d", &massa); printf("A massa convertida em libras eh: %.2lf", (massa / 0.45)); return 0; }
C
#include "fthread.h" #include "stdio.h" /* cleanup when stopping a thread */ void pr (void *text) { while (1) { fprintf (stdout,"%s",(char*)text); ft_thread_cooperate (); } } void cleanup (void *args) { fprintf (stdout,"clean up!!!!!!!!\n"); } void control (void *args) { ft_thread_t t = (ft_...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #define FINISH_FLAG "FILE_TRANSPORT_FINISH" #define MAXLINE 10240 void usage(char *command) { printf("usa...
C
#include <stdlib.h> #include "digraph.h" /* Construtor do dígrafo */ Digraph *initDigraph(int nV, int nA, List **adjacentes){ Digraph *G; G = malloc(sizeof(Digraph)); G->V = nV; G->A = nA; G->adj = adjacentes; return G; } /* Retorna o vetor de listas de adjacencia do dígrafo */ List **getAdj(Digraph *G){ retu...
C
// // main.c // 冒泡排序 // // Created by 吴方兵 on 16/8/14. // Copyright © 2016年 吴方兵. All rights reserved. // #include <stdio.h> void Bubblesort(int a[],int n){ int i,j,t; for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ if(a[i]>a[j]){ t=a[i]; a[i]=a[j]; ...
C
#include <stdio.h> #define N 3 #define M 2 int main() { int a[N][M] = { 1, 2, 3, 4, 5, 6 }; int x = a[1][0]; // sets x to 3 int y = a[2][1]; // sets x to 6 int z = *(*(a + 2) + 1); // equivalent to a[2][1] printf("x: %d, y: %d, z: %d\n", x, y, z); }
C
#include "holberton.h" /** * _atoi - converts a string to an integer, pulls integer and its sign. * @s: string to be evaluated. * Return: integer with its sign */ int _atoi(char *s) { int dash_count = 0; int num_started = 0; int number = 0; int i = 0; for (; s[i] != '\0'; i++) { if (s[i] >= '0' && s[i] <...
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: Lewis * * Created on 11 December 2016, 12:24 */ #include <stdio.h> int input(){ ...
C
#include <stdlib.h> #include <stdio.h> #include <mcheck.h> int main(int argc, char *argv[]) { char *p; if (mcheck(NULL) != 0) { fprintf(stderr, "mcheck() failed\n"); exit(EXIT_FAILURE); } p = malloc(1000); fprintf(stderr, "About to free\n"); free(p); fprintf(stderr, "\nAb...
C
#include <stdio.h> int main (void){ char conta, es; float a,b; int op; while (op<= 10){ system ("cls"); printf("Digite a conta desejada:(+,-) "); scanf("%f %c %f", &a, &conta, &b); if (conta == '+') printf("%.2f %c %.2f = %.2f",a, conta, b, a+b); else if (conta == '-') p...
C
///input: 1 output: a or A assign number to albabet to print albabet by cooresponded number like 25=z ///the below code does not give output and any error Alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' numbers = [3,6,12,1,1,3] letters = Alphabet(numbers) #include <stdio.h> void print(int); int main(void) { int nu...
C
#include "vfs.h" #include "terminal.h" #include "log.h" #include "common.h" fs_node_t *fs_root = 0; uint32_t read_fs(fs_node_t *node, uint32_t offset, uint32_t size, uint8_t *buffer) { if (node->read != 0) return node->read(node, offset, size, buffer); else return 0; } uint32_t write_fs(fs_no...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_vector_create.c :+: :+: :+: ...
C
#include "holberton.h" /** * _strlen - Count the maximum number of a array * @s: Input Array * * Return: counter */ int _strlen(char *s) { int cont; cont = 0; while (s[cont]) { cont++; } return (cont); } /** * string_nconcat - concat in s1 n charecters of s2 * @s1: String 1 * @s2: String 2 * @n: # ...
C
#include "../../lv_examples.h" #if LV_USE_SNAPSHOT && LV_BUILD_EXAMPLES static void event_cb(lv_event_t * e) { lv_obj_t * snapshot_obj = lv_event_get_user_data(e); lv_obj_t * img = lv_event_get_target(e); if(snapshot_obj) { lv_img_dsc_t * snapshot = (void *)lv_img_get_src(snapshot_obj); if...
C
//program to write the result of 1/1!+ 1/2! + 1/3! + ....... +1/n! #include<stdio.h> int main() { int n; float fact =1; float sum = 0; printf("\nEnter the value of n: "); scanf("%d",&n); for(int i=1;i<=n;++i) //repeat for n numbers { for(int j=i;j>=1;--j) //calculate factorial ...
C
#include <stdio.h> int main(void) { int c = 0, aux; float a[3]={1, 2, 3}; //float c, d; for (float i = .0f; i < 2.2f; i+=.2f) { aux = (int)((i - (int)i)*10); for (int j = 0; j < 3; j++){ if(aux == 0){ printf("I=%.0f J=%.0f\n", i, a...
C
#include <sys/types.h> #include <sys/stat.h> #include <sys/socket.h> #include <unistd.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char **argv){ int ssock, csock; struct sockaddr_in saddr; char buf[10000]; char filename[255]; cha...
C
#include <stdio.h> int main(void) { printf("Hello\tWorld!\n"); printf("kuruC\ttanoC\n"); printf("%d+%d=%d円\n",200,100,200+100); printf("%f\n", 10.0/3.0); int a = 40; //変数宣言は本来先頭でないと動かないが、C99やC++では動く int b = 13; int division = a / b; // 四捨五入を行うと、商×割る数、の逆計算を行ったときに、 // その結果が、元の割ら...
C
#ifndef LAB_8_C #define LAB_8_C #include "functions.h" void counting_sort (int *arr, int *counters, int len, int min, int max) { int i = 0; for (i = 0; i < len; i++) { counters[arr[i]]++; } int j = 0, k = 0; for (i = min; i < max + 1; i++) { for (j = 0; j < counters[i]; j++) { arr[k] = i; k++; } } } #...
C
#include <stdarg.h> #include <stdio.h> /** * print_numbers - Prints numbers, followed by a new line. Varying amount of * numbers may be passed. * @separator: The string that will be printed in between numbers. * @n: The numbers of arguments passed after n. * * Return: Void. */ void print_numbers(const c...
C
/* Group 27 Venkat Nalla Siddartha Reddy 2016A7PS0030P Arnav Sailesh 2016A7PS0054P Gunraj Singh 2016A7PS0085P Aashish Singh 2016A7PS0683P */ #include "interface.h" #include "symbol_table.h" #include "ast.h" #inclu...
C
#include <stdio.h> #include <stdlib.h> // This program sets up the ADC int main(void) { char path[35] = "/sys/devices/bone_capemgr.9/slots"; printf("Setting up ADC..."); FILE *fd = fopen(path, "w"); if (fd == NULL) { fprintf(stderr, "Could not open file: %s\n", path); return EXIT_FAILURE; } fprint...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* check_valid.c :+: :+: :+: ...
C
#include <stdlib.h> #include <stdio.h> #include "expr.h" // build and print expression objects void main(int argc, char *argv[]) { // create expression 3 + 4 EXPR *e1 = expr_create_num(3); EXPR *e2 = expr_create_num(4); EXPR *e = expr_create_sum(e1, e2); expr_print(e); printf("\n"); // create e...
C
// Cuff: 查拳、燕青拳、太祖長拳、六合拳、少林長拳、八極拳 // Claw: 大擒拿手、小擒拿手、鷹爪功、虎爪手 // Strike:八卦掌、武當綿掌、遊身八卦掌 #include <ansi.h> inherit SKILL; string martialtype() { return "skill"; } mapping *action = ({ ([ "action": "$N單手上抬,一招查拳的「沖天炮」,對準$n的$l猛擊下去", "force" : 420, "attack": 130, "dodge" : 45, "parry"...
C
#include"stdio.h" int main(int argc, char *argv[]) { int n; scanf("%d",&n); static num[3]; int a,b,c; int counta=0,countb=0,i; for(i=0;i<n;i++) { scanf("%d %d %d",&a,&b,&c); num[a]++; if(a==1) { counta+=b; } else countb+=b; } ...
C
#include <stdio.h> void print_r(int a[],int n){ int i; for (i = 0; i < n; ++i) { printf("%d\t",a[i]); } printf("\n"); } void merge(int a[],int temp[], int start, int mid, int end) { int first_end, second_start, temp_pos=0; first_end = mid; second_start = mid + 1; int size = end - start+1; while((start <=...
C
/* * Helper for single-precision routines which calculate exp(x) and do not * need special-case handling * * Copyright (c) 2019-2023, Arm Limited. * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception */ #ifndef PL_MATH_V_EXPF_INLINE_H #define PL_MATH_V_EXPF_INLINE_H #include "v_math.h" static const...