language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
//Number 2 in Review //Make a recursive Fibonacci #include <stdio.h> int Fibonacci(int num) //Code that takes in n and returns the "nth" Fibonacci number { int value; if(num == 0)//Base Case { value = 0; } else if (num == 1) { value = 1; } else //General C...
C
#include<stdio.h> #include<stdlib.h> int main() { int i,n,T,count=0; char line[100000]; char *p,*e; long int input; printf("T = "); scanf("%d",&T); for(i=1;i<=T;i++) { printf("Enter the string value: "); scanf(" %[^\n]",&line); //printf("string value: %s\n",lin...
C
#include <stdio.h> #include <stdlib.h> // Programa REF_009_ifs_3 /* Este programa avalia uma nota de exame consoante as seguintes condies: se nota >= 9.5, "Aprovado" se nota >= 8.0 e nota < 9.5, "Oral" se nota >= 0 e nota < 8, "Reprovado" Se nota fora dos valores ente 0 e 20, Valor da ...
C
// // main.c // BeerSong // // Created by Gabe on 10/12/14. // Copyright (c) 2014 Gabe Snyder. All rights reserved. // #include <stdio.h> void singSongFor(int numberOfBottles) { if (numberOfBottles == 0) { printf("There are simply no more bottles of beer on this wall!\n\n"); } else { print...
C
#include<assert.h> #include<stddef.h> #include "adjacentab.h" #include "bitops.h" void init_adjacent_table(adjacent_table_t * table, unsigned int size) { assert(size <= NODE_POOL_SIZE_MAX); table->size = size; } void init_adjacent_table_node_pool(adjacent_table_node_pool_t * pool, int size) { assert(si...
C
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> struct Item { struct Item *next; float data; }; typedef struct { struct Item *node; } Iterator; bool Equal(Iterator *lhs, Iterator *rhs) { return lhs->node == rhs->node; } Iterator *Next(Iterator *i) { i->node = i->node->next; retur...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include "size_types.h" #include "sess_anal.h" void read_app_map(sess) SESSION *sess; { si1 *app_map_dir, app_map_path[256]; si4 i, area, dummy; FILE *fp; ui1 *am; extern si1 *get_env_var(); void bad_app_file(), bad_app_file2(); app_map_dir = ge...
C
// Assignment #2 USE TEXT FILE LDB.txt TO TEST CODE #include <stdio.h> #include <stdlib.h> #include <math.h> #define SIZE 4800 typedef struct sensor_str{ double x[SIZE]; double y[SIZE]; double z[SIZE]; }sensor_data; sensor_data data; /*--------------------------------...
C
/************************************************************************* > File Name: recv_xml.c > Author: qxs> Mail: qxs2222@163.com > Created Time: 2014年06月12日 星期四 11时25分04秒 ************************************************************************/ #include"server.h" xmlChar* recv_xml(int server_socket) { char ...
C
/* * SPDX-License-Identifier: ISC * * Copyright (C) 2017-2021 Michael Drake <tlsa@netsurf-browser.org> */ /** * \file * \brief CYAML common utility functions. */ #ifndef CYAML_UTIL_H #define CYAML_UTIL_H #include "cyaml/cyaml.h" #include "utf8.h" /** Macro to squash unused variable compiler warnings. */ #def...
C
#include "BioData.h" using namespace std; BioData::BioData(){} BioData :: BioData (const string& fileName) { checkNumberOfColumns(fileName); setData(fileName); } BioData :: BioData (const string& fileName, const int& xCol,const int& yCol) { checkNumberOfColumns(fileName); setData(fileName, ...
C
#include "lists.h" /** * _reverse_listint - reverse a linked list (helper function) * @current: a pointer to the first node * * Return: a pointer to the first node of the reversed list */ listint_t *_reverse_listint(listint_t *current) { listint_t *tail; if (!current) return (NULL); tail = _reverse_listint...
C
#include "Charges.h" const double TwoSpecial = 0.05; const double ThreeSpecial = 0.10; const double FourSpecial = 0.15; const double FiveSpecial = 0.20; const double Music_Mantinee = 88.00; const double Music_Evening = 175.00; const double Theatre_Matinee = 78.00; const double Theatre_Evening = 165.00; const double ...
C
#include <stdio.h> int main(int argc, char *argv[]){ int values[]={5,6,8,7,9}; int index; int *ptr; ptr=values; char str[]="Hello World"; char *cptr; cptr=str; for(index=0;index<5;index++){ printf("values: %d ",*(values+index)); } printf("\n"); for(index=0;index<5;index++){ ...
C
#include <stdio.h> void main (){ //3º problema: desenvolva um programa que leia o salário bruto de 15 funcionários de uma empresa, calcule e exiba o salário líquido de cada funcionário. Lembre-se que o salário líquido é calculado abatendo o imposto do salário bruto, com base nesta tabela de imposto. Ao final, mostr...
C
#include <stdio.h> struct s_teacher { long number; char name[20]; int age; }; struct s_student { struct s_teacher nested_teacher; long number; char name[20]; int age; int score; }; void print_student_info(struct s_student student); int main() { struct s_student student1 = {{1234,"Kim", 35}, 4567, "Lee", 2...
C
/* * File: reglas.c * Author: Carlos Li Hu */ #include "reglas.h" #define N_COM 10 /*numero de comandos por condición*/ #define DIM 50 /*tamaño palabras*/ #define NUM 40 /*numero consecuencias*/ /** * @BRIEF lee los comandos del fichero y los guarda en una tabla de comandos * cada uno de estos com...
C
/* * Copy sparse file */ #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <fcntl.h> #include <errno.h> #include <linux/fiemap.h> #include <linux/fs.h> #include <linux/types.h> #ifndef BUF_SIZE #define BUF_SIZ...
C
#include <stdio.h> /* 4408. Build a Fence */ int main(){ int x; while(scanf("%d", &x) && x != 0){ printf("%.2lf\n", x * x / (3.1415926 * 2)); } }
C
// Faa um Programa que leia trs nmeros e mostre-os em ordem decrescente. #include<stdio.h> main() { int x, y, z; printf("Digite tres numeros com espacos entre eles: "); scanf("%d%d%d",&x, &y, &z); if ((x >= y) && (y >= z)) { printf("Ordem decrescente: %d %d %d",x, y, z); } else if ((x >= z) && (z >= y)) { ...
C
#include<stdio.h> int main() { int Begin, End, i, j; printf("Begin :"); scanf("%d",&Begin); printf("End :"); scanf("%d",&End); for(i=1 ;i <= 12 ;i++){ for(j = Begin; j <= End; j++){ printf("%2d*%2d=%3d ",j,i,i*j); } printf("\n"); } }
C
#include<stdio.h> /*zNEOɓĂ鐔𕄍AςȂǂ𔻒肵‚”zKEKKAɑĂ*/ void KEISAN(int hugou[9], int NEO[10], int KEKKA[10]) { int a; int b; for (a = 0, b = 0; a < 10; a++) { if (hugou[a] == 1){ KEKKA[a] = NEO[a]; } else if (hugou[a] == 2){ KEKKA[a] = -NEO[a]; } else if (hugou[a] == 3){ KEKKA[a] = KEKKA[a - 1] ...
C
#include <stdio.h> #include <stdlib.h> #define N 100 int main() { int a[N], n, i; scanf("%d", &n); for(i = 0; i < n; i++) scanf("%d", &a[i]); for(i = n - 1; i >= 0; i--) printf("%d ", a[i] * a[i]); exit(EXIT_SUCCESS); }
C
#include <stdio.h> /**biblioteca de escrita e leitura*/ #include <stdlib.h> /**biblioteca auxiliar*/ #define PI 3.1415 /**constante de pr processador*/ int main() { /** Constante A palavra reservada "const" cria posio de memria j a o "define" substitui em tempo de compilao. */ const int nro =...
C
#include<linux/module.h> #include<linux/kernel.h> #include<linux/fs.h> #include<linux/cdev.h> #include<linux/kdev_t.h> #include<linux/types.h> #include<linux/slab.h> //kmalloc and #include<linux/gfp.h> // malloc flage #include<linux/uaccess.h>// copy to/from user struct cdev *mycdev; dev_t device_no; int *kernel...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_next_line.h :+: :+: :+: ...
C
#include<stdio.h> #define MAX 15 #define ARRIVE 0 #define DEPART 1 #include "air_sim.h" void main() { srand(time(NULL)); struct airport a; int i, pri, curtime, endtime; double expectarrive, expectdepart; struct plane *temp; int test; test = randomnumber(0.47); printf("%d"...
C
/* Copyright 2018 Jacques de Hooge, GEATEC engineering, www.geatec.com 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 License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable la...
C
#include<stdio.h> #include<unistd.h> #include<fcntl.h> #define MAX_READ 20 char buff[MAX_READ]; char arr[] = "Enter data: "; int main(int argc, char const *argv[]) { if(write(1,arr,sizeof(arr)) == -1) { printf("Unable to write\n"); } if( read(0, buff, MAX_READ) == -1) { printf("Unable to read \n"); }...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* server_bonus.c :+: :+: :+: ...
C
#include <sys/time.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <fcntl.h> #include <sys/stat.h> #include <unistd.h> int isPrime(int number) { if (number <= 1) return 0; unsigned int i; for (i=2; i*i<=number; i++) { if (number % i == 0) return 0; } return 1; } int ...
C
/* ============================================================================ Description : 结构体赋值 ============================================================================ */ #include <stdio.h> #include <stdlib.h> #include <string.h> //定义结构体类型时不要直接给成员赋值 //结构体只是一个类型,还没有分配空间 //只有根据其类型定义变量时,才分配空间,有空间后才能赋值 typ...
C
#include <termios.h> #include <string.h> #include "v24.h" #include "transfer.h" #include "crc.h" int fd = FDINIT; struct termios oldtio, newtio; unsigned short generate_crc(struct package* paket) { int size_id = sizeof(paket->id); int size_len = sizeof(paket->len); int size_buffer = sizeof(paket->buffer); in...
C
/* Definitions for MTF computer */ typedef struct { double dx; /* grid spacing in meters */ long Nx; /* number of grid points in 1D */ double lambda; /* wavelength in meters */ double **aperture; /* array of complex numbers: (i,j) pixel is aperture[i][2*j] (re), 2*j+1 (im) */ double du; /* grid spacing of MT...
C
#include<stdio.h> void main() { int a[10],count=1,newcount=1,ccount=1,i,j,n; printf("\tenter the size of the array\n"); scanf("%d",&n); printf("\treading elements into the array\n"); for(i=0;i<n;i++) { scanf("%d",&a[i]); } //find the largest number of repeating element for(i=0;i<(n-1);i++) { newcount=1; for(j=i+1;j<n...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* print_int2.c :+: :+: :+: ...
C
#include <avr/io.h> #include <avr/interrupt.h> #include <util/delay.h> #define LED_DDR DDRA #define LED PA7 #define LED_PORT PORTA ISR(TIM0_OVF_vect) { // interrupt occurs every: // 1000000 / 1024 * 256 // = ~ 250000 clocks // = ~250 ms (since clock is 1mhz and 1 clock cy...
C
#include <stdio.h> int main() { int i, j; char *table1[3][2] = { { "A1", "A2" }, { "B1", "B2" }, { "C1", "C2" }, }; char *table2[3][4] = { {"a1", "a2", "a3", "a4"}, {"a2", "b2", "b3", "b4"}, {"a3", "c2", "c3", "c4"}, }; char *table3[3][6]; i...
C
/*************** * Gidon Tobin * 320518020 * 01 * ex6 ***************/ #ifndef _QUEUE_H #define _QUEUE_H // A linked list (LL) node to store a queue entry typedef struct QNode { void* key; struct QNode* next; }QNode; // The queue, front stores the front node of LL and rear stores the // las...
C
/*Questao 7*/ #include <stdio.h> #include <stdlib.h> #include <math.h> int frac (float num, int* inteiro, float* fracao) { *inteiro = floor(num); *fracao = num - *inteiro; return 0; } int main () { float numero; int inte; float fracc; printf ("digite um numero real:"); scanf ("%f", &numero); frac (num...
C
/* +---------------------------------------------------------------------------+ | Mobile Robot Programming Toolkit (MRPT) | | http://www.mrpt.org/ | | ...
C
#include "leecode.h" int minarray(int *pl, int size) { int min = *pl; for (int i = 1; i < size; i++) { if (min > *(pl + i)) { min = *(pl + i); } } return min; } /** * 1 * Note: The returned array must be malloced, assume caller calls free(). */ int *twoSum(int *nums, int...
C
/*#include <stdio.h> #include <stdlib.h> #define MAXSIZE 5 typedef struct { int r[MAXSIZE+1];//r[0]ڱʱ int length; }SqList; void swap(SqList *L,int i,int j) { int temp = L->r[i]; L->r[i] = L->r[j]; L->r[j] = temp; } void HeapAdjust(SqList *L,int s,int m) { int temp,j; temp = L->r[s]; fo...
C
#include <signal.h> #include <assert.h> #include "sr_nat.h" #include <unistd.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <netinet/in.h> #include "sr_protocol.h" /* HELPER FUNCTIONS FOR router.c */ struct sr_nat_connection *find_connection(struct sr_nat_connection *con, uint16_t external_por...
C
// Name: Anthony Gasbarro /* * Mergesort is implemented in function 'mergesort', which is * implemented using recursion. * Change mergesort so that it is implemented iteratively and * still has O(n log n) time complexity. */ #include <stdio.h> #include <stdlib.h> //#include <unistd.h> #define MAXLENGTH 1000 ...
C
#include "drsfunc.h" /* * @fn void PM::updateUsed(const VMPtr vm, bool plus) * Update pm's used value when add or del a vm * @param vm involved vm * @param plus means add a vm if set to true * @created by tuantuan at 2011.8.20 // */ //void updateUsed(pmPtr pm, vmPtr vm, BOOL plus) //{ // int i ; // /*Update u...
C
#include<unistd.h> #include<sys/types.h> #include<sys/stat.h> #include<pwd.h> // 所有者信息 #include<grp.h> // 所属组信息 #include<time.h> #include<string.h> #include<stdlib.h> #include<stdio.h> #include <sys/wait.h> int main(){ pid_t pid = fork(); if(pid > 0){wait(NULL);printf("parent\n");} if(pid == 0){sleep(5);pri...
C
#include <stdio.h> int main() { int n1, n2,temp; printf("enter the n1 number : "); scanf("%d", &n1); printf("enter the n2 number : "); scanf("%d", &n2); temp=n1; n1=n2; n2=temp; printf("n1 is: %d\n",n1); printf("n2 is: %d\n",n2); return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #include "interface.h" #include "logica.h" #include <unistd.h> #include <string.h> void mostrar_tabuleiro(ESTADO *e, FILE *file) { //system("cls"); int i, j; int a = 8; CASA peca; for (i = 0; i < 8; i++) { if (file==stdout) ...
C
#ifndef SEMAFORO_H_ #define SEMAFORO_H_ /*Define Semaforo como um ponteiro do tipo void*/ typedef void* Semaforo; /*Cria um elemento da struct Semaforo_S*/ Semaforo criaSemaforo(char *id, double x, double y, char *cfill, char *cstrk, char *sw); /*Retorna Id de um elemento da lista de semaforos*/ char *getSemaforoId(...
C
int maxArr(int* A, int n1) { int min = INT_MAX, max = INT_MIN, min2 = INT_MAX, max2 = INT_MIN; int i; for(i=0; i<n1; i++){ if(A[i]+i > max) max = A[i]+i; if(A[i]+i < min) min = A[i]+i; if(A[i]-i < min2) min2 = A[i]-i; if(A[i]-i > max2) max2 = A[i]-i; } if(abs...
C
#include "usb_parser.h" Control_CMD_t ParsCMD(uint8_t* data_buff) { Control_CMD_t ret_val = EMPTY; uint8_t dictionary_idx; char *ptr; uint8_t cmp_lng = 0; uint8_t n_word = 0; if(data_buff[0] == 'A') { if(data_buff[1] == 'T') { if(data_buff[2] == '+') { /*определим в пространстве каких симв...
C
/* * strpbrk.c -- SHIFT-JIS string mamipulator * Copyright(c) Jiro Kamina 1994-1997. All rights reserved. * $Header: strpbrk.cv 1.1 98/09/22 12:04:08 Exp $ */ #include <stdio.h> #include <string.h> #include "sjis.h" #include "stringjk.h" /* strpbrk() for SHIFT-JIS string */ char * strpbrk_sj(const char *s, co...
C
#include<stdio.h> int main() { double number; printf("enter a number:"); scanf("%1f",&number); if(number <=0.0) { if(number == 0.0) printf("you entered 0."); else orintf("you entered a negative number."); } else printf("you entered a positive number."); return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { // APPROACH #1 // printf(“Please enter a line:\n”); // char *line =NILL; // size_t len = 0; // ssize_t lineSize = 0; // lineSize = getline(&line, &len, stdin); // printf(“You entered %s, which has %zu chars.\n”, ...
C
// main.c // insertionSort // // Created by Mahamed Hassan on 8/25/20. // Copyright © 2020 Mahamed Hassan. All rights reserved. // #include <stdio.h> void swap(int *x, int *y){ int temp=*x; *x=*y; *y=temp; } void Insertion(int A[], int n){ int i,j,x; for(i=1;i<n;i++){ j=i-1; ...
C
#include<stdio.h> void add_1(void) { int a=10,b=20,c; c=a+b; printf("%d\n",c); }
C
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include "ratio.h" extern int ratio_pgcd(int p, int q) { int t; while(q != 0) { t = q; q = p % q; p = t; } return p; } extern ratio_t ratio_red(ratio_t r) { int pgcd; if(ratio_denom(r) < 0) { ratio_denom(r) = - ratio_denom(r); ra...
C
//comment this line if executed program individually //and uncomment the main class #include "build_heap.cpp" int heap_extract_max(int *,int ); int* heap_increase_key(int*, int, int); int flag = 0;//1 not changed, 0 changed //int main(){ // // int a[] = {1,2,3,4,5}; // int length = sizeof(a)/sizeof(a[0]); // int *m ...
C
#include <stdio.h> #include <stdlib.h> #include "LinkedList.h" #include "Controller.h" #include "Employee.h" #include "validar.h" /**************************************************** Menu: 1. Cargar los datos de los empleados desde el archivo data.csv (modo texto). 2. Cargar los datos de los e...
C
#include "freeglut\freeglut.h" #include "Camera.h" #include "Aircraft.h" extern bool keys[256], specialkeys[256]; extern bool exitProgram; extern Camera *camera; extern Aircraft *aircraft; extern int licznikStrzal; extern bool strzelaj; extern int nrWystrzelonejKuli; extern int iloscKul; extern const GLfloat accel; ex...
C
#include <stdio.h> #include <stdlib.h> int cmpfunc(const void *a, const void *b) // Provides 2 pointers { return (*(float *)a - *(float *)b); // compares two elements. } int main() { int n; float *vector; printf("Enter the number of values to be sorted : \n"); scanf("%d", &n); vector = malloc(n * sizeo...
C
#include<stdio.h> int main() { int a = 5, b = 0; while (a > b) { printf("a = %d b= %d \n", a, b); a--; b++; } return 0; }
C
#include "holberton.h" /** * print_rev - prints a string, in reverse * @vl: string * Return: int */ int print_rev(va_list vl) { int i = 0, len = 0; char *s = va_arg(vl, char *); char nl[] = "(null)"; if (!s) { for (i = 0; nl[i]; i++) _putchar(nl[i]); return (i); } while (s[len] != '\0') len++; ...
C
#include "mySqlHandler.h" #include <stdio.h> #include <string.h> #define SELECT_ALL "SELECT * FROM " #define INSERT_ONE "INSERT INTO " #define DELETE_ONE "DELETE FROM " static int MySql_Query(MYSQL* _mySql, char const* _statement) { int Retvali = mysql_query(_mySql, _statement); if(Retvali != 0) { fprintf(...
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 <stdlib.h> #include "lists.h" #include <stdio.h> /** *print_listint_safe - fun that print all the elements of list int *@head : pointer of list *Return: nbr of elements in list */ size_t print_listint_safe(const listint_t *head) { const listint_t *zeb; int s = 0; while (head) { printf("[%p] %d\n", ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #define TEXTLENGTH 2000 /** * @ciphertext is the input text which is the XOR of the plaintext @p and @q. * @cipherlen is the length of the ciphertext. */ char ciphertext[TEXTLENGTH]; char p[TEXTLENGTH]; char q[TEXTLENGTH]; int cipherlen;...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdint.h> // -no-pie // ASLR on ; NX on ; CANARY on void id_index() { long id[]={0}; int index; printf("What index is your id?: "); scanf("%d", &index); printf("%p", id[index]); } void id_update() { puts("Feature is under maint...
C
#include<stdio.h> int main() { float u,a,t,d,temp1,temp2; printf("Enter the value of initial velocity(u) in m/s : "); scanf("%f",&u); printf("Enter the value of time(t) in seconds: "); scanf("%f",&t); printf("Enter the value of acceleration(a) in m/s^2 : "); scanf("%f",&a); temp1= u*t; ...
C
// vi:nu:et:sts=4 ts=4 sw=4 // Lifted from Lemon, part of Sqlite which is Public Domain. /* The text in the input is part of the argument to an %ifdef or %ifndef. ** Evaluate the text as a boolean expression. Return true or false. */ static int PreprocEvalBoolean ( char *z, int lineno ...
C
// // leetCode-0234.c // leetCode-0234 // // Created by liyoucheng on 2018/10/23. // Copyright © 2018年 齐家科技. All rights reserved. // #include "leetCode-0234.h" /* 我们使用快慢指针找中点的原理是fast和slow两个指针,每次快指针走两步,慢指针走一步,同时前置慢指针部分,等快指针走完时,慢指针的位置就是中点。同时比较slow和prev的值 */ #include <stdlib.h> #include <stdbool.h> #include "LYC...
C
/* // Copyright (c) 2010-2017 Intel Corporation // // 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 License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable la...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* parser.c :+: :+: :+: ...
C
/************************************************************************//** * \file ext_led.h * \brief Function to use the extension LEDs * \author pascal (dot) sartoretti (at) hevs (dot) ch ***************************************************************************/ #ifndef __EXT_LED_H #define __EXT_LED_H #...
C
#include <stdio.h> int main (void) { int n, i; scanf("%d", &n); double x[n]; char u[n][3]; for (i=0;i<n;i++){ scanf("%lf", &x[i]); scanf("%s", u[i]); } double sum; for (i=0;i<n;i++) { if (u[i][0] == 'J') { sum += x[i]; } else { sum += x[i]*380000; } }...
C
#ifndef CUSTOM_LOOPS_H #define CUSTOM_LOOPS_H #ifndef forN //C-Style loop i is the index N the number of loop #define forN(i,N) for(size_t i = 0; i < N; i++) #endif #ifndef forrN //C-Style loop i is the index N the number of loop, reserve version #define forrN(i, N) for(size_t i = N -1; i >= 0; i--) #e...
C
/* * PlayLinkedList.c * * Created on: 2019年1月30日 * Author: dragon */ #include "PlayLinkedList.h" /** * 创建链表 */ PlayNode create_empty_list(){ PlayNode pHead = (PlayNode)malloc(sizeof(Node));//头节点 PlayNode pTail = pHead;//尾节点 pTail->pNext = NULL; return pHead; } /** * 遍历链表 * @params headNode:头节点 ...
C
/*Write a program that shows the minimum digit of all its digits Open Cygwin, run gcc app1.c -o app1.exe to make an exe file, then run ./app1.exe to start the program. Note that the numbers are declared as int */ int n,a,b,c; main(){ printf("Enter a number: "); scanf("%d",&n); //printf("%d",n); while (n...
C
/* * Drizzle Client & Protocol Library * * Copyright (C) 2008 Eric Day (eday@oddments.org) * All rights reserved. * * Use and distribution licensed under the BSD license. See * the COPYING file in this directory for full text. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> ...
C
#include "utils.h" #include <stdlib.h> #include <stdio.h> #include <sys/time.h> void print_msg(char* c) { printf( "\n %s\n", c ); exit(1); } double get_time() { struct timeval t; gettimeofday(&t, NULL); return (double)t.tv_sec + (double)t.tv_usec * 1.e-6; }
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/ioctl.h> #include <fcntl.h> #include <linux/btrfs.h> #include <linux/btrfs_tree.h> #include <string.h> /* * Run the following commands before executing the program * to setup a test loop device with btrfs filesystem: * * qemu-img create -f ra...
C
#include <stdio.h> int main(void) { const int WEEK = 7; int week, day, day1; printf("Введите колличество дней: \n"); while(day>=0) { scanf("%d", &day); day1 = day%WEEK; week = day/WEEK; printf("%d week and %d days", week, day1); } return 0; }
C
#include <stdio.h> void subtract(int a, int b) { printf("Subtraction is %d\n", a-b); } void add(int a, int b) { printf("Addition is %d\n", a+b); } void multiply(int a, int b) { printf("Multiplication is %d\n", a*b); } int main() { // fun_ptr_arr is an array of function pointers void (*fun_ptr_arr...
C
#include <math.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <assert.h> #include <limits.h> #include <stdbool.h> int main(){ int q; scanf("%d",&q); for(int a0 = 0; a0 < q; a0++){ long n; scanf("%ld",&n); long int k = (long)(n%7); p...
C
#include<stdio.h> #include<math.h> /* Define the function to be integrated here: */ double f(double x){ return x*x; } /*Program begins*/ main(){ int n,i; double a,b,h,x,sum=0,integral; /*Ask the user for necessary input */ printf("\nEnter the no. of sub-intervals: "); scanf("%d",&n); printf("\nEnter the...
C
#include <stdio.h> #include <stdlib.h> void missingMoreThanOneElement(int A[],int length,int min,int max) { int H[min+max]; for (int i=0; i<min+max; i++) { H[i]=0; } for (int i=0; i<min+max; i++) { H[A[i]]++; } for (int i=min; i<max; i++) { ...
C
#include "uart.h" #include "msp.h" /*UART setup*/ void UART0_init() { // Configure UART pins P1->SEL0 |= BIT2 | BIT3; // set 2-UART pin as secondary function // Configure UART EUSCI_A0->CTLW0 |= EUSCI_A_CTLW0_SWRST; // Put eUSCI in reset EUSCI_A0->CTLW0 = EUSCI_A_CTLW0_SWRST | // Re...
C
/* Copyright (c) 2019 Pencode.net Author: StoneLi <stone@bzline.cn> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, mod...
C
#include <stdio.h> #include <ctype.h> #include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> int main() { char server_message[256] = "You have reached the server02!"; // create the server socket int server_socket; server_socket = socket(AF_INET, SOCK_STREAM, 0); ...
C
#include <stdio.h> #define FILENAME "student.dat" #define MAX_SIZE 64 int main(int argc, char const *argv[]) { char first_name[MAX_SIZE]; char last_name[MAX_SIZE]; int age; int id; printf("First Name: "); scanf("%s", first_name); printf("Last Name: "); scanf("%s", last_name); printf("Age: "); sca...
C
typedef struct node { int data; node *left; node *right; }node; node *lca(node *root, int v1,int v2) { if(root == NULL){ return NULL; } if(root->data > v1 && root->data > v2) return lca(root->left, v1, v2); if(root->data < v1 && root->data < v2) return lca(root->right, ...
C
/* Name : rentInfoAccess.c ver 1.0 * Content : DVD 대여 정보 저장/참조 함수들의 정의 * Implementation : YSW * * Last modified 2015/02/25 */ #include "common.h" #include "rentInfo.h" #include "cusInfo.h" #include "cusInfoAccess.h" #include "screenOut.h" #define RENT_LEN 100 static dvdRentInfo rentList[RENT_LEN]; static int...
C
#include<stdio.h> int prime(int x,int y); int prime(int x,int y) { int i,j,l,h,flag; l=x;h=y; if(x>y){ l=y;h=x; } // printf("Prime numbers between %d and %d are: ", l, h); printf("Prime numbers:"); for(i=l+1; i<=h; i++) { flag=0; for(j=2; j<=i/2; j++) { if(i%j==0) ...
C
// // homeWord.c // Learn4_ndk // // Created by qgg on 2017/8/1. // Copyright © 2017年 lhc. All rights reserved. // #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> struct BilateralNode{ void* data; struct BilateralNode *prev; struct BilateralNode *next; }*head,*end; int...
C
#include "trie.h" #include <stdio.h> #include <stdbool.h> #include <string.h> int main(int argc, char* argv[]) { bool printInReverse = false; if (argc == 2 && strcmp(argv[1], "r") == 0) printInReverse = true; char str[50];//Assuming 50 it's enough for buffersize TrieNode* head = TrieNode_new(); if (stdin) ...
C
int bitcount(STYPE value) { int result = 0; UTYPE uns_value = value; while (uns_value) { result += uns_value & 1; uns_value >>= 1; } return result; }
C
#include <stdio.h> int binsearch(int x, int nrs[], int n); int main() { int nr, length, position; int nrs[] = {1, 5, 9, 20, 43, 57, 68}; length = 7; nr = 20; position = binsearch(nr, nrs, length); printf("Nr %d is found at position %d\n", nr, position); nr = 57; position = binsearch...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* fmt_s.c :+: :+: :+: ...
C
#define MIN_NUM(a, b) ((a) < (b) ? (a) : (b)) #define MAX_NUM(a, b) ((a) > (b) ? (a) : (b)) int movesToMakeZigzag(int* nums, int numsSize) { int min1 = 0; int min2 = 0; if (numsSize <= 2) { return 0; } /* 奇数索引数大的情况 ,减偶数索引的数*/ for (int i = 1; i < numsSize - 1; i += 2) { ...