language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
/* Program that simulates the game "Game of Life". * First, takes 3 inputs, rows, columns and number of steps/generations * Then takes the initial board state * Returns the board state of the final generation/step */ #include <stdio.h> #include <stdlib.h> /* * Constants for alive and dead cells, can be changed ...
C
#include <stdio.h> #define LENGTH 6; int binsearch(int i, int j[], int q); int main () { int x, n, i; x = 3; n = LENGTH; int v[n]; for (i = 0; i < n; i++) { v[i] = i + 1; printf("%d \n", v[i]); } printf("index: %d \n", binsearch(x,v,n)); } int binsearch(int x, int v[], int n) { int low, high, mid; low ...
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> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <errno.h> #include <fcntl.h> #include <time.h> #include "headers.h" int main(int argc, char * argv[]){ welcomeScreen(); char * name = getName(); char * player = playerSelection(name); char ** winLose; // first is winner, ...
C
#include "linkqueue.h" #include "BFS.h" int visit[N] = {0}; graph_t * graph_create(){ graph_t *g = (graph_t *)malloc(sizeof(graph_t)); int i = 0; for (i = 0; i < N; ++i) { g->V[i] = i; } return g; } int graph_input(graph_t * g) { int i,j; while(scanf("%d %d", &i, &j) == 2) { //while( getchar() != '\n...
C
/*Write a program to implement Singly Linked lists of integers. 1.Write function insert_end() to insert an element at end of linked list. Take Linked List pointer and integer as two arguments. 2.Write function insert_beg() to insert at beginning of linked list. Take Linked List pointer and integer as two arguments. 3.W...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* parser_heredoc.c :+: :+: :+: ...
C
/* PROTO-SHELL CRIADO POR CAMILO LIRA SIDOU * para a matéria de Sistemas Operacionais * ministrada pelo prof. André Carvalho * Engenharia de Software - iComp - UFAM * 01/09/2019 */ #include <stdio.h> #include <stdlib.h> #include <sys/wait.h> #include <string.h> #include <unistd.h> #include <fcntl.h> // INPUT_DEL...
C
#include <stdio.h> #include <stdlib.h> #include <locale.h> main () { setlocale (LC_ALL, "portuguese"); int quantidadeMinima, quantidadeMaxima; float estoqueMedio; printf ("\n Digite o estoque Mínimo: "); scanf ("%d", &quantidadeMinima); printf ("\n Digite o estoque Máximo: "); scanf ("%d"...
C
#include "holberton.h" /** * select_function - structured list to work with it * @format: string with operators * @list: list of arguments to print * Return: numbers of char printed */ int select_function(char format, va_list list) { unsigned int i = 0, result = 0; f_type operator[] = { {'c', print_char}, ...
C
/* */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include "cjson/cJSON.h" #include "cjson/cJSON_ex.h" #include "types.h" #include "list.h" struct list_head NodeListHead[HASHLISTLENTGH]; /** * @brief init list hash table head. * * @returns no...
C
#include <stdio.h> #include <stdlib.h> int comp(const void *a, const void *b) { return *(int*)a-*(int*)b; } int main() { int i = 0; int *array; int n; printf("输入排序个数:\n"); scanf("%d", &n); array = (int*)malloc(n*sizeof(int)); for(;i<n;i++) { scanf("%d", (array+i)); } ...
C
/*古典问题(兔子生崽):有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少?(输出前40个月即可)*/ #include "stdio.h" int main() { int month,num; int f(int n); for(month=1;month<=40;month++) { num=f(month); printf("The amount of rabits in the %dth month is:%d.\n",month,num); } return 0; } int f(int n) { int m; ...
C
/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ struct TreeNode* createNode(int* nums, int left, int right){ if(left > right) return NULL; int x = (left+right)/2; struct TreeNode* node = (struct TreeNode*)...
C
/************************************************************************* > File Name: server.c > Author: hosts > Mail: hosts@gsxio.com > Created Time: Sun 02 Jul 2017 09:12:03 AM CST ************************************************************************/ #include "apue.h" #include <sys/types.h> /* Se...
C
#include<stdio.h> #include<stdlib.h> int main() { char c; int isVowel(char); scanf("%c",&c); if (isVowel(c)==1) { printf("V\n"); } else{ printf("C\n"); } return 0; } int isVowel(char c){ switch(c){ case 'a':case 'o':case 'i':case 'e':case 'u': case 'A':case 'O':case 'I':case 'E':case 'U': return 1;...
C
/* * File: ResTableEntry.h * Author : angelToms * */ #ifndef RESTABLEENTRY_H #define RESTABLEENTRY_H #include <stdint.h> #include "ResStringPoolHeader.h" #include "ResStringPoolRef.h" /** * This is the beginning of information about an entry in the resource * table. It holds the reference to the name of th...
C
#include<stdio.h> #include<conio.h> void main() { int a,b,ans; char ch; clrscr(); printf("\n Enter a=addition,s=substraction,m=multiplication: "); scanf("%c",&ch); printf("\n Enter A \n"); scanf("%d",&a); printf("\n Enter B \n"); scanf("%d",&b); switch(ch) { case 'a': ans=a+b...
C
#ifndef INTERNALEEPROM_H #define INTERNALEEPROM_H static sensorConfig_eprom_t epromRecords[NUMBER_OF_HARDWARE_ADDRESSES] __attribute__((section(".eeprom"))); sensorConfig_eprom_t eepromRead(int myAddress) { sensorConfig_eprom_t myRecord; myRecord.sensorConfig.hardwareAddress = e...
C
/* 5) Apresentar os números primos entre 1 e 100. */ #include <stdio.h> int main(void) { int i, j; int qtde; printf("Monstrar os numeros primos entre 1 e 100:\n\n"); for (i = 1; i < 101; i++) // gerar os primos de 1 a 100. { qtde = 0; for (j = 2; j <= i / 2; j++) // testar o numero...
C
/* 2019最新个人所得税免征额提高到5000,5001~8000部分税率3%, 8001~17000部分税率10%,17001~30000部分税率20%,30001~40000部分税率25%, 0001~60000部分税率30%, 60001~85000部分税率35%,85000部分以上45%。输入当月工资额,计算应交个税。 */ #include<stdio.h> int main() { double salary; printf("请输入当月工资:\n"); scanf("%lf",&salary); if(salary>5000&&salary<=8000) printf("应交个人所得税%f\n",sal...
C
#include <stdio.h> void set_matrix (int i, int j, int n, char c, int matrix[][10], int columns[]) { if (i < n) { if (j < 10 && c == ',') { scanf("%d%c", &matrix[i][j], &c); return set_matrix(i, j + 1, n, c, matrix, columns); } columns[i] = j; return set_matrix(i + 1, 0, n, ',', matrix, columns); ...
C
//character frequency #include <stdio.h> #include <string.h> int main() { char str[10],ch; int c = 0; printf("Enter a string: "); gets(str); printf("Enter a character to find its frequency:"); scanf("%c",&ch); for (int i=0;str[i]!='\0';++i) { if (ch==str[i]) ...
C
/* ** cut_str.c for cut_spaces_tab in /home/DoWdoX/PROJECT/PSU/clone2 ** ** Made by DORIAN DEBOUT ** Login <DoWdoX@epitech.net> ** ** Started on Sat Jan 21 15:39:56 2017 DORIAN DEBOUT ** Last update Sun Jan 22 15:05:03 2017 DORIAN DEBOUT */ #include "./include/my.h" int cut_begin(char *str) { int i; i = 0; ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_isexec.c :+: :+: :+: ...
C
#include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <wait.h> #include <limits.h> #include <fcntl.h> #include <time.h> #include <pthread.h> #include <inttypes.h> #include <math.h> #include <errno.h> #include <semaphore.h> struct performer{...
C
/* $Revision: 1.1.6.6 $ */ /* shrlibsample.c * * Sample C shared library for use with MATLAB Shared * Library Calling (CALLLIB) * Copyright 2002-2008 The MathWorks, Inc. * */ #include <stdlib.h> #include <mex.h> /* only needed because of mexFunction below and mexPrintf */ /*#include "windows.h"*/ #define EXPOR...
C
#include <stdio.h> #include<stdlib.h> struct Term { int coeff; int exp; }; struct poly { int n; struct Term *terms; }; void create(struct poly *p) { int i; printf("Number of terms?"); scanf("%d",&p->n); p->terms=(struct Term*)malloc(p->n*sizeof(struct Term)); printf("Enter terms\n"); ...
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> #include <math.h> int fees(int starthrs,int startmin,int endhrs,int endmin){ int hrs = 0, min = 0; int fees=0; if( startmin>endmin ){ endhrs -= 1; endmin += 60; } hrs = endhrs-starthrs; min = endmin-startmin+(hrs*60); if( min<=120 ) fees = (min/30)*...
C
#include "uart.h" void uart0_init() { unsigned int * gphcon = GPHCON,*gphup=GPHUP,*ulcon=ULCON0,*ucon=UCON0,*ubrdiv0 = UBRDIV0; *gphcon &= ~(3<<4|3<<6); *gphcon |= 2<<4|2<<6; *gphup &= ~(1<<2|1<<3); *ulcon = 3; *ucon = 5; *ubrdiv0 = 26; } int getchar(void) { unsigned int * uartstat = UARTS...
C
#include <stdlib.h> #include <stdio.h> void *my_alloc(size_t count) { return malloc(count); } void my_free(void *ptr) { printf("NATIVE freeing: %p\n", ptr); free(ptr); }
C
#include <stdio.h> #include <string.h> #define TARGET_SPEED 100 #define PID_CNT 100 typedef struct pid_info { float kp; float ki; float kd; float set_speed; float actual_speed; float err; float err_last1; float err_last2; float err_total; } pid_info_s; int pid_init(pid_info_s *pid) { if (NULL == pid) { ...
C
#include "osdcore.h" #include "sound/wavwrite.h" struct _wav_file { FILE *file; UINT32 total_offs; UINT32 data_offs; }; wav_file *wav_open(const char *filename, int sample_rate, int channels) { wav_file *wav; UINT32 bps, temp32; UINT16 align, temp16; /* allocate memory for the wav struct */ ...
C
#include <stdlib.h> #include "c-sum.h" int sum_abs_(int *in, int *num, int *out) { int i; for (i=0; i < *num; ++i) { *out += abs(in[i]); } }
C
#include <stdio.h> void delete_char(char* arr,char ch); int main() { char arr[10],ch; scanf("%s\n",arr); scanf("%c",&ch); delete_char(arr,ch); return 0; } void delete_char(char* arr,char ch) { for(int i=0;i<10;i++) { if(ch==*(arr+i)) { for(int j=i;j<10;j++) { *(arr+j)=*(arr+j+1);...
C
#include "LynxSD.h" //////////////////////////////////////////////////////////////////////////////// // // Microcontroller communication constants // //////////////////////////////////////////////////////////////////////////////// typedef enum { ECommandByte_OpenDir = 0, ECommandByte_ReadDir, ECommandByte_OpenFile...
C
/*************************************************************/ /* imcop_types.h */ /* DM350 IMCOP type definitions */ /* ------------------------------------------------------ */ /* 09/02/2005 First release by ...
C
#include <stdio.h> #include <stdlib.h> int putData(int**, int, int); void printData(int**, int, int); int main(void) { int n, m; int i; scanf("%d %d", &n, &m); int** arr = (int**)malloc(sizeof(int*) * n); if (arr == NULL) exit(EXIT_FAILURE); for (i = 0; i < n; i++) // 주의: 'n번' 할당해야 한다. Cautio...
C
#include <stdio.h> #include <stdlib.h> int get_positive_int() { char buffer[80]; char *ret, *tail; long n; do { printf("Height: "); ret = fgets(buffer, 80, stdin); n = strtol(buffer, &tail, 10); } while (n < 1 || n > 8 || ret == NULL || *tail != 0x0a); return n; } int m...
C
#include <stdio.h> #include <ucontext.h> #include <stdlib.h> #include <string.h> typedef struct TCB_t { int thread_id; ucontext_t context; struct TCB_t *next; struct TCB_t *prev; } TCB_t; void init_TCB (TCB_t *tcb, void *function, void *stackP, int stack_size) { memset(tcb, '\0', sizeof...
C
#include<stdio.h> #include<stdlib.h> int main() { char prenom[100]; printf("Veuillez entrer votre nom:\n>>> "); scanf("%s", prenom); printf("Bonjour Monsieur %s !", prenom); return 0; }
C
#include <ng_vector.h> #include<stdlib.h> #include<string.h> // constructors ng_vector_t* ng_vector_new(const size_t fruit_size, const int max) { const size_t size = sizeof(ng_vector_t) + fruit_size*max; ng_vector_t* self = (ng_vector_t*)malloc(size); return ng_vector_init(self, fruit_size, max); } ng_vect...
C
#include <stdio.h> unsigned int bit_set(unsigned int value, int n) { value = value | 1 << (n - 1); return value; } int bitpat_search(unsigned int source, unsigned int pattern, int n) { int int_size = 32, i, j, k = 1; unsigned int compare, movePattern, move, temp = 1, theMove = 0; for (i = 1; i <= n; i++) the...
C
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<unistd.h> #include<sys/types.h> #include<sys/ipc.h> #include<sys/sem.h> #include<sys/shm.h> #include <sys/stat.h> #include<fcntl.h> static struct sembuf buf; void podnies (int semid, int semnum) { buf.sem_num = semnum; buf.sem_op = 1; buf.sem_flg = 0...
C
/* Este programa crea dos hilos. Cada hilo hace exactamente lo mismo, incrementar una variable global un numero de veces "NITER". El resultado final debe ser el doble del numero de veces que se incrementa la variable, ya que cada hilo la incrementa el mismo número de veces. Si no hubiera semáforo general, el resultad...
C
#include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <errno.h> #if 0 //chri #include <getopt.h> #include <linux/soundcard.h> #include <sys/resource.h> #include <linux/config.h> #endif #include <math.h> #include "faad.h" #include "audio.h" audio_file *open_audio_file(char *infile, int samplerate, int...
C
#include"../inc/cmd.h" int run(int argc, char* argv[]) { // No input file path, Print HELP if(argc == 1){ printf("%s",help_info); return 0; } // Initial static global variables algo = 0, mode = 0, k_flag = 0, total_bytes = 0; in_path = argv[1]; fp = NULL; out_path = NULL; ...
C
#include "holberton.h" /** * _abs - determine the absolute value of an integer * @i: variable to determine the absolute value of an integer * Return: i if succesful */ int _abs(int i) { if (i < 0) i *= -1; return (i); }
C
/* * DE1-SoC LT24 Example * * Displays a test pattern on the LT24 * LCD using the LT24 bare metal driver. * * Created on: 09 Feb 2018 */ #include "DE1SoC_LT24/DE1SoC_LT24.h" #include "HPS_Watchdog/HPS_Watchdog.h" #include "HPS_usleep/HPS_usleep.h" #include "seven_seg/seven_seg.h" #include <math.h> volatile int...
C
#include <gtk/gtk.h> #define BUFSIZE 256 /* Create the list of "messages" */ static GtkWidget *create_list( void ) { GtkWidget *scrolled_window; GtkWidget *textView; /* Create a new scrolled window, with scrollbars only if needed */ textView= gtk_text_view_new(); scrolled_window = gtk_scrolled...
C
#include <stdio.h> int main(){ int cont=0,N=0,m; scanf("%d",&N); while (cont<=10000){ cont++; if(cont%N==2){ printf("%d\n",cont); } } return 0; }
C
#include <stdio.h> char *findFirstOcc(char c, char str[]) { int i; for(i = 0; str[i]; ++i) { if(str[i] == c) { return str + i; } } return NULL; } int main(void) { int cdt; char str[256]; scanf("%d", &cdt); while(cdt--) { scanf(" %[^\n]%*c", str); printf("('a') => %s\n", findFirstOcc('a', str)); ...
C
/** \file myDebug.c \brief Implementation file for custom debugging functions. \date Dec 5, 2014 \author Luis M. Gallegos C. */ /****************************************************************************** * INCLUDE FILES * **************...
C
#include <stdio.h> #include <stdlib.h> #include <signal.h> #include <string.h> //input:seconds,path,args int pid; void alarmAction (int signum) { printf("ALARM\n"); kill(pid,SIGKILL); } int main (int arc, char **argv, char **env) { if (arc <= 1) printf("There are not any args\n"); else if (arc == 2) ...
C
#include "trickle.h" #include "positioning.h" // PhoenixLL #include "mayfly.h" #include "debug.h" // other #include <string.h> #include "SEGGER_RTT.h" #define APP_ID 0x8070 #define KEY_LEN 14 /* Application "positioning" * Key structure: (uint16_t app_id, uint8_t addr1[6], uint8_t addr2[6]) * Value: 1 byte RSSI ...
C
#include <stdio.h> #include <cs50.h> #include <math.h> int getCoin(int n); int main(void) { int counter = 0; float change = -1; int cents = 0; while (change < 0) { printf("How much is the change?\n"); change = get_float(); cents = roundf(change * 100); } while (cen...
C
/* * Layout.h * * Created on: Jan 26, 2020 * Author: Kenny Rhodes * */ #ifndef LAYOUT_H_ #define LAYOUT_H_ #include <stdio.h> #include <stdlib.h> #include "room.h" typedef struct{ //A graph of rooms in the house Room roomList; }Layout; int nRooms(void); Room firstRoom(void); void...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char vet[200]; char * str1; int tam; scanf("%[^\n]%*c", vet); tam = strlen(vet); str1 = (char *)malloc(sizeof(char) * tam); for(int i = 0; i < tam; i++) { str1[i] = vet[tam - 1 - i]; } str1[ta...
C
/* Input one character and print that character. */ #include<stdio.h> int main() { char w[20]; scanf("%s", &w); printf("%s\n", w); return 0; }
C
#include "trie.h" #include <stdio.h> #include <stdlib.h> #include <string.h> /** * @brief Adding fake documentation to keep playing with github. * * @param trie * @param word * * @return */ int add_word(trieNode* trie, char* word){ int i, j, length = strlen(word); if(trie->letter){ printf("add_word should o...
C
// // instruction.h // desassembleur // // Created by Hubert Godfroy on 23/03/12. // Copyright (c) 2012 Mines de Nancy. All rights reserved. // // Cette classe a pour but de faire de la POO en C.. // /*! * @file instruction.h */ #ifndef desassembleur_instruction_h #define desassembleur_instruction_h #include...
C
#include <stdio.h> /* * print Fahrenheit-Celsius table for fahr = 0, 20, ..., 300 */ float fahr_to_cel(int fahr); float fahr_to_cel(int fahr) { return (5.0 / 9.0) * (fahr - 32.0); } main() { /* * Declarations: <type> <variable name> */ float fahr, celsius; int lower, upper, step; /* * Assignm...
C
#include <stdio.h> int main() { int a[6] = {1, 2, 3, 4, 5, 6}; for (int i = 0; i < 6; i++) { if (i == 4) break; printf("\nAddress of array index elements %d is %x.", a[i], &a[i]); } return 0; }
C
// // Created by gianluca on 23/11/19. // #include <stdio.h> #define MAXD 7 int maj(int *v, int n); int main() { int vet[MAXD] = {3, 3, 9, 4, 3, 5, 3}; int ris = maj(vet, MAXD); printf("%d\n", ris); return 0; } int maj(int *v, int n) { if(n==1) return *v; //Il vettore unitario ha il suo unico e...
C
#include <stdio.h> #include <stdlib.h> #define MAXN 999999999 #define MAXV 100 int M[MAXV][MAXV],X[MAXV],n; int flag=0;//ǿ֧ͨ /* +(X)ǷΪ? :0;:1*/ int Phi_plus() { int i,j; for(i=1;i<=n;i++) for (j=1;j<=n;j++) if ((i!=j)&&(X[i]==-1)&&(X[j]==0)&&(M[i][j])) return(1); return(0); } void prim1() { int i,j; for(...
C
/* * File: main.c * Author: bryan * * Created on 18 de julio de 2018, 11:55 AM */ #include <stdio.h> #include <stdlib.h> #include <string.h> /* * Argumentos principales argc para el contador de parametros ingresados en la ejecucion * argv para el puntero que hace referencia a los parametros ingresados...
C
#include <stdio.h> int strlen1(char *s); int main(void) { char str[] = "hogefoobar"; printf("length of str:%d\n", strlen1(str)); return 0; } int strlen1(char *s) { int len = 0; for (; s[len] != '\0'; len++); return len; }
C
#include <stdio.h> #include <stdlib.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(void) { int arr[2][2][2] = {1, 2, 3, 4, 5, 6, 7, 8}; printf("%d \n", arr[1][0][1]); printf("1°: %d \n", *(*(*(arr+1)+0)+1)); printf("2°: %d \n", *(*(ar...
C
/*գҪıйص䡣 һ looptimes (0<looptimes<10) looptimes 㣺 ʮơ˽ƺʮʽÿʮơ˽ƺʮʽ ʾ˵ 룺 1 (looptimes=1) 31 11 1a (ʮ31˽11ʮ1a) The decimal is 31, the octal is 37, the hexadecimal is 1f. (ʮ31ʮơ˽ƺʮʽ31, 37, 1f) The decimal is 9, the octal is 11, the hexadecimal is 9. ˽11ʮơ˽ƺʮʽ9, 11, 9) The decimal is 26, the octal is 32, the he...
C
// // main.c // TwoFloats // // Created by Josiah Mory on 4/7/17. // Copyright © 2017 kickinbahk Productions. All rights reserved. // #include <stdio.h> int main(int argc, const char * argv[]) { float firstNum; float secondNum; double combinedNums; firstNum = 3.14; secondNum = 82.25; combinedNum...
C
#include <stdlib.h> #include <string.h> #include <stdio.h> #include "lib_util.h" #include "stringsorting.h" void createStringElementsArray(StringElementsArray * si, int N) { si->N = N; si->str = (char **) malloc(sizeof(char *) * N); si->len = (int *) malloc(sizeof(int) * N); return; } void fre...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> #include "linkedHead.h" struct Song_node * insert_front(struct Song_node *nody, char *artist, char *name){ struct Song_node *newSong = malloc(sizeof(struct Song_node)); strcpy(newSong->name, name); strcpy(newSong->artist, artist)...
C
/** *\file dwenguinoLumberjack.h *\brief This file contains all the functions that are made specifically for the game. * *Almost all changes happen by changing the variables in the \a Game struct. *\author Antoine, Sebastiaan */ #ifndef DWENGUINO_LUMBERJACK_H #define DWENGUINO_LUMBERJACK_H #include <stdlib.h> #inclu...
C
/*Jinoo Hong*/ /*Take in 3 user-input numbers and print “numbers are equal” if all 3 numbers are equal, and “not equal”, followed by the largest number, if the numbers are not equal. Then print out the sum of the 3 numbers.*/ #include <stdio.h> int main() { int num1, num2, num3, total; printf("Please enter a numb...
C
#include<stdio.h> int main() { char c; int islowercasevowel,isuppercasevowel; printf("enter an alphabets:"); scanf("%c",&c); if(is lowercase vowel) printf("%c is a vowel"); else printf("%c is a consonants"); }
C
#include<stdio.h> int main() { int arr[25],i,positive=0,negative=0,odd=0,even=0; for(i=0;i<25;i++) { printf("\n enter the no = "); scanf("%d",&arr[i]); } for(i=0;i<25;i++) { if (arr[i]>0) positive++; if (arr[i]<0) negative++...
C
/* * readability.c * index = 0.0588 * L - 0.296 * S - 15.8 * L is the average number of letters per 100 words in the text * S is the average number of sentences per 100 words in the text * Ask user to input a string, count the number of letters (a-z, A-Z) * Calculate grade * Print as output "Grade X" where X is ...
C
// Exercise 5-4. Write the function strend(s,t), which returns 1 of the string // t occurs at the end of the string s, and zero otherwise. #include <stdio.h> int strend(char*, char*); int main() { char a[] = "This is one string."; char b[] = "one string."; printf("%d\n", strend(a, b)); return 0; } int strend(ch...
C
#include <stdio.h> #include <stdlib.h> struct queue{ int* data; int head; int tail; int cap; int count; }; void initqueue(int n, struct queue* q){ q->data = (int*)malloc(n*sizeof(int)); q->cap = n; q->count = 0; q->head = 0; q->tail = 0; } void relocation(struct queue* q){ ...
C
#include <stdio.h> #include <stdlib.h> #include "linked_list.h" // function to convert a linked list to an array sized_arr convert_list_array(Node *list) { sized_arr sized_array; int size_list = get_size(list); double *array = NULL; array = malloc(sizeof(double) * size_list); Node *temp = list; ...
C
#include <stdio.h> #include <stdlib.h> #include <locale.h> #include <math.h> float hipcalc(float a, float b); /*2) Escrever uma funo para retornar o valor da hipotenusa de um tringulo retngulo dado os valores dos catetos.*/ int main() { setlocale(LC_ALL, "portuguese"); float op, adj, hipotenusa; printf("H...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> int *fill_arr(int count){ srand(time(NULL)); int *arr = (int*)malloc(count * sizeof(int)); for(int i = 0;i < count;i++){ *(arr + i*sizeof(int)) = rand() % 10; } return arr; } void print_arr(int *arr,int count){ for(int i = 0;i < co...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_printf.c :+: :+: :+: ...
C
#include "LPmatrx.h" int iSum(int n,int *v) { int i,r=0; for (i=0; i<n; i++) r+=v[i]; return (r); } /* iSum */ int getPos(int n, int i, int *v) { int j; for(j=0; j<n && i!=v[j]; ++j); return (j); } /* getPos */ void iZero(int n, int *x, int ...
C
#include <stdio.h> #include <stdlib.h> void read(char *filename, FILE *rfp, FILE *wfp); void write(char * filename, char c, FILE *wfp); int main(void) { char file[30]; printf("Enter the css file name you want to format with: (include the .css) "); scanf("%s", file); //char file[] = "app.min.css";...
C
/************************************************************************** * cryptofile.c * * 4096/B7B720D6 "Kyle Isom <coder@kylesiom.net>" * * 2011-01-08 * * ...
C
#include "holberton.h" /** * _puts - prints a string then a line feed * @s: the string to print */ void _puts(char *s) { char *sub; for (sub = s; *sub; sub++) _putchar(*sub); _putchar('\n'); }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* find_alias.c :+: :+: :+: ...
C
#include "../include/shell.h" // filedes[0] предназначен для чтения, а filedes[1] предназначен для записи. static int check_redir(char **args, int f) { int i; i = -1; while (args[++i]) { if (equals(args[i], ">") || equals(args[i], ">>")) { g_gl.flagf = 1; return (0); } else if (equals(args[i], "<...
C
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include "poly_mul.h" extern void polymul_asm(uint16_t *r, const uint16_t *a, const uint16_t *b); void pol_mul(uint16_t* a, uint16_t* b, uint16_t* res, uint16_t p, uint32_t n) { uint32_t i; uint16_t c[2*n - 1]; polymul_asm(c, a, b); for (i =...
C
//#include <stdio.h> // //int main() //{ // int i1; // printf("%lu\n", sizeof(i1)); // i1 = 2147483647;//2^31-1 // printf("%d\n", i1); // // short int i2; // printf("%lu\n", sizeof(i2)); // i2 = 32767;//2^15-1 // printf("%hd\n", i2); // // long int i3; // printf("%lu\n", sizeof(i3)...
C
#include <stdio.h> void main() { int i,j,sayi; printf("Sayi giriniz "); scanf("%d",&sayi); for(i=1;i<=sayi;i++) { printf("%d\t",i); for(j=1;j<=i;j++) { printf("%d",i); } printf("\n"); } getch(); }
C
#include "task_lib.h" tcb_t tcb[MAX_TASKS]; /** * @brief Scheduler update * @param void * @retval void */ void sch_update(void) { uint8_t index; for (index = 0; index < MAX_TASKS; index++) { /* Check if there is a task at this location */ if (tcb[index].p_tack_cb) { ...
C
/* Casting data types */ #include <stdio.h> #include <stdlib.h> void main (void) { int a = 1; /* one data type can be cast as another using (new type)variable */ printf("Print integer as float: %f\n", (float)a); /* Output: => Print integer as float: 1.000000 */ exit(0); }
C
#include <stdio.h> #include <stdlib.h> int valorMaximo(int* arr){ int valorMax = 0; int valorActual = *(arr); if( *(arr) != 0){ valorMax = valorMaximo(arr+1); if(valorMax == 0){ return valorActual; } if(valorActual > valorMax){ return valorActual; ...
C
// ------------------------------------------------------------------------------------------------ // string.h // ------------------------------------------------------------------------------------------------ #pragma once #include "stdlib/types.h" void *memset(void *s, int c, size_t n); void *memcpy(void *dst, co...
C
#include<stdio.h> int main () { int a[]={10,2,4,15,35,46,85}; int value,pos=-1,i; printf("Enter the value:"); scanf("%d",&value); for(i=0; i<7; i++) { if(value==a[i]) { pos=i+1; break; } } if(pos==-1) { pr...
C
#include<stdio.h> #include<math.h> int main() { int start, first, second, end; while (scanf("%d%d%d%d", &start, &first, &second, &end) != EOF){ int degree = 1080, scale = 9; if (start == 0 && first == 0 && second == 0 && end == 0){ break; } else{ degree = degree + ((40 + (start - first)) % 40) * 9; d...
C
// Author: Robert H. Lee // Created: Fall 2015 // Here we use allgatherv to fill only part of the blocks corresponding to each // process. This is useful when we want to overlap computation and // communication. If computation is required to produce the block of data that // needs to be allgathered, we can compute a...