language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> #include <stdlib.h> #include "LinkedList.h" #include "Controller.h" #include "Employee.h" int menu(); int main() { LinkedList* listaEmpleados = ll_newLinkedList(); char salir='n'; do { switch(menu()) { case 1: system("cls"); if(ll_is...
C
/*question 9*/ /*find centre,radiusand area of intersection of plane and sphere * plane a*x+b*y+c*z+d=0 * sphere x*x+y*y+z*z+e*x+f*y+g*z+h=0*/ #include<stdio.h> #include<math.h> void main() { float a,b,c,d,e,f,g,h,j,k,l,m,r,p,q; printf("the value of a,b,c,d,e,f,g,h"); scanf("%f%f%f%f%f%f%f%f",&a,&b,&c,&d,&e,&f,&g,&h)...
C
/* ** еԪ,ʹȫǰ,żȫں */ #define _CRT_SECURE_NO_WARNINGS #include "stdio.h" #include "stdlib.h" #define LEN 11 int arr_new[LEN] = { 0 }; /*---ӡ---*/ void arr_display(int arr[]) { for (int i = 0; i < LEN; ++i) { printf("%-3d", arr[i]); } printf("\n"); } /*------*/ void modi_arr(int arr[]) { int odd_count = 0; f...
C
#include <sys/wait.h> #include <unistd.h> #include <sys/timeb.h> #include <time.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include "semaphores.h" #include "shared_memory.h" int main (int argc, char* argv[]){ int sem_p1; int sem_enc1; int sem_chan; int sem_p2; //create the sem...
C
#include <stdio.h> #define MAX 100 int op[MAX]; void Show(int *w,int len) { printf("===================================\n"); int i = 0; for(i = 0; i < len; i++) { printf("物品 %d 在第 %d 个船上,重量为 %d\n",i+1,op[i]+1,w[i]); } } void Fun(int weight,int rw,int lw,int *x,int *w,int w1,int w2,int i,...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_parse_fun.c :+: :+: :+: ...
C
/* Write a program that has a global counter that increments every 1 second and the counter resets every time there is a SIGINT signal. SIGQUIT and SIGTERM should be ignored. Remember to manage critical regions in the main loop */ #include <stdio.h> #include <errno.h> #include <stdlib.h> #include <signal.h> #include...
C
#include<mpi.h> #include<stdio.h> #include<string.h> #define comm MPI_COMM_WORLD int main(int argc, char const *argv[]) { int root=0; int a; int rank,size; MPI_Init(NULL, NULL); MPI_Status status; MPI_Comm_rank(comm,&rank); MPI_Comm_size(comm,&size); if (rank==root) { printf("enter a number\n")...
C
/* * Functions in relation to accessing and minimizing * the space consumption of a (unsigned short) */ #include "bitPacking.h" void packBits(unsigned short *toPack, int packSize, LeftOver *LO) { unsigned short mask = 0; unsigned short prev_LO = LO->data; /*& ((1 << LO->size) -1);*/ int LO_prevSize = LO->s...
C
#include <stdio.h> typedef struct point { int x; int y; } P; int main() { P p; p.x = 10; p.y = 20; printf("%d, %d", p.x, p.y); return 0; }
C
#include<stdio.h> #include<stdlib.h> #include<limits.h> #include "./PES1UG19CS393_H.h" //utility function to setup and return a graph struct ptr graph* createGraph(int V) { graph* new = (graph*)malloc(sizeof(graph)); new->v = V; new->array = (list*)malloc(V * sizeof(list)); for (int i = 0; i < V; +...
C
/* * Delta programming language */ #include "DeltaInstruction.h" #include "delta/compiler/compiler.h" struct DeltaInstruction new_DeltaInstruction0(char *name, DeltaByteCode bc) { struct DeltaInstruction d; d.func = name; d.bc = bc; d.args = 0; d.arg = NULL; return d; } struct DeltaInstruction new_Delta...
C
#ifndef _UILOW_H #define _UILOW_H enum uilow_ret { UI_OK, UI_ERR }; typedef unsigned int uilow_chtype; // Low-level UI functions /// Initialize the low-level UI void uilow_init(void); /// Deinitialize the low-level UI void uilow_end(void); /// Move to a position on the display enum uilow_ret uilow_move(int y, int ...
C
/* * tcpechosrv.c - A concurrent TCP echo server using threads */ #include <stdio.h> #include <stdlib.h> #include <string.h> /* for fgets */ #include <strings.h> /* for bzero, bcopy */ #include <unistd.h> /* for read, write */ #include <sys/socket.h> /* for socket use */ #include <signal.h> /* for sig...
C
/* * lcd.h * * Created on: Sep 4, 2019 * Author: Joseph Hanna */ #ifndef LCD_H_ #define LCD_H_ #include <avr/io.h> #include <util/delay.h> /* Set a certain bit in any register */ #define SET_BIT(REG,BIT) (REG|=(1<<BIT)) /* Clear a certain bit in any register */ #define CLEAR_BIT(REG,BIT) (REG&=(~(1<<BIT...
C
#include <string.h> #include "hecdssInternal.h" #include "heclib.h" /** * Function: getDateAndTime * * Use: Public * * Description: Returns the date and time from params in a time series struct. * * Declaration: int getDateAndTime(int time, int timeGranularitySeconds, int julianBaseDate, char *dateString...
C
# Description ====================================================================================================================================== Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last word does not exist, retu...
C
//switch #include <cs50.h> #include <stdio.h> int main (void) { // Promt user for ancwer char c = get_char(" G(g) or N(n): "); char c2 = get_char("G(g) or N(n): "); // Check answer switch (c) { case 'n': case 'N': printf("Никита\n"); break; case 'G': case '...
C
#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> #include <assert.h> size_t my_strlen(const char* str) //ָΪԪظ { assert(str != NULL); char *p = str; while (*p != '\0') { p++; } return p - str; } //size_t my_strlen(const char* str) //ʱ //{ // assert(str != NULL); // if (*str == '\0') // return 0; // el...
C
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> void swap(int* a, int* b) { int temp; temp = *a; *a = *b; *b = temp; } int main() { int a = 0; int b = 0; printf("֣"); scanf("%d %d", &a, &b); swap(&a, &b); printf("a = %d b = %d", a, b); system("pause"); }
C
#include <stdlib.h> #include <stdio.h> #include <errno.h> #include <assert.h> #ifndef QUEUE_Q_H #define QUEUE_Q_H typedef struct Item { int val; struct Item *prev; struct Item *next; } Item; typedef struct Queue { Item *head; Item *tail; } Queue; void PrintAction(char *act, Item *item) { if ...
C
/*PROGRAM TO FIND SUM OF DIGITS OF A GIVEN NUMBER*/ #include<stdio.h> void main() { /*declaring variables*/ int i,n; int sum=0, temp; printf("enter a number to find sum of its digits\n"); scanf("%d",&n); while(n!=0){ temp=n%10; sum+=temp; n=n/10; } printf("sum of the digits of a given number is%d...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* parse_types.c :+: :+: :+: ...
C
#include <math.h> #include <stdint.h> float fabsf(float x) { union { float f; uint32_t i; } u = {x}; u.i &= 0x7fffffff; return u.f; }
C
#include <stdio.h> #include <assert.h> #include "mil.h" #define STACK_SIZE_MAX (65536) typedef enum { INT_VALUE_TYPE, STRING_VALUE_TYPE } ValueType; typedef struct { ValueType type; union { int int_value; char *string_value; } u; } Value; static Value st_stack[STACK_SIZE_MAX]; static Value st_vari...
C
/* * File: file_reader.h * * Brief: Simple file reader utility that provides an easy and intuitive way to * load a file's contents into memory. * * LICENSE: MIT * * Author: Alexander DuPree * * https://github.com/AlexanderJDupree/File_Reader */ #ifndef FILE_READER_H #define FILE_READER_H #include ...
C
//-ӡ100-200֮ #include<stdio.h> #include<math.h> int aaa(int pi) { int j = 0; for (int j = 2; j <= sqrt(pi); j++) { if (pi % j == 0) return 0; } return 1; } int sum = 0; int main() { //ӡ100-200֮ int i = 0; for (int i = 100; i < 200; i++) { if (aaa(i) == 1) { prin...
C
#include<stdio.h> #include<stdlib.h> #define COMPARE(x,y) ((x) < (y)? -1: ((x)==(y))? 0:1) void sort(int *arr1, int n); int BinarySearch(int arr1[],int searchnum, int left, int right); void main() { FILE *fin=fopen("input.txt","rt"); FILE *fout=fopen("ouput.txt","wt"); int *arr1; int i,n,m; int left,right; f...
C
/** * \file fenetre.c * \brief Implémente les fonctions de fenetre.h * \author Pauline.M * \version 1.0 * \date 01 mai 2019 * * Implémente les fonctions utiles à l'affichage du jeu. */ #include "fenetre.h" #include <SDL.h> #include <SDL_ttf.h> #include <stdio.h> #include <stdlib.h> #include "developpement.h" #...
C
#include <libsystem/Assert.h> #include "kernel/node/Connection.h" #include "kernel/node/Socket.h" static FsNode *socket_openConnection(FsSocket *socket) { FsNode *connection = fsconnection_create(); list_pushback(socket->pending, fsnode_ref(connection)); return connection; } static bool socket_FsNodeCa...
C
/**************************************************************** **** **** This program file is part of the book **** `Parallel programming with MPI and OpenMP' **** by Victor Eijkhout, eijkhout@tacc.utexas.edu **** **** copyright Victor Eijkhout 2012-7 **** **** OpenMP Exercise **** ***********************...
C
// uthash.c #include <string.h> /* strcpy */ #include <stdlib.h> /* malloc */ #include <stdio.h> /* printf */ #include <assert.h> #include "uthash.h" const int MAX_DATA = 12000000; struct kv { char *key; double val; UT_hash_handle hh; }; char i2ch[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'B...
C
#include <stdio.h> #include <string.h> #define INPUTMAX 20 #define OUTPUTMAX 40 void convert_string(char [INPUTMAX+1],char [OUTPUTMAX+1]); int main(void){ char str[INPUTMAX+1]; char dest[OUTPUTMAX+1]; int len; printf("Enter the input: "); fgets(str,INPUTMAX+1,stdin); len = strlen(str); if (str[len-1] == '\n') s...
C
#include<stdio.h> #include<string.h> int main(void) { int x,z; char word[40]; printf("请输入一个单词\n"); scanf("%s",word); x=strlen(word)-1; for(z=x;z>=0;z--) printf("%c",word[z]); printf("\n"); return 0; }
C
#include<stdio.h> int ref_bias_fp32(float* in_data, float* out_data, float* bias, int size, int channels, float scale, int zero_point) { for(int c = 0; c < channels; c++){ float* out_ptr = out_data + c*size; float* in_ptr = in_data + c*size; for(int i = 0; i < size; i++) { ...
C
/**************************************************************************** Description: Program to test shared memory using mmap in this program parent and child shares ptr. It is to show how shared memory is shared between parent and child. comment semaphore functions and run with 1000 times l...
C
#include "../SequStack.h" #include <stdio.h> Status PrintChar(SElemType e); //遍历函数的功能函数,打印字符 void LineEdit(char back, char clear); //行编辑 Status PrintChar(SElemType e) { printf("%c", e); return OK; } void LineEdit(char back, char clear) { SqStack stack; char ch; SElemType e; InitStack(&stack); do { ch = getc...
C
/* Include-file defining data types used by message subsystem */ #ifndef __MESSAGES__ #define __MESSAGES__ #include "global.h" /* ---------------------------------------------------------------- */ /* Declarations of global variables declared for messages */ /* ---------------------------------------------------...
C
# include <stdlib.h> # include <stdio.h> # include <string.h> /* * See ../README.md */ /* * Run as: cc -o ch-2.o ch-2.c; ./ch-2.o < input-file */ # define DIFF_PER_MINUTE 11 /* Half degrees */ # define MIN_PER_HOUR 60 # define FULL_CIRCLE 720 /* Half degrees */ int main (void) { int hours, minu...
C
#include <stdio.h> void recursive(int n) { if(n!=1) recursive(n-1); printf("%d\n", n); } int main() { recursive(5); return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #define MAXINPUT 100 typedef struct node { int val; struct node * next; } node_t; int is_number(char* str) { int result = 1; int length; length = strlen(str); for (int i = 0; i < length; i++) if (!isdigit(str...
C
#include<stdio.h> int heap_k=-1; void addnode(int*,int, int**); int ExtractMin(int*, int**); void adjust_heap(int*, int**); void addnode(int* heap, int node, int** mat) { heap_k++; int child=heap_k; int parent=(child-1)/2; while(child>0 && PTY(heap[parent])<PTY(node)) { heap[child]=heap[parent]; ...
C
struct Gsymbol* GLookup(char * name) { struct Gsymbol *temp=Ghead; while(temp!=NULL) { if(strcmp(name,temp->name)==0) return temp; temp=temp->next; } return NULL; } void GInstall(char *name, struct Typetable *type,struct Classtable *cptr,int size,int s2,struct Paramstruct *paramlist) { if(GLookup(name)!=...
C
#include <stdio.h> #include <regex.h> #include<string.h> /** *下载地址: *https://sourceforge.net/projects/gnuwin32/files/regex/2.7/(regex-2.7-bin.zip) *下载完包解压后: *将lib中的libregex.dll.a和libregex.la放进MinGW的lib目录,将regex2.dll放进程序所在目录。 * *libraries 要添加配置regex *动态链接库文件regex2.dll需要放在exe文件下面 */ int main9() { // regex(); reg...
C
#include <stdio.h> #include <time.h> int main(void){ enum Week {sun, mon, tue, wed, thu, fri, sat}; enum Week today; struct tm *p; time_t t; time(&t); p = localtime(&t); today = p -> tm_wday; switch(today){ case mon: case tue: case wed: case thu: ...
C
//https://github.com/hzyitc/armbian-onecloud/issues/52 #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <fcntl.h> #include <sys/types.h> #include <sys/mman.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/select.h> #include <pthread.h> #include <unistd.h> #include <sc...
C
/* * 20134220 Jeong hyun, Woo * BasicUDPServer.c */ #include <sys/socket.h> #include <sys/stat.h> #include <arpa/inet.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <ctype.h> #include <time.h> #include <signal.h> #define MAXBUF 2048 #define PORT 24220 void sigHandler(i...
C
/* ʵ4-2-6 ַ 15 ֣ ҪдnɴдĸAʼɵַС ʽ һиһn1n<7 ʽ nɴдĸAʼɵַСʽÿĸ涼һո 4 A B C D E F G H I J */ #include<stdio.h> #define return return int main() { char c ='A'; int N; scanf("%d",&N); for(int i=0;i<N;i++){ for(int j=i;j<N;j++){ printf("%c ",c); c++; } printf("\n"); } return 0; }
C
//注册已知文件系统的GUID. #include <filesystem/filesystem.h> #include <filesystem/fhhfs.h> #include <memory/memory.h> #include <drivers/devicetree.h> #include <common/printk.h> //根目录设备文件的设备树地址。 char g_root_device_path[64]; const GUID* g_registered_filesystems[] = { &FzOS_ROOT_PARTITION_GUID }; int (*registered_filesystem_m...
C
/* ** get_side.c for function to know the orientation of a wall in /home/gaspar_q/rendu/Igraph/MUL_2014_wolf3d ** ** Made by quentin gasparotto ** Login <gaspar_q@epitech.net> ** ** Started on Sat Dec 13 10:42:40 2014 quentin gasparotto ** Last update Sat Dec 20 14:28:03 2014 quentin gasparotto */ #include <math....
C
/* C program to remove spaces from a string */ #include<stdio.h> void remove_white_spaces(char *str) { int i = 0, j = 0; while (str[i]) { if (str[i] != ' ') str[j++] = str[i]; i++; } str[j] = '\0'; puts(str); } int main() { char str[50]; printf("\n\t Enter a string : "); fgets(str,20,stdin);...
C
#include <stdio.h> int main() { int n=4,i,j,c=10; for(i=0;i<n;i++) { printf("\n"); //salto de linea para cada renglon for(j=i;j<n-1;j++) printf(" "); //espacios for(j=i;j>0;j--)//numeros printf("%d",c-j); printf("%d",c); //cifra columna for(j=1;j<i+1;j++)//numeros printf("%d",c-j); ...
C
/* Author:- KARSHIL SHETH Objective:-TO PERFROM THE MULTIPLICATION OF A MATRIX. Date:- 11-02-2018 */ void main() { int i,j,a[3][3],b[3][3],d,c[3][3],k; clrscr(); printf("\n Enter 1st matrix of 9 elements : \n"); for(i=0;i<3;i++) { for(j=0;j<3;j++) { scanf("%d",&a[i][j]); } } ...
C
#include<stdio.h> void main() { int data[10],j; printf("Enter 4 bits of data one by one\n"); scanf("%d",&data[3]); scanf("%d",&data[5]); scanf("%d",&data[6]); scanf("%d",&data[7]); //Calculation of parity bits data[1]=data[3]^data[5]^data[7]; //P1 = D3 D5 D7 printf("Parity Bit at P1 %d\n",data[1]); data[2]...
C
/* ADS1115_sample.c - 12/9/2013. Written by David Purdie as part of the openlabtools initiative Initiates and reads a single sample from the ADS1115 (without error handling) edited by Zach Richard to work with the TRAPSat Custom IO board for the RockSat-x 2016 mission. * changed address to 0x49 (previously 0x48)...
C
/*- * Licensed under the SPDX BSD-2-Clause identifier. * Use is subject to license terms, as specified in the LICENSE file. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <errno.h> #include <unistd.h> #include <getopt.h> #include <xbps.h> static void __attribute__((nor...
C
/* * util.c * * Created on: Sep 5, 2019, 11:46:19 AM * Author: Joshua Fehrenbach */ #include "util.h" #include <string.h> #include <ctype.h> #include <dirent.h> #include <sys/stat.h> static const unsigned char * const binary_alphabet = (const unsigned char*)"01"; static const unsigned char * const octal_al...
C
#include<stdio.h> #define MAX 5 typedef int tVector[MAX]; tVector vector; float sumarVector(tVector, int); int main( ){ vector [0]=10.50; vector [1]=2.50; vector [2]=12.50; vector [3]=5.20; vector [4]=32.10; printf("suma es: %.2f", sumarVector(vector, 0)); return 0; } float sumarVector(tVector pVector, int i){...
C
/************************************************************************** * SHA1 declarations **************************************************************************/ #define SHA1_SIZE 20 /** * This structure will hold context information for the SHA-1 * hashing operation */ typedef unsigned long uint3...
C
#include <stdio.h> #include <stdlib.h> // malloc #include <string.h> // memset #include <stdint.h> // uintxx_t types #include <fcntl.h> // open #include <unistd.h> // write #define WIDTH 100 #define HEIGHT 160 int main (int argc, const char * argv[]) { uint8_t * bitmap = NULL; uint8_t * p = NULL; uint32_t counter ...
C
#include <stdio.h> #include <string.h> #include <assert.h> #include <stdlib.h> #define MAX_CHAR_NUM 26 #define MAX_KEY_WORD 36 char freq_of_char[MAX_CHAR_NUM] = {0}; static char *static_site[] = {"do", "end", "else", "case", "downto", "goto", "to", "otherwise", "type", "while", "const", "div", "and"...
C
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <unistd.h> #include "utilities.h" #include "powerbag.h" #include "seriesoperation.h" void *workerWrapper(void *p_voidedbag); void workerOptimization(PowerBag *p_bag); int main(int argc, char *argv[]) { int code = 0, initialRuns, activeWorkers, sch...
C
/* * This file implements enrichment from an arbitrary, custom enrichment * channel parameterized by the user in VICE singlezone simulations. */ #include <stdlib.h> #include "../singlezone.h" #include "../callback.h" #include "../channel.h" #include "../utils.h" #include "channel.h" /* * Determine the rate of ma...
C
#include "holberton.h" /** * _strlen_recursion(:)? (- leng)? * * @s: input char * Return: a */ int _strlen_recursion(char *s) { if (*s != '\0') { int a = 0; a += 1; return (a + _strlen_recursion(++s)); } else return (0); }
C
/* * err.c * * Created on: Jul 28, 2019 * Author: jan */ #include "err.h" void error(char* msg){ fprintf(stderr, "%s: %s\n", msg, strerror(errno)); exit(1); }
C
#include "common.h" /* The plaintext case for I/O is really easy. Call the openssl BIO_* functions and return. */ /*********************************************************************************************************************** * * remote_read_plaintext() * * Input: A pointer to our remote_io_helper obje...
C
#ifndef LIST_H_ #define LIST_H_ struct list { void* value; struct list* rest; }; typedef void (*list_for_each_fn)(void* obj, void* value); void list_init(struct list* self, void* value, struct list* rest); struct list* list_new(void* value, struct list* rest); void list_for_each(struct list* self, list_for_ea...
C
/* mpd_signbit -- Signbit of a MPD number */ #include "mpd-impl.h" int mpd_signbit (mpd_srcptr x) { if (MPD_CLASS(x) == MPD_CLASS_NEG_ZERO) { MPD_RET(-1); } if (MPD_CLASS(x) == MPD_CLASS_POS_ZERO) { MPD_RET(1); } MPD_RET(MPD_SIGN(x)); }
C
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> int main() { int t; scanf("%d",&t); while(t--) { int i,n,a[100000],sumc=0,flag=0,sumnc=0,max=0; scanf("%d",&n); for(i=0;i<n;i++)scanf("%d",&a[i]); for(i=0;i<n;i++) { if(a[i]<0)flag=1; ...
C
#include "PID.h" /* The parameters that we will use is: goal_rpm -> the input of the user. local variable at GUI.c curr_rpm -> it 120000/freq. we measure it and we can not change it. goal_dutycycle -> we don't have this parameter. it is unkown and "curr_dutycycle" will reach that by iteration curr_dutycycle -> we c...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <SDL.h> #include "util-graphics.h" Uint32 get_pixel32( SDL_Surface *surface, int x, int y ) { //Convert the pixels to 32 bit Uint32 *pixels = (Uint32 *)surface->pixels; //Get the requested pixel return pixels[ ( y * surface->w ...
C
// El siguiente codigo se realizo con la guia del siguiente tutorial: https://www.youtube.com/watch?v=fNerEo6Lstw&feature=youtu.be #include <stdio.h> #include <stdlib.h> #include <string.h> #include <signal.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/ine...
C
#include<stdio.h> void main() { int a[10]; int i=0; printf("Enter the array elements(value should not be more than 5): "); for(i=0;i<5;i++) scanf("%d ",&a[i]); int b[10]; for(i=0;i<10;i++) { if(b[a[i]]<0) { printf("Duplicates exist %d !!!",a[i]); return; ...
C
#include <pthread.h> #include <stdio.h> #include <stdlib.h> #define NUM_THREADS 7 void *PrintThread(void *id) { long idt; idt = (long) id; printf("Thread %ld\n", idt+1); pthread_exit(NULL); } void CallThread(long nt, pthread_t *t){ int rc; rc = pthread_create(t, NULL, PrintThread, (void *) nt); ...
C
#include <stdio.h> #include <conio2.h> #include <stdlib.h> #include <windows.h> // Definioes de movimentao da cobra #define LIMITE_COBRA 101 #define CIMA 80 #define BAIXO 72 #define DIREITA 77 #define ESQUERDA 75 #define ESC 27 #define CABECA 0 #define CAUDA 1 #define POS_INICIAL_CABECA 3 #define POS_IN...
C
#include <stdio.h> void print(int n); int main() { int n; printf("Enter the value of n: "); scanf("%d", &n); print(n); return 0; } void print(int n){ int ans =0; int i=1; for(int j=0;j<n;j++){ ans = ans + (i*i); i=i+2; } printf("Sum of first %d numbers is %d",n,...
C
#include <stdarg.h> #include <stddef.h> #include <setjmp.h> #include <cmocka.h> int __wrap_getchar(void) { return (int)mock(); } #define BOOLEAN int #define FALSE 0 #define TRUE 1 int get_word(char *s, int len_max, BOOLEAN b_print); void test_get_word_hello (void ** state) { char word[256] = {0}; will...
C
/* CP05_13.C */ /* Testing Associativity of unary operator */ #include<stdio.h> #include<conio.h> void main() { int x = 10; printf("\n x = %d ++x = %d x = %d",x, ++x, x ); getch(); }
C
#include <stdio.h> void ft_div_mod(int a, int b, int *div, int *mod); int main() { int div = 0; int mod = 0; int a = 11; int b = 4; ft_div_mod(a, b, &div, &mod); printf("Quotient de (%d modulo %d) = %d", a , b, div); printf("\nReste de (%d modulo %d) = %d\n", a, b, mod); return 0; }
C
// // Created by Mookel on 16/9/6. // Email : ltp0709@sina.com // Copyright (c) 2016 jlu.edu. All rights reserved. // dfa.c : // #include <compiler.h> #include "globals.h" #include "dfa.h" #include "terp.h" #include "print.h" typedef struct _DFA_STATE{ unsigned group: 8; /*group id, used by minimize*/ uns...
C
#include <stdio.h> #include "error.h" #include "instruction.h" //! Forme imprimable des codes oprations const char *cop_names[] = { "ILLOP", //!< Instruction illgale "NOP", //!< Instruction sans effet "LOAD", //!< Chargement d'un registre "STORE", //!< Rangement du contenu d'un registre "ADD", //!< Addition un ...
C
/* -------------------------------- MarkdownLatex markdownlatex.c -------------------------------- Copyright 2014 Jacob Causon Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the Lic...
C
/************************************************************************* > File Name: 8-1.c > Author: chendi > Mail: chendi1995425@gmail.com > Created Time: 2014年07月24日 星期四 11时10分22秒 ************************************************************************/ #include<stdio.h> #include<errno.h> #inclu...
C
#include<stdio.h> #include<string.h> typedef struct{ int s,f; } Tile; int N,M,flag,taken[20]; Tile T[20],tArr[20]; void swap(int *a,int *b){ int tmp; tmp=*a; *a=*b; *b=tmp; } int isValid(Tile tmp,int i){ if(tArr[i-1].f==tmp.s){ tArr[i]=tmp; return 1; } else if(tArr[i-1].f==tmp.f && i!=N+1){ ...
C
#include <stdio.h> int main(void) { char arr[] = "Hello, Wolrd!"; char str[100]; int len, i; char *p; len = sizeof(arr); p=arr+len -2; for(i=0; i<len-1; i++){ str[i] = *p--; } printf("%s\n", arr); printf("%s", str); }
C
#include <stdio.h> /* */ /*ϸμ round.h*/ /* */ /* FxΪҪFyΪҪ뵽Сǰλ : F_round(3.1415926,0.3); ˼Ϊ3.1415926뵽С3λ F_round(3141592.6,3.0); ˼Ϊ3141592.6뵽Сǰ3λ */ /* bug!!! Сֻܵ6λ ԭʱδ֪ 2019/10/29 */ double D_round(double Dx, double Dy) { long long array[11] = {1, 10, 100, 1000...
C
#include <stdlib.h> #include <string.h> #include "disemvowel.h" #include <stdio.h> int isval(char *str1) { int len; char *result; int a; a = strlen(str1); len = 0; result = str1; for (int i = 0; i < a; i++){ if (result[i] == 'a' || result[i] == 'e' || result[i] == 'i' || result[i] == 'o' || result[i] ...
C
#include<stdio.h> #include<string.h> #include"inode_test.h" typedef unsigned int u32; #define PAGE_SIZE 4096 #define DIR_LEN 20 #define O_RD (1 << 0) #define O_RDWR (1 << 1) #define O_CREATE (1 << 2) #define O_DEL (1 << 3) union dir_block { struct dir_entry d[20]; char b[PAGE_SIZE]; }; union first_block{ struct s...
C
/* ITS240-01 Lab 01 Ch5p236pe8 02/08/2017 Daniel Kuckuck refer to the book: Book Identification #; Inventory Balance at begining of month; Number of copies receieved during the month; Number of copies sold during month. Use a while loop so only 3 books are requested. Output should be: New Balance = Inven...
C
// // mysh.c // P2 // // Created by Terry Shao on 2/8/14. // Copyright (c) 2014 Terry Shao. All rights reserved. // #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <string.h> #include <limits.h> #include <sys/types.h> #include <sys/wait.h> #include <errno.h> #define SEQUENT...
C
/* the answer is 983 */ //2014.11.23// /* 1000以下の自然数nにおいて 1 / n の巡回節は最高で n - 1桁となる。 10^m - 1 を割り切ることができればそのnの巡回節はm桁となる。 */ #include<stdio.h> #include<math.h> int main(void){ int i,cycle,maxCycle = 0,Remainder; for(i = 3; i < 1000; i += 2){ Remainder = 0; cycle = 1;//1にしないと結果が合わない 理由は不明 if(i % 5 == 0) i...
C
///Programa de evolución de un sistema ferromagnético en función de la temperatura (Ising) # include <stdio.h> # include <math.h> # include "gsl_rng.h" //Librería para generación de números aleatorios para compilar un programa //con la librería anterior de números aleatorios tengo que añadirle al comando //de compilaci...
C
/****************************************************************************** * File : Main program * Author : VNP02 *****************************************************************************/ //#include "stm32f0xx.h" #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string....
C
#include "AST.h" ////////////////////////////////// // I/O Interface ostream& operator <<(ostream &o, const ASTExpression &a) { // Concatenates an ASTExpression object to an ostream. // // This works by delegating the job back to the ASTExpression node. a.ASTPrint(o); return o; } ///////////////////////...
C
#include <stdio.h> int main() { char names[][10] = {"jeetendra", "atharva"}; char *ptr = &names[0][0]; char (*ptr1)[10] = &names[0]; for(int i = 0 ; i < 2 ; i++) printf("%s %s\n", ptr++, *ptr1++); }
C
#include <msp430.h> #include "switches.h" #include "led.h" #include "buzzer.h" #include "stateMachines.h" char switch1_state, switch2_state, switch3_state, switch4_state; char switch_state_changed; /* effectively boolean */ switch_state = 0; static char switch_update_interrupt_sense() { char p2val = P2IN; /* updat...
C
/* mechanics.h * * */ #ifndef MECHANICS_H #define MECHANICS_H #include "lpc_types.h" #define PI 3.14159265 // Pi #define MIDDLE_SENSOR 0 // Middle sensor #define RIGHT_SENSORS 1 // Right sensors #define LEFT_SENSORS 2 // Left Sensors #define FRONT_ANALOG 3 // Analog sensor in the front #define LEFT_F_ANALOG 2 /...
C
#include <stdio.h> #include <GL/glut.h> void display(void){ glClear(GL_COLOR_BUFFER_BIT); glFlush(); } void resize(int w, int h){ glViewport(0,0,w,h); glLoadIdentity(); } void mouse(int button, int state, int x, int y){ switch(button){ case GLUT_LEFT_BUTTON: printf("left"); ...
C
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <sys/mman.h> int ecc(const uint32_t *words, size_t count) { int bit, ecc; uint32_t word, i; bit = 0xff00; ecc = 0; while (count--) { word = *words++; for (i ...
C
#include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #define LONGITUD_CADENA 30 /// 30 bytes -- 240 bits (Por palabra), "cambiar para cadenas mas largas" /* * Ejercicio con cadenas * a. Convertir cadenas a minusculas * b. Convertir cadenas a mayusculas * c. Contar vocales de cadena * d....