language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* format_hex.c :+: :+: :+: ...
C
#include "utils/s2n_safety.h" void *malloc(__CPROVER_size_t); uint32_t nondet_uint32(); uint8_t nondet_uint8(); int main(int argc, char * const * argv){ uint8_t *a, *b; uint32_t len; int result; a = malloc(sizeof(uint8_t)); b = malloc(sizeof(uint8_t)); len = nondet_uin...
C
/* ** EPITECH PROJECT, 2019 ** strace_exe ** File description: ** jooyoung.kim@epitech.eu */ #include <stdio.h> #include <signal.h> #include <sys/ptrace.h> #include <stdlib.h> #include <unistd.h> #include <sys/wait.h> #include <sys/user.h> #include "strace.h" pid_t *global_pid; void handler(int sig) { ptrace(PTR...
C
#pragma once #ifndef PARSER_H #define PARSER_H 1 #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <assert.h> #include <errno.h> #include <inttypes.h> #include <string.h> #include "macro.h" #include "types.h" #define MAGIC_SIG "DEMO\0" #define MAGIC_SIG_LEN 5 #define DATA_TYPE_ASCII 1 #define DAT...
C
#include <stdio.h> #include <stdlib.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> int foo(int a, int b) { return a+b; } int main(int argc, char *argv[]) { int a = 2; int b = 2; int (*c)(int,int); int d = 0; c = &foo; // or c = foo; d = c(a,b); printf("%d\n",d); return 0; }
C
#include <stdlib.h> #include "core.h" size_t core_get_int_length(const int integer){ if(integer > 999999999){ return 10; }else if(integer > 99999999){ return 9; }else if(integer > 9999999){ return 8; }else if(integer > 999999){ return 7; }else if(integer > 99999)...
C
#include "i8259.h" #include "lib.h" #include "rtc.h" #include "tests.h" #define RTC_REGISTER_PORT 0x70 #define RTC_DATA_PORT 0x71 #define NMI_MASK 0x80 #define RTC_IRQ_NUM 0x08 #define MAX_FREQ 1024 /* credit to http://wiki.osdev.org/RTC */ volatile int next_interrupt = 0; /*Initialize RTC input,output:none Effects: e...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_lines.c :+: :+: :+: ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_splitwhitespaces.c :+: :+: :+: ...
C
/*C program to convert the given decimal number into binary and count of 1's */ #include<stdio.h> int main(void) { int num, bin_val = 0, base = 1, rem, dec_val, count_One = 0, count_Zero = 0; printf("Enter decimal number -> "); scanf("%d", &num); dec_val = num; while(num > 0) { rem = num % 2; if(rem == ...
C
/********************************** tcp_ser.c: the source file of the server in tcp transmission ***********************************/ #include "headsock_tcp4.h" #define BACKLOG 10 char toPrint[BUFSIZE] = {"\0"} ; void str_ser(int sockfd); // tran...
C
/**************************************************************************** * * Copyright (c) 2012, BeiJing EFLAG Technology Co., LTD. * All rights reserved. * * ļ sensor.c * ժ Ҫ ¶ȴʵ * * ǰ汾 * EFLAG * * * ȡ汾 * ԭ * ޸ * 2012.08.01 * ******************************************...
C
// 1. every node is either red or black // 2. root is black // 3. null leaf(sentinel) is black // 4. if a node is red, its sons are black // 5. every path from one node to all its leaves(sentinel) has same number of black nodes #include "agile_rbtree.h" static inline void rbtree_left_rotate(rbtree_node_t** root, rbtr...
C
/* ** This program reads a cafeteria data file or a pedometer file ** and cuts out windows of bites or steps. ** Bite indices are determined via gt_union.txt. ** Step indices are determined via steps.txt. ** The type of file is determined by which of those two GT is present. ** ** The data is cut from N sec pr...
C
/** @file ESP8266.h * @brief ESP8266 Driver V 1.0 * * Created on: May 26, 2020 * Handles sending to a Local server with only one connection. * * @author Alaa AbdAlrhman * @bug no known bugs */ #ifndef ESP8266_H_ #define ESP8266_H_ #include "Utils.h" #include "Std_Types.h" #include "../UART/U...
C
#include "RSXABOUTconfig.h" void border(unsigned char nColorIndex) { #ifdef RSXABOUT_BORDER __asm ; &BC38 AF,BC,DE and HL are corrupted push af push bc push de push hl LD d, #0x00 LD e, 4 (ix) LD (TABLE), de LD A,#0x01 ;un seul paramètre LD IX,#TABLE ; le paramètre : 4 (border 4) LD HL,...
C
/* ** EPITECH PROJECT, 2020 ** add_mul.c ** File description: ** add_mul */ #include "mem_ptr.h" static void test_add_str ( void ) { char *str1 = "Hey, "; char *str2 = "it works !"; char *res ; add_str (str1, str2, &res ) ; printf ("%s\n", res ) ; } static void test_add_str_struct ( void ) { ...
C
#include "leptjson.h" #include <assert.h> /* assert() */ #include <stdlib.h> /* NULL, strtod() */ #include <errno.h> #include <math.h> #define EXPECT(c, ch) do { assert(*c->json == (ch)); c->json++; } while(0) #define IS_DIGIT(c) ((c)>='0'&&(c)<='9') typedef struct { const char* json; }lept_context; static...
C
/* solveT.c */ #include "SubMtx.h" #define MYDEBUG 0 /*--------------------------------------------------------------------*/ static void real_solveDenseSubrows ( SubMtx *mtxA, SubMtx *mtxB ) ; static void real_solveDenseSubcolumns ( SubMtx *mtxA, SubMtx *mtxB ) ; static void real_solveSparseRows ( SubMtx *mtxA, S...
C
#include <stdio.h> #include <stdlib.h> typedef struct node { int data; struct node *left; struct node *right; }Node; int * create() { int x; Node *newnode=(Node*)malloc(sizeof(Node)); printf("Enter the data for the no...
C
#include <stdio.h> #include<string.h> int main() { char s[100],s1[100]; int i=0; scanf("%s",s); while(s[i]!='\0') { i++; } int j=0; while(i>=0) { s1[j++]=s[i-1]; i--; } s1[j]='\0'; printf("%s",s1); return 0; }
C
#include <cs50.h> #include <stdio.h> int main(void) { int start_size = 0; int end_size = 0; int number_accepted = 0; int years = 0; int years_found = 0; int llamas = 0; //Ask user for start size until valid number is entered while (number_accepted == 0) { start_size = get_l...
C
#include "lists.h" /** * free_list - function that frees a list_t list. * @head: Pointed to head of a list * * Return: Void */ void free_list(list_t *head) { list_t *new = head; list_t *next = NULL; for (; new != NULL; new = next) { next = new->next; free(new->str); free(new); } }
C
#include <stdio.h> int main(int argc, char **argv) { int i; printf("argv count: %d\n", argc); for(i = 0; i < argc; i++) { printf("argv[%d] = %s\n", i, argv[i]); } fprintf(stderr, "this message is send to stderr\n"); }
C
#include <stdio.h> #include <stdlib.h> struct Node { char data; struct Node *next; }; void LinkdeListTraversal(struct Node *ptr) { printf("Data in linked list is: \n"); while (ptr != NULL) { printf("%c", ptr->data); ptr = ptr->next; } } int main() { struct Node *head; st...
C
/** * use execve * deal with absolute PATHS only * */ #include <unistd.h> #include <stdio.h> #include <errno.h> int main(int argc, char *args[]) { char *path = "/bin/ls"; // exceve deals with PATHS only char *argv[] = {"ls", "-l", "-a", NULL}; // if this is not null terminated the call wil...
C
#include<stdio.h> #include<stdlib.h> #include<sys/stat.h> #include<fcntl.h> #include<unistd.h> int main(int argc, char *argv[]) { int realY = open("y_test", O_RDONLY); int predY = open("result.csv", O_RDONLY); FILE *predYfp = fdopen(predY, "r"); int num = atoi(argv[1]); int correct = 0; int times[10] = {}; fs...
C
#include <stdio.h> #include <cs50.h> #include <math.h> int main(void) { float x; int c,n=0; x=get_float("Change owed:"); while(!(x>0)) { x=get_float("Change owed:"); } c = round(x * 100); while((c-25)>=0) { n++; c=c-25; } while((c-10)>=0) { ...
C
/*Viken Parikh B2 1411099*/ #include<stdio.h> #include<conio.h> void merge(int array[], int low, int mid, int high) { int i, j, k; int n1 = mid - low + 1; int n2 = high - mid; int L[100], H[100]; for(i = 0; i < n1; i++) L[i] = array[low + i]; for(j = 0; j < n2; j++) H[j] = array[mid + 1+ j]...
C
#include <stdio.h> #include<string.h> int main(){ char st [20]="hello"; char*st2="lipun"; strcat(st,st2); printf("st is %s",st); return 0; }
C
#include <stdio.h> #define sz 1000000000 int ara[sz]; void sieve() { int i,j,root; for(i=2;i<=sz;i++){ ara[i]=1; } root=sqrt(sz); for(i=2;i<=root;i++){ if(ara[i]==1){ for(j=2;i*j<=sz;j++){ ara[i*j]=0; } } } } int m...
C
/****************************************************************************** Projete um programa para calcular a área de um triângulo. O usuário informará os dados necessários para o cálculo, ou seja, a base e a altura do triângulo. onde: área = base * altura /2 **************************************************...
C
#include <stdio.h> #include <stdlib.h> //exit関数を使うには、<stdlib.h> を #include する必要がある //次のプログラムは、int型の要素数10個の配列を動的に確保します。 int main() { int i; int *heap; // heap = 長期的に使用される大きなサイズのメモリを格納する領域 printf("%p\n",heap); // malloc()の戻り値はvoid *型ですが、これをint *型へと変換している()を // キャスト演算子(cast operator)と呼びます。 heap = (int *)malloc(siz...
C
#include <stdio.h> static const char *strings[] = {"one","two","three","four","five","six","seven","eight","nine"}; int main() { int a,b,i; scanf("%d\n%d", &a, &b); for(i=a;i<b;i++) { if((i>=1&&i<=9)&&(b>=1&&b<=9)) { printf("%s\n",strings[i-1]); printf("%s\n",str...
C
/* * File: fonction_periph.c * Author: laure * * Created on 21 fvrier 2019, 16:36 */ #include <stdio.h> #include <time.h> #include "HC-SR04.h" #include "fonction_periph.h" void send_water(int cup_size) { Relai_eau = 0; my_delay(2000*cup_size); Relai_eau = 1; } void send_milk(int num_cup) { ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> int main (int argc, char *argv []) { FILE *ArchivoResultados; char Renglon [100]; if (argc != 2) { printf ("Error: demasiados o muy pocos argumentos.\n"); printf ("Uso del programa: ./LeeComplex NombreArchivo (Con ext.)\n"); exit (...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* print_func.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> int main() { float d,l,s; int t,x,y,r; scanf("%d",&t); while(t--) { scanf("%d %d %d",&x,&y,&r); d=sqrt(pow(x,2)+pow(y,2)); l=r+d; s=r-d; printf("%.2f %.2f\n",s,l); } return 0; }
C
//寫一個程式讀入三個平面上的座標, //然後印出其中距離原點最遠的點, //如果兩個或多個點,有相同的距離, //輸出最先出現的點座標。 #include <stdio.h> main() { int a, b; scanf("%d", &a); scanf("%d", &b); int x = a, y = b; scanf("%d", &a); scanf("%d", &b); if ((a*a + b*b) > (x*x + y*y)) { x = a; y = b; } scanf("%d", &a); scanf("%d", &b); if ((a*a ...
C
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <conio.h> int fre_counter(char s[]) { int i, f = 0; for(i=0; s[i]!='\0'; i++) { if(s[i]=='t' && s[i+1]=='h' && s[i+2] == 'e' && s[i+2] != '\0') { f++; } } return f; } void main() { char s[50]; i...
C
//Fibonacci sequence creator #include <stdio.h> int main(){ int a=1, b=1, c; printf("Enter a value:"); scanf("%d", &c); printf("%d - %d - ",a,b); for(; a+b<=c; ){ a=a+b; b=a-b; printf("%d - ",a); } }
C
#include "command_unalias.h" int command_unalias(int argc , char* arg[]) { int i = 0; int* mark = NULL; int retstate = 0; if(0 == argc || NULL == arg) { return -1; } mark = (int*)malloc(argc * sizeof(int)); if(strcmp("unalias",arg[0])) { shellcommandNOcall(STDERR_FILENO,"unalias"); return -1; } mark...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> #include "list.h" #include "../student.h" #include "../../basic.h" extern void student_showAdapter(void *pStu); extern int student_writeAdapter(FILE *fp,void *pStu); extern int student_readAdapter(FILE *fp, void *pStu); extern int student_compareAdapter(void *pStu...
C
#include <stdlib.h> #include <stdio.h> #include "helper/list.h" /** * Frees a (void *) that is in reality an (int *) * @param integerVoidPointer */ void freeIntPointer(void *integerVoidPointer) { if (integerVoidPointer != NULL) free((int *)integerVoidPointer); } void *intComparator(void *a, void *b) { ...
C
#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> int vflag, rflag, wflag, xflag; int displayVerbose(); void usage (char *prog) { printf("usage : %s [rvwx] file", prog); } int maccess (int argc, char **argv) { int mode = F_OK; int i; printf("OPTIONS verbose:%i, read:%i, write:%i...
C
#include "floatToHex3a.h" float number = -2.25; uint8_t message[32]; int main() { int i; floatToByte(number, message); for(i = 0; i < 32; i++) { printf("here is the message[i] %X\n",message[i]); } return 0; }
C
/****************************************************************************** * Student Name : * RMIT Student ID : * COURSE CODE : * * Startup code provided by Paul Miller for use in "Programming in C", * study period 4, 2018. *****************************************************************************...
C
//C hello world example #include <stdio.h> #include <time.h> // #include <conio.h> // testing git void my_function(); int max(int, int); int solution(int A[], int ); int solution_2(int N) ; int solution_3(int A[], int N); int solution_4(int A[], int N, int X, int D); int solution_5(char *E, char *L); void getSecond...
C
/** * 参考自 https://github.com/AndreMouche/algorithms_study/blob/master/data_structure/skiplist.cpp ,https://www.epaperpress.com/sortsearch/txt/skl.txt * 踩坑如下:insert方法中 update变量初始化问题,不同于java声明变量后变量初始赋值为NULL,而是随机值,当取址时就会出错。谨记!!! * * 另外复习下结构体初始化方式: * 1.recType value = (recType){key}; * or recType value = {...
C
#ifndef _COMMON_H_ #define _COMMON_H_ // I[o[Cȟx}~ #pragma warning(disable: 4996) #include "Vector.h" #define PI 3.141592f #define D2R(degree) (degree * 0.017453f) #define R2D(radian) (radian / 0.017453f) #define null 0 #define boolean unsigned char #define SAFE_METHOD(p, method) {if(p) p->method();} #define SAFE_R...
C
#include <stdlib.h> #include <stdio.h> #include <pthread.h> #include <math.h> #define NUMVALS 1024 int mylist[1024]; int sortedList[1024]; typedef struct { int start_index; int end_index; } SortInfo; int genRand(int low, int high) { // generate a random integer r such that low <= r <= high double r1, r2...
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
/** * @file main2.c * @brief Множення матриці саму на себе * * @author Makarenko V. * @date 14-dec-2020 * @version 1.0 */ #include <stdlib.h> #include <time.h> /** * Розмір матриці */ #define SIZE 3 /** * функція для множення матриці саму на себе * * Послідовність дій: * - створення масиву, в який буде з...
C
#include <stdio.h> #include <string.h> int main( ) { char str2[10], str1[10]="darsh"; str2[10]=strrev(str1); printf("The entered string is: %s",str1); printf ("The reversed string is : %s",str2) ; return 0; }
C
#include<stdio.h> #include<math.h> void triangleTypeCheck(double a, double b, double c) { if( !((a+b) > c) || !((b+c) > a) || !((a+c) > b) ) { printf("Invalid\n"); } else if( (a == b) && (b == c) ) { printf("Equilateral Triangle\n"); } else if( (a != b) && (a != c) && (b != c) ) { if( (a / (c-b)) == ((c+...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> /* Include cloc-generated header files */ #include "hw.h" #include "hw2.h" int main(int argc, char* argv[]) { char* input1 = "Gdkkn\x1FGR@\x1FVnqkc"; size_t strlength = strlen(input1); char *input = (char*) malloc_global(strlength + 1); char *output = (c...
C
#include <stdio.h> int numero, ultimoNumero, penultimoNumero, primeiroNumero; int main(){ printf("...::: PROGRAMA INVERSOR DE NUMEROS :::...\n"); printf("Insira o número que deseja inverter:"); printf("0 a 999\n"); scanf("%i", &numero); //calculador de numeros// ultimoNumero = numero % 10; ...
C
#include "simple_logger.h" #include "gf2d_draw.h" #include "level.h" #include "Grunt.h" static Level *THE_LEVEL = NULL; Level *level_get_active() { return THE_LEVEL; } Uint8 level_bounds_test_circle(Level *level, Vector2D center, float radius, Vector2D *normal) { Uint8 hit = 0; if (!level) { slog("no level pr...
C
#include "Paging.h" /*paging*/ #define small_page 1024 /*1 kb*/ #define pageby4 4096 /*1024*4 4 kb*/ /*bits as defined in os dev for enmabling paging*/ #define cr0enable 0x80000000 #define cr4enable 0x00000010 /*various flags all described in ULK*/ #define global_flag 0x100 #define dirty_flag 0x40 #defi...
C
# include <stdio.h> enum days {Sun, Mon, Tue, Wed, Thu, Fri, Sat}; void main() { enum days Var; for(Var=Sun;Var<=Sat;Var++) { switch(Var) { case Sun:printf("\nSunday"); break; case Mon:printf("\nMonday"); break; case Tue:printf("\nTu...
C
/* * Copyright (c) 2014, Ben Wei (ben@staros.mobi) * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of co...
C
#include "debug.h" #include "nlib.h" #include <stdlib.h> i64 err_s = 0; void print_parse_tree() { for (i64 i = 0; i < parse_top; i++) printf("%s\n", neta_node2string(parse_tree[i])); } void print_eval_stack() { for (i64 i = 0; i < eval_top; i++) printf("%s\n", neta_node2string(...
C
#include<stdio.h> main() { unsigned int a,b,c; printf("Enter a:"); scanf("%d",&a); printf("Enter bit position :"); scanf("%d",&b); if(((0<=b)&&(b<=31))?1:printf("Wrong data Entered");) { b=1<<b; c=a&&b; printf("%d",c); } }
C
#include "dog_struct.h" struct dog * create_dog(char * name, char * color, uint8_t age, uint8_t weight){ static int dog_create_count = 0; printf("Dogs created = %d\n", dog_create_count); dog_create_count++; // create dog struct struct dog * d = NULL; d = (struct dog *) malloc(sizeof(struct d...
C
# include <stdio.h> main() { int n1; printf("Digite um numero menor que 10: "); scanf("%d",&n1); // Os comandos "if" e "else" equivalem a "se" e "seno". if(n1<10) { printf("Ok!"); }else { printf("O numero digitado eh maior ou igual a 10."); } }
C
#include <locale.h> #include <stdio.h> #include <conio.c> #include <conio.h> #include <ctype.h> #include <string.h> #define LINHA 20 #define COLUNA 60 void preenche(char matriz[][COLUNA], int i, int j, char simb); void printMatriz(char matriz[][COLUNA], int i, int j); int main(void) { setlocale(LC_ALL...
C
/**/ #include <stdio.h> int main(){ float A, B, C, D, grade; printf("Enter thresholds for A, B, C, D\nin that order, decreasing percentages > "); scanf("%f%f%f%f", &A, &B, &C, &D); printf("Thank you. Now enter student score (percent) >"); scanf("%f", &grade); if (grade >= A) printf("Student has an A grad...
C
/******************************************************************************* * [FILE NAME]: adc.h * * [Author]: Hisham Elsayed * * [DATE CREATED]: Oct 6, 2021 * * [DESCRIPTION]: Header file for ADC Driver *******************************************************************************/ #ifnd...
C
/* * File: main.c * Author: domenicocitera * * Created on 14 de noviembre de 2013, 16:58 */ #include <stdio.h> #include <stdlib.h> #include <math.h> void imatge(double t, double *p); double distancia(double* p0, double* p1); /* * */ int main(int argc, char** argv) { int n, i = 0; double a, b; ...
C
// // Created by amichai hadad on 15/12/2019. // #include <stdio.h> #include "sortlib.h" #define Len 50 int main(){ int arr[Len]; int temp; for(int i = 0; i<Len;i++){ scanf(" %d",&temp); *(arr+i) = temp; } insertion_sort(arr,Len); for(int y =0;y<Len-1;y++){ printf("%d,",...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* print.c :+: :+: :+: ...
C
/****************************************************************************** *LCD.c -- Inplementation of setting up LCD functions and printf on the LCD display *By Weipeng Tang *FEB 1, 2019 ********************************************************************************/ #ifndef _LCD_H #define _LCD_H #include...
C
#include "../head.h" double Add(double a, double b); double Sub(double a, double b); double Mul(double a, double b); double Div(double a, double b); double (*func[])(double, double) = {Add, Sub, Mul, Div}; enum op{ ADD = 0, SUB, MUL, DIV }; double Add(double a, double b) { return a+b; } double Sub(double a, d...
C
#include<stdio.h> #include<malloc.h> struct stack { int data; struct stack * link; }; void push(struct stack ** stack ,int no) { struct stack * n1=(struct stack *)malloc(sizeof(struct stack)); n1->link=*stack; n1->data=no; *stack=n1; } int pop(struct stack ** stack) { int var...
C
#include <string.h> #include <stdio.h> #include <stdlib.h> #define YEARS 5 #define MONTHS 12 int main(int argc, char const *argv[]) { /** * 统计2010-2014年的降水量初始化数组 * 计算一年的总降水量 * 计算平均的每月降水量 */ const float rain[YEARS][MONTHS] = { {0.2,0.5,0.7,0.1,1.0,0.8,0.1,0.9,0.2,0.7,1.0,0.9}, {0.4,0.7,0.8,0.0,0.6,0.7,...
C
#include <stdio.h> #include <assert.h> #include <stdlib.h> #include <errno.h> #include <string.h> struct Address { int id; int set; char* name; char* email; }; struct Database { int max_data; int max_rows; struct Address* rows; }; struct Connection { FILE* file; struct Database* db; }; void Databa...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include "trie.h" #include "heap.h" #include "heap.h" #include "hash_table.h" bloom_filter * bloom ; void test_insert_trie(char * sentence) { trie * mytree; mytree = init_trie(); heap* my_heap = heap_create(); int result ...
C
#include <vigenere.h> const char *vgn_crypt(const char *msg, const char *key){ if(!msg || !key) return 0; char *_new = (char *) malloc(strlen(msg)); int x; for(x=0;x<strlen(msg);x++) _new[x] = ((msg[x]+key[x]) % 255)+1; return (const char *) _new; } const char *vgn_decrypt(const char *msg, const char *key)...
C
#include "tictactoe.h" /* returns one of GAME_ACTIVE, GAME_DRAWN * GAME_PLAYER_WON, GAME_PLAYER_LOST */ int evaluate_board( PLAY_MOVE_ARGS ) { int winning_lines[NUM_WINNING_LINES][3][2] = WINNING_LINES; int i, j, x, y, num_computer, num_player, is_on_line = FALSE; int num_available_lin...
C
// // Queues 1.0 // Implementing a Queue Using an Array #include <stdlib.h> typedef struct { int head, tail; int QA[MaxQ]; } QType, *Queue; Queue initQueue() { Queue qp = (Queue)malloc(sizeof(QType)); qp->head = qp->tail = 0; return qp; } int empty(Queue Q) { return (Q->head == Q->tail); } void...
C
/* ǰ0ȣǸ */ #include <angle.h> int mk_mid = 1500+140; //мֵҲ0ȵֵλus void angle_init() { /* ʱͨ£ ʱ TIMx_CH1 TIMx_CH2 TIMx_CH3 TIMx_CH4 TIM1 PA8 PA9 PA10 PA11 TIM2 PA0 PA1 PA2 PA3 TIM3 PA6 PA7 PB0 ...
C
#include "stdio.h" #include "stdlib.h" char board[15][31]={"өөөөөөөөөөөөө", "ĩ", "ĩ", "ĩ", "ĩ", "ĩ", "ĩ", "ĩ", "ĩ", "ĩ", "ĩ", "ĩ", "ĩ", "ĩ", "۩۩۩۩۩۩۩۩۩۩۩۩۩"}; char chess[2][3]={"",""}; char name[4][6]={"1","2","",""};...
C
#ifndef QUEUE_C #define QUEUE_C #include "queue.h" #include <stdio.h> #include <stdlib.h> #include <string.h> int front; int rear1,rear2; Queuevector * newQueuevector(){ Queuevector * sv = malloc(sizeof(Queuevector)); sv->data = newVector(); sv->enqueue = pushQueuevector; sv->dequeue = popQueuevector; sv->peek =...
C
#include<stdio.h> void main() { int len,i,j; char s1[20],s2[20]; printf("Enter original string:"); fgets(s1, sizeof(s1), stdin); len = 0; while(s1[len]!='\0') { len++; } for(i=0,j=len-1;i<len;i++,j--) { s2[j] = s1[i]; } s2[len] ='\0'; printf("reverse string: %s\n",s2); }
C
#include "blocks.h" #include "metadata_disk.h" #include "meta.h" #include "list.h" #include <linux/limits.h> #include <inttypes.h> #define CWD_LENGTH 128 char* normalize_path(char* resolved_path, char* cwd); typedef struct stack_node { entry_disk* _entry; unsigned int depth; } stack_node; void tree_print(ch...
C
#include <iostream> #include <math.h> #include <iomanip> const double a = 1.2; double f(double x) { //The function we are analyzing return tanh(a*x)-x; } double g2(double x) { //Newton-Raphson method return x-((tanh(a*x)-x) / ((a / (cosh(a*x)*cosh(a*x)))-1)); } int main() { double x; int n; std::cout << "x = ...
C
# include <stdio.h> # include "c_iraf.h" # include "hstio.h" # include "stis.h" # include "calstis1.h" # include "hstcalerr.h" /* for REF_TOO_SMALL */ # include "stisdef.h" /* This routine finds the bin factors and corner location to use when calling bin2d to extract and bin the appropriate subset of a refere...
C
/* * ultraS.c * * Created on: 7. nov 2016 * Author: Y009 */ /** \file ultraS.c ** \brief Documentation for the ultrasonic module. ** ** Describes the workings of the ultrasonic module. ** @startuml {umlFSM.png} ** [*] --> US_IDLE : Power on ** US_IDLE --> US_WORKING : Button press ** US_WORKING --> US_...
C
#include "draw.h" #include <SDL.h> #include "types.h" #include "anim.h" #include "puzzle.h" #define FONT_WIDTH 9 #define FONT_HEIGHT 16 #define TW 64 #define TH 64 #define TIMER_W 7 #define TIMER_H 7 #define EXPLOSION_LEN 500 #define PARTICLE_W 4 #define PARTICLE_H 4 void draw_string(SDL_Renderer *renderer, SD...
C
#include<stdio.h> #include<stdlib.h> void swap(int *a,int *b) { int temp=*a; *a=*b; *b=temp; } int partition(int *a,int low,int high) { int ele=a[high]; int i=low-1,j=low; for(j=low;j<high;j++) { if(a[j]<=ele) { i=i+1; swap(&a[j],&a[i]); } ...
C
/* 文件:message.c 作者:李培生 内容: 控制消息有无的全局变量; 消息字符串的全局变量; 设置显示内容的函数的声明; 消息显示的函数的声明。 */ #include <string.h> #include "imgui.h" #include "graphics.h" #include "extgraph.h" #include "message.h" //全局变量 int message_content = MESSAGE_NO; //消息有无 char message[100] = "\0"; //消息字符串 //...
C
#include "libmx.h" void mx_pop_back(t_list **list) { if (*list) { t_list *node = *list; t_list *last_node = NULL; while (node->next->next) { node = node->next; } last_node = node->next; node->next = NULL; last_node->data = NULL; last_node->next = NULL; free(last_node); } }
C
#include <math.h> double get_sd(double data[], int n){ int i; double mean=0.0, sum_deviation=0.0; if(n==1) return 0.0; for(i=0; i<n; i++){ mean+=data[i]; } mean=mean/n; for(i=0; i<n;++i){ sum_deviation+=(data[i]-mean)*(data[i]-mean); } return sqrt(sum_deviation/n); } d...
C
#include "holberton.h" /** * set_string - sets the value of a pointer to a char. * @s- pointer value be set * @c- to char value to be set * Return: Always 0. */ void set_string(char **s, char *to) { *s = to; }
C
#include <stdio.h> void d2b(int); int main() { int n; scanf("%d", &n); d2b(n); printf("\n"); return 1; } void d2b(int n) { if(n==0) return; d2b(n/2); printf("%d", n%2); }
C
#include <stdio.h> #include <stdlib.h> #define UPPER_LIMIT 1000 #define LOWER_LIMIT 1 #define BITUP 10 #define BITDOWN(X) ((X)/(10)) #define REMAINDER(X) ((X)%(10)) int BitUp(int zegop); int main(void){ int testcase=0; int idx=0; //INPUT scanf("%d", &testcase); int num1[testcase]; int num2[testcase]...
C
#include <stdlib.h> size_t maxSeq(int* array, size_t n) { int myIt; int numSeq = 1; int tmpSeq; if (n == 0) { return 0; } tmpSeq = 1; for (size_t i = 1; i < n; i++) { myIt = array[i-1]; if (myIt < array[i]) { tmpSeq++; if (numSeq < tmpSeq) { numSeq = tmpSeq; } } else { tmp...
C
#ifndef PRINT_TREE_H #define PRINT_TREE_H struct block { struct node * stmt; struct node * block; }; struct assign { struct node * lhs; struct node * expr; }; struct unop { char * op; struct node * oprnd; }; struct biop { char * op; struct node * oprnd1; struct node * oprnd2; }; struct ident { ...
C
/* * cw6-z2.c * * Created: 10/24/2020 11:47:54 AM * Author : Kamil Cinner */ #define LeftButton 0 #define RightButton 3 #include <avr/io.h> #include <avr/interrupt.h> #include <stdbool.h> volatile bool timerStarted = false; volatile bool keyLocks[] = { false, false, false, false }; volatile uint8_t keyPress...
C
#include <netinet/in.h> #include <strings.h> #include <string.h> #include <arpa/inet.h> #include <stdio.h> #include <sys/socket.h> #include <unistd.h> #include <sys/errno.h> #include <stdlib.h> int main(int argc, char** argv) { int sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); struct sockaddr_in cliaddr; bzer...