language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> #include <malloc.h> typedef struct __node { int data; struct __node *node_l; struct __node *node_r; }tree; tree *get_node() { tree *tmp; tmp = (tree *)malloc(sizeof(tree)); tmp->node_l = NULL; tmp->node_r = NULL; return tmp; } void print_tree(tree *root) { printf("%d\n...
C
/* ============================================================================ Name : Tp1_laboratorio.c Author : Version : Copyright : Your copyright notice Description : Hello World in C, Ansi-style ============================================================================ */ #include <s...
C
/* cc greedy.c -o greedy -O Group Name: KaheKahe kakai Group Members: Marcelo Melo, Bryan Hinton, Carl Mitchell. marcelom@cs.byu.edu Greedy */ #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <time.h> /*FUNCTIONS*/ unsigned long find(unsigned long); unsigned long...
C
// implementation of field void initField(int field[FLD_DEF_LIN][FLD_DEF_COL]) { int lin, col; for(lin = 0; lin < FLD_DEF_LIN; lin++){ for(col = 0; col < FLD_DEF_COL; col++){ field[lin][col] = 0; } } } void insertBlock(int field[FLD_DEF_LIN][FLD_DEF_COL], int line, int col) { if(line >= 0 && line <= FLD_S...
C
#include<stdio.h> int main(){ int cases; int n,k,res,i; scanf("%d",&cases); while(cases--){ scanf("%d%d",&n,&k); res=0; for(i=0;i<n;i++){ if(k%4==1||k%4==2) res|=1<<i; k>>=1; } printf("%d\n",res); } return 0; }
C
/* COPYRIGHT The following is a notice of limited availability of the code, and disclaimer which must be included in the prologue of the code and in all source listings of the code. (C) COPYRIGHT 2022 Dr. Ralf Schlatterbeck Open Source Consulting Permission is hereby granted to use, reproduce, prepare derivative wor...
C
#include "holberton.h" #include <stdlib.h> #include <stdio.h> /** * string_nconcat - concat the strings. * @s1: the first string. * @s2: the second string. * @n: delimiter of the second string. * Return: Always 0. */ char *string_nconcat(char *s1, char *s2, unsigned int n) { int a = 0; unsigned int b = 0; int ...
C
typedef struct node { int value; struct node *next; } node_t; node_t* createNode(int nValue); int insertNode(node_t** head,int nValue); node_t* findValue(node_t* head, int nValue); void deleteNode(node_t* head, int nValue); void deleteList(node_t* head); void displayList(node_t *head);
C
/* date = January 9th 2021 10:37 am */ #ifndef UTILS_H #define UTILS_H #pragma warning(push) #pragma warning( disable : 4514 ) #include <stdint.h> #include <stddef.h> //~ TYPEDEFS typedef int8_t s8; typedef int16_t s16; typedef int32_t s32; typedef int64_t s64; typedef uint8_t u...
C
/** * 1、维护一个libuv的event loop 供其他的模块调用 * 2、管理程序的生命周期 * * https://github.com/luohaha/Chinese-uvbook * http://luohaha.github.io/Chinese-uvbook/ */ #include <uv.h> #include "ry_mqtt.h" #include "ry_nvr_mgr.h" #include "ry_iec61850.h" #include "ini.h" //-------------------全局变量--------------------------- uv_loop_t *r...
C
#ifndef __BST_H__ #define __BST_H__ #include <stddef.h> /* size_t */ typedef struct bst_node bst_node_t; typedef bst_node_t *bst_iter_t; typedef struct bst bst_t; typedef int(*cmp_func_t)(const void *data1, const void *data2, const void *param); typedef int(*action_func_t)(void *data, void *param); /*Descripti...
C
/* * This code snippet demonstrates simple use of malloc() to dynamically allocate * memory on the heap. */ #include <malloc.h> int main(int argc, char const *argv[]) { int *array; /* * malloc() returns a void pointer to the allocated memory starting address. * Its argument is the byte size, elements cou...
C
/* 9 巨人航空公司(编程练习 8)需要另一架飞机(容量相同), 每天飞 4 班(航班 102、311、444 和519)。 把程序扩展为可以处理4个航班。 用一个顶层菜单提供航班选择和退出。 选择一个特定航班,就会出现和编程练习8类似的菜单。 但是该菜单要添加一个新选项:确认座位分配。 而且,菜单中的退出是返回顶层菜单。 每次显示都要指明当前正在处理的航班号。 另外,座位分配显示要指明确认状态。 */ #include <stdio.h> #include <string.h> #define NUM_OF_FLIGHTS 4 #define NAMESIZE 12 #define NUM_OF_SEATS ...
C
/* * main.c * * Created on: Mar 5, 2020 * Author: m7med */ //(12) Array that contains integer values, some of these //values are repeated with an even number of repetitions, //and only one value is repeated with an odd number of //repetitions. Write a C function that’s take the array as //input and the arr...
C
#include "collection.h" #include "testHandler.h" #include "testPrinter.h" #include "testPropogate.h" #include <stdlib.h> #include <stddef.h> #include <stdio.h> #include <string.h> int main(int argc, char* argv[]) { char* a = argv[0]; if (argc == 1) { printEmpty(); } else if (argc == 2) { printContradict...
C
/** ****************************************************************************** * @file : my_gpio.c * @version : v1.0 * @brief : надстройка над CubeMX для организации удобной работы с gpio * @author : Стюф Алексей/Alexe Styuf <a-styuf@yandex.ru> *******************************...
C
#include "list.h" #include <assert.h> #include <stdlib.h> void list_free(struct list_node *list) { while (list) { struct list_node *next_list = list->next; free(list); list = next_list; } } struct list_node *list_append(struct list_node *list, char *s) { struct list_node *new_node = malloc(sizeof(struct lis...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> int main() { //calcule uma esfera em funo do raio R expressao: v=(4/3) X PI X (R)^3 float d = 4.0/3.0, pi = 3.14, r, e = 3 ,re , v; printf("Informe o valor do Raio"); scanf("%f ", &r); re = pow(r,e); v=(d*pi*re); printf(" \n Di...
C
#include "auxiliar_projeto.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> /*Daniel Azevedo N2014200607 Nuno Afonso Santos N 2014226541*/ void pedir_dados(Lista triagem) { int n; char num[10]; printf("\nIntroduza 1 para prosseguir e 2 para retroceder:\n\t"); ...
C
void moveInit(Move *moveList) { moveList->name = NULL; moveList->damage = 0; moveList->next = NULL; } void* createMove(char* name, int damage) { Move m = m->name = name; m->damage = damage; return *m; } void addMove(Move *moveList, char* name, int damage) { if(moveList == NULL) { moveList = createMove(mo...
C
../MMult_dgemm.c
C
#include "bstlib.h" #include "utility.h" /* ------------------------------------- */ // UTILITY LIBRARY // // DEVELOPED BY EMMANUEL CANTARELLI // /* ------------------------------------- */ // Clean buffer keyboard void clsBuffer() { while((getchar())!='\n'); } // mainMenu testuale int...
C
#include<stdio.h> int main(int argc, char *argv[]) { int n,x=0,girl,taxi,pizza,c=0,y,i,num,max; scanf("%d",&n); char ch; char s[10]; char name[n][25]; int b[300]={0}; for(i=0;i<n;i++) { scanf("%d",&num); scanf("%s",&name[i][0]); girl=0;taxi=0;pizza=0; whil...
C
/* * Header file for circular queue of HistoryListItems. */ #ifndef __HISTQUEUE_H__ #define __HISTQUEUE_H__ #include "parse_args.h" #define MAXHIST 10 // max number of commands in history list /* * A struct to keep information one command in the history of * command executed */ struct HistoryEntry { ...
C
#include<stdio.h> struct dream{ char name[10]; char country[10]; }; void display(struct dream); void main() { struct dream team = {"barcelona","spain"}; display(team); } void display(struct dream team) { printf("\nmy best football team is %s\n",team.name); printf("foot ball clup barcelona is %s team",team.country...
C
#include <stdio.h> #include <math.h> int main(){ float lambda = 1.0/5.0; float N0 = 10.0; float dt = 0.001; float t_total = 3.0/lambda; int n_points = (int)t_total/dt; int i; float t = 0.0; float n = N0*exp(-lambda*t); printf("%f %f\n", t, n); for(i=0;i<n_points;i++){ t += dt; n = N0*exp(-lambda*...
C
#include<stdio.h> void main() { char a; int b; float c; double d; printf("size of char is %d \n",sizeof(a)); printf("size of int is %d \n",sizeof(b)); printf("size of float is %d \n",sizeof(c)); printf("size of double is %d \n",sizeof(d)); }
C
#include "unp.h" #include <time.h> #include <pthread.h> void * time_srv(void * confd){ int n; char buff[MAXLINE]; fd_set rset; time_t ticks; int connfd = *(int *)confd; struct timeval timeout; int maxfd = connfd+1; FD_ZERO(&rset); for ( ; ; ) { FD_SET(c...
C
// // test_chapter_11_01.c // // Testing purposes - Chapter 11 // String input #include <stdio.h> int main(void){ char somethingBig[4]; float sum = 0.1+0.1+0.1-0.3; printf("Sum is: %.27f", sum); printf("\n"); return 0; }
C
# 1 "<stdin>" # 1 "<built-in>" # 1 "<command-line>" # 31 "<command-line>" # 1 "/usr/include/stdc-predef.h" 1 3 4 # 32 "<command-line>" 2 # 1 "<stdin>" # 1 "./stdlib.h" 1 void __foo(void *arg){ } void abort(void){ return 1; } # 2 "<stdin>" 2 extern int __VERIFIER_nondet_int(); # 15 "<stdin>" void myexit(in...
C
#include <stdio.h> #define N 7 long power(int, int); void prn_heading(void); void prn_tbl_of_powers(int); int main(void) { prn_heading(); prn_tbl_of_powers(N); return 0; } void prn_heading(void) { printf("\n::::: A TABLE OF POWERS :::::\n\n"); } void prn_tbl_of_powers(int n) { int i, j...
C
#include<stdio.h> #include<string.h> main() { char s[] = "I love cat."; char c = 'd'; char* p = NULL; printf("문자열 「%s」안에 문자「%c」", s, c); p = strchr(s, c); if (!p) printf("는 없습니다.\n"); else printf("를 찾았습니다.\n"); } /* 포인터를 이용할 때 그 어드레스에 데이터가 반드시 존재해야한다. 포인터를 초기화하지 않고 사용할 ...
C
/* ** EPITECH PROJECT, 2018 ** connection ** File description: ** connection */ # ifndef RESSOURCES_HH # define RESSOURCES_HH # include "server.h" OBJECT_CREATOR ( Item, String name; int nb; int id; GenerationRarity generationrarity; struct s_Item *next; ); OBJECT_CREATOR ( Ressource, Item *items; );...
C
/*********************************************************** *文件名 : db_api.h *版 本 : v1.0.0.0 *日 期 : 2018.05.03 *说 明 : 数据库相关操作接口 *修改记录: ************************************************************/ #ifndef DB_API_H #define DB_API_H #include "sqlite3.h" /*数据库条目最大长度*/ #define DB_DATA_MA...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_sort_params.c :+: :+: :+: ...
C
/** * UNIX-style pwd command. * * @author Pablo Mayrgundter * @date Sunday, June 15, 2008 */ #include <unistd.h> #include <stdio.h> int main (const int argc, const char * const argv[]) { const char * buf = getcwd(NULL, 0); if (buf == NULL) return 1; printf("%s\n", buf); return 0; }
C
// // Created by bconway on 4/1/19. // “I pledge my honor that I have abided by the Stevens Honor System.” - Brereton Conway #include "cs392_exec.h" #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> #include <sys/wait.h> #define NUMBER_OF_ARGV_WORDS 10 #define LENGTH_...
C
# include "holberton.h" /** * print_alphabet_x10 - First Prorotype/Function */ void print_alphabet_x10(void) { short int letter, j; for (j = 0; j < 10; j++) { for (letter = 97; letter < 123; ++letter) { _putchar(letter); } _putchar(10); } }
C
/* * cpl.c * * Created on: 07.11.2015 * Author: Benedikt */ #include "cpl.h" #include "opcodes.h" void cpl_init(CplState* cs, CplHeader* ch, FILE* fp) { cs->dst = fp; cs->ch = *ch; } void cpl_write_header(CplState* cs) { } void cpl_write_instr(CplState* cs, opcode_t instr) { fputc(instr, cs->dst); } ...
C
/* ** EPITECH PROJECT, 2018 ** solver ** File description: ** compute math functions */ int my_pow_rec(int nb, int p) { if (p < 0) return (0); if (p == 0) return (1); return (nb * my_pow_rec(nb, p - 1)); }
C
#ifndef SCATTER_H #define SCATTER_H #pragma OPENCL EXTENSION cl_khr_fp64 : enable /** @file scatter.h This file contains the definition of channel descriptor, open channel and communication primitive for Scatter. */ #include "data_types.h" #include "header_message.h" #include "operation_type.h" #include ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> struct station { char name[100]; int l; //variable to find path length int count; struct transfer *utransfer; }; struct transfer { struct station *unewstation; int duration; }; typedef struct Node { struct Nod...
C
#include<stdio.h> #include<stdlib.h> #include<math.h> // Hence the difference between the sum of the squares of the first // ten natural numbers and the square of the sum is 3025 − 385 = 2640. // Find the difference between the sum of the squares of the first // one hundred natural numbers and the square of the sum. /...
C
//NAME: Kyle Rosswick //PAW PRINT: klrmt5 //LAB SECTION: L #include <stdio.h> #include <stdlib.h> #include <stdbool.h> bool load_data(char*, int*, double*, char*, int); void print_data(int*, double*, char*, int); int highest_amount(double *, int); int lowest_amount(double *, int); float average_amount(double *, int); ...
C
/* Programa que apresenta a tabuada (de 0 at o 10) de um nmero inteiro informado pelo usurio usando uma estrutura de repetio.: Autor: Felipe Augusto Bortolini Data: 29/09/2020 Teste de Mesa: _______numero_______|________Sada_______| <- 3 | | | 3 x 1 =...
C
#include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <unistd.h> #define BUFFER 999 int main(int argc, char* argv[]) { int fd = socket(AF_INET, SOCK_DGRAM, 0); char buf[BUFFER]; struc...
C
#include<stdio.h> void remplace(char *nom, char ori, char nv) { FILE * f = fopen(nom,"r+"); if (f == NULL) { fprintf(stderr,"Erreur dans l'ouverture de %s\n",nom); } else { while (!feof(f)) { char c = fgetc(f); if (c == ori) { fseek(f,-1*sizeof(char),SEEK_CUR); fputc(nv,f); ...
C
int f(int a,int b){ int c; return a+b; } int main(){ int a; a=f(56,27); printf("\n func ",a); }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define LED_MAX_NAME_SIZE 128 typedef unsigned char u8; void DumpBuffer(unsigned char *buf, int bufSize); void DumpBuffer(unsigned char *buf, int bufSize) { int i = 0; printf("buffer size is %d \n", bufSize); for (i=0; i<bufSize;i++ ){ pr...
C
#include "stdio.h" #include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys/wait.h> #include <fcntl.h> #include <errno.h> #define MAXLINE 256 #define FIFO1 "/tmp/fifo.1" #define FIFO2 "/tmp/fifo.2" #define FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) //default permissions...
C
#include<stdio.h> //定义复数结构体 typedef struct { float realpart; //实部 float imagpart; //虚部 }Complex; //C语言中,函数的定义部分出现在被调用的函数之后,需要在前面声明 /* void assign(Complex* A, float real, float imag); //赋值声明 void add(Complex* A, float real, float imag); //加法 void minus(Complex* A, float real, float imag); //减法 void multiply(Compl...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "effector.h" #include "effdata.h" #include "sma.h" #define DELAY_NUM 16 static int *sma_buf_l, *sma_buf_r; void sma_init(int *param) { int i; sma_buf_l = (int *)malloc(DELAY_NUM * sizeof(int)); sma_buf_r = (int *)malloc(DELAY_NUM...
C
#include<stdio.h> #include<math.h> int main() { int n,num,x,p=1,i; scanf("%d",&n); num = (1+sqrt(1+8*n))/2; for(i=1;i<=num;i++) { scanf("%d",&x); printf("%d ",x-p); p = x - p; } printf("\n"); return 0; }
C
#include <stdio.h> int main(void) { char str[16]; int d,count=1; printf("enter the sentence:"); scanf("%[^\n]s",str); for(d=0;str[d]!='\0';d++) { if(str[d]==' ') { count=count+1; } } printf("\nno of words=%d",count); return 0; }
C
#include <stdio.h> #include <stdlib.h> #define MAX 10 //最大顶点个数 #define INFINITY 65535 typedef struct graph { int num; //顶点个数 int side[MAX][MAX]; //弧 }GRAPH, *PGRAPH; PGRAPH InitGraph(void) // { PGRAPH pG = (PGRAPH)malloc(sizeof(GRAPH)); while(1) { printf("请输入顶点个数:"); ...
C
Problem statement : c program to generate first n Triangular numbers solution : include <stdio.h> void triangular_series(int n) { for (int i = 1; i <= n; i++) printf(" %d ", i*(i+1)/2); } int main() { int n ; printf("Enter value for n\n"); scanf("%d",&n); triangular_series(n); ...
C
#include <stdint.h> /* Max font name length */ #define MAX_NAME 128 /* "bytecode" to encode font pixels */ #define BC_NEWLINE -126 #define BC_EOG -127 /* end of glyph */ #define BC_NUM_SPACES(n) (-1 * n) /* number of consecutive empty pixels in a row */ #define BC_GREY_PIXEL(n) (127 - n / 2) /* 0-25...
C
#include <string.h> #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/wait.h> #include <pwd.h> #include <unistd.h> #include <signal.h> #include <readline/history.h> #include <readline/readline.h> #define CUR_DIR_SIZE 100 #define PROMPT_SIZE 500 #define MAX_PARAMETERS 5...
C
#include "wator.h" #include <pthread.h> /* * Struttura della coda rappresentata attraverso una linked list * */ typedef struct queue { void *info; struct queue *next; }queue; /* * Struttura della coda sincronizzata attraverso coda e mutex * */ typedef struct synqueue { queue *f; /*Primo elemento*/ queue *l; ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* queue_tools.c :+: :+: :+: ...
C
#include <stdio.h> int main(void) { FILE *fp; int i, j; char filename[80]; scanf("%s", filename); fp = fopen(filename, "r"); fscanf(fp, "%d%d", &i, &j); printf("%d\n", i + j); fclose(fp); return 0; }
C
#include <stdio.h> #include <unistd.h> #include <string.h> char *ft_strstr(char *str, char *to_find) { int i; int j; i = 0; if (to_find[0] == '\0') { return (str); } while (str[i] != '\0') { if (str[i] == to_find[0]) { j = 1; while ((to_find[j] != '\0') && (to_find[j] == str[i+j])) { j++; ...
C
#ifndef _List_H struct Node; typedef struct Node *PtrToNode; typedef PtrToNode List; typedef PtrToNode Position; List MakeEmpty(List L); int isEmpty(List L); int isLast(List L); Position find(int Element, List L); void delete(int Element, List L); Position findPrevious(int Element, List L); void insert(int Element, L...
C
#define _GNU_SOURCE #include <stdio.h> #include <dirent.h> #include <sys/stat.h> #include <sys/types.h> #include <fcntl.h> // for open flags #include <time.h> // for time measurement #include <assert.h> #include <errno.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #define FILE_SIZE 128*1024*1024 #de...
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<conio.h> int arm (int x); void main() { int x,r; clrscr(); printf("enter the value"); scanf("%d",&x); r=arm(x); if(r==0) { printf("the no is armstrong no."); } else { printf("the no.is not arm"); } getch(); } int arm(int x) { int a,b,d; int s=0; b=x; while(x>0) { a=x%10; d=(a*a*a); s=...
C
#ifndef DNSINFOC #define DNSINFOC #include "dnsInfo.h" int formalizeURL(char dest[], const char* src) { char* dotPos = dest; dest++; for (int i = 0; i < maxUrlLen; i++, dest++) { if (src[i] == '.') { *dotPos = dest - dotPos - 1; dotPos = dest; } else *dest = src[i]; if (src[i] == 0) { *dotPos = dest - dotPos -...
C
#include <stdio.h> #include <sys/ipc.h> #include <sys/shm.h> #include <string.h> #include <errno.h> #define KEY 0x11112222 #define SIZE 256 #define MODE 0644 #define OPEN_MODE 0444 #define SHM_OK 0 #define SHM_FAILED -1 int test_creat(); int test_write(); int test_read(); int test_delete(); int mai...
C
#include <time.h> #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #define LEFT -2 #define RIGHT 2 static int cnt = 0; typedef struct _avl avl; struct _avl { int data; avl *left; avl *right; }; bool check_dup(int *data, int compare, int idx) { int i; for (i = 0; i < idx; i++) ...
C
#include "hash_tables.h" /** * hash_table_create - build hash table * @size: size hash table * Return: new pointer hash */ hash_table_t *hash_table_create(unsigned long int size) { hash_table_t *htable; unsigned int i; if (size == 0) return (NULL); htable = malloc(sizeof(hash_table_t)); if (htable == NUL...
C
#include <stdio.h> #include <stdlib.h> #include <conio.h> #include <windows.h> int menu(); void limpa_aposta(int *ap); void listar(int *ap); void apostas(int *ap); void sorteio(int *sorteio); int acertos(int *boletim, int *sorteio); void main() { int OpMenu; int boletim[5][7]; int chave[7]; int x; ...
C
# include<stdio.h> # include<string.h> long long mul(long long a,long long b,long long c) { if(b==0) { return 0; } long long regresar=mul(a,b>>1,c); regresar=(regresar+regresar)%c; if(b&1) { regresar=(regresar +a)%c; } return regresar; } int main() { int t,n,l,k; long long int temp,i,j,a,b,c; sc...
C
/* <p>A robot is located at the top-left corner of a <em>m</em> x <em>n</em> grid (marked &#39;Start&#39; in the diagram below).</p> <p>The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked &#39;Finish&#39; in the diagram below).</p>...
C
#include <fcntl.h> #include <string.h> #include <stdio.h> #include <stdlib.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/socket.h> #include <linux/if.h> #include <linux/if_tun.h> int tun_open(char *devname){ struct ifreq ifr; int fd, err; fd = open("/dev/net/tun", O_RDWR); memset(&ifr...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_print_flag.c :+: :+: :+: ...
C
#include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <sys/socket.h> #include <arpa/inet.h> int main(int argc, char *argv[]){ struct sockaddr_in sa = { 0 }; int len; char buff[4096]; int sock = socket(AF_INET, SOCK_DGRAM, 0); // 通信相手のソケットアドレスを作成 sa.sin_family = AF_INET; sa.sin...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* fill_arg_struct.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> #include <strings.h> #include <string.h> #include <hiredis/hiredis.h> //#include "hiredis.h" #include "csp_redis.h" int CspRedisOperation(int databaseNO,int type,char * key, char *value,redisContext * conn){ redisReply *reply =NULL; char Command[COMMANDLEN]={0}; char ...
C
// 快速排序 // 时间复杂度O(nlogn) 空间复杂度O(logn) // 最坏情况下 时间复杂度O(n^2) 空间复杂度O(n) // 主程序,递归实现 void QuickSort(ElemType A[], int low, int high) { if (low < high) { int pivotpos = Partition(A, low, high); // 分治 QuickSort(A, low, pivotpos - 1); QuickSort(A, pivotpos + 1, high); } } // 划分操作 // 每次总是以当前表中第一个原属作为枢轴值(基准)对表进行划分 in...
C
#include <stdio.h> int main(void){ int n = 0; for(n;n<10;n++){ int i = 0; for(i;i<=n;i++){ printf("*"); } printf("\n"); } return 0; }
C
#include <stdio.h> #include <linux/sockios.h> #include <net/if.h> #include <netinet/in.h> #include <string.h> int main(int argc, char **argv) { { int fd; struct ifreq req; fd = socket(AF_INET, SOCK_DGRAM, 0); strncpy(req.ifr_name, "eth0", IFNAMSIZ); ioctl(fd, SIOCGIFADDR, &...
C
#include<stdio.h> #include<math.h> int main() { int num,c=0,result; printf("Enter number "); scanf("%d",&num); result=b_num(num,c); d_num(result); return 0; } int b_num(int num,int c) { int rem,b_num=0,i=0; ...
C
// EUHEXDMP.H // // Copyright (C) Symbian Software Ltd 1997-2005. All rights reserved. // _LIT(KTxtTwoSpaces," "); _LIT(KTxtThreeSpaces," "); _LIT(KTxtTwoSpaceStar," * "); _LIT(KTxtOneSpaceStar," *"); _LIT(KFormat1,"%S\n"); inline void hexDump(const TDesC8& aBuffer,TInt32& aAddress,TInt32& aOffset,TD...
C
#include <stdio.h> void insert_sort(int k[],int n); int main (void) { int array[] = {3,2,1,9,7,5,8,4,0,6,10}; int i; insert_sort(array,11); printf("array after sort:\n "); for(i=0;i<11;i++){ printf("%d ",array[i]); } return 0; } void insert_sort(int k[],int n) { ...
C
#include <stdlib.h> #include <stdio.h> #include <limits.h> #include "graph.h" #include "dijkstra.h" #include "heap.h" void print_array_nodes(const array* Queue) { for(int i = 0; i < Queue -> size; i++) { node * current = Queue -> nodes[i]; printf(" %d ", current -> id); } } void...
C
#include<stdio.h> #define size 20 int main() { int arr[size][size],i,j,n,count1=0,count2=0,k=0; scanf("%d",&n); for(i=0;i<n;i++) for(j=0;j<n;j++) scanf("%d",&arr[i][j]); for(i=0;i<n;i++) { for(j=0;j<n;j++) printf("%3d",arr[i][j]); printf("\n"); } if(n==2) { if(arr[0][1]==0) ...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> int main() { char *a = malloc(6*sizeof(char)); printf("%p\n",a); strncpy(a,"hello",5); printf("%p\n",a); a[5] = '\0'; puts(a); return 0; }
C
#include <stdio.h> #ifdef __STDC_NO_ATOMICS__ #define autch 1 #else #define autch 0 #include <stdatomic.h> #endif #ifdef __STDC_NO_THREADS__ #define threadsautch 1 #else #define threadsautch 0 #include <threads.h> #endif int main () { printf("hello atomic world\n%d\n%d\n", autch, threadsautch); return 0; }...
C
#include <stdio.h>; #include <math.h>; void main() { double step = 0.2; int interval[2] = { 2, 4 }; double x; double y; for (double i = interval[0]; i <= interval[1] + 0.1; i += step) { x = i; if (x <= 3) { y = log10(pow(x, 3)); } else if (3 < x < 3.5) { y = 1 / fabs(sin(x)); } else if...
C
/* LIST1301.c: Day 13 Listing 13.1 */ /* Demonstrates the break statement. */ #include <stdio.h> char s[] = "This is a test string. It contains two sentences."; int main(void) { int count; printf("\nOriginal string: %s", s); for (count = 0; s[count] != '\0'; count++) if (s[count] == '.') { s...
C
#include<stdio.h> #define LENGTH 500 int main() { char text[LENGTH]; printf("Please choose the operation you want:\nEnter E to encrypt\nEnter D to decrypt\n"); char choice=getchar(); if(choice=='E') { printf("Please enter the text needs to be encrypted:\n"); scanf("%s",&text); for(int i=0;i<...
C
#include "define.h" #include <malloc.h> #include <stdio.h> #include <stdlib.h> /* |------------------------------------------------------------------------------------------------- |队列的链式存储结构 |------------------------------------------------------------------------------------------------- |入队列的时间复杂度为O(1) |出队列的时间复...
C
#include<stdio.h> #include<ctype.h> int contaPal (char s[]){ int conta = 0; if(s[0] != '\0') conta++; int i = 0; while (isspace(s[i]) != 0){ i++; } while (s[i] != '\0') { if (isspace(s[i]) != 0 && isspace(s[i-1]) == 0) conta++; i++; } if (isspace (s[i-1]) != 0){ conta--; } ...
C
// ce programme est pour faire un plot en html5 de la fonction du quantificateur /* gcc -Wall -o plot.exe plot_wsub2.c */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> /* fonction de quantification generique */ double quantif( double x, double q ) { double qx; int ix; if ( q == ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_eight_queens_puzzle.c :+: :+: :+: ...
C
/* Author: Golia Simone Program: An example of sorting array using Quicksort Algorithm */ #include <stdio.h> #include <stdlib.h> #define SWAP(type, a, b) {type tmp = a; a=b; b=tmp;} int* scanArray(int* dim); void printArray(int* array, int dim); void quickSort(int* array, int start, int end); int partition(int* a...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* stack.c :+: :+: :+: ...
C
#include "M083040024.h" void Init_Array(int a[] , ConstInt size) //Initialize an array { int i; for( i = 0 ; i < size ; i++ ) a[i] = -1; } void Generate_Sequence_write( int a[] ) //Generate a sequence of random write number { int i; for(i = 0 ; i < REFERENCE_SIZE ; i++) { if( rand() % 3 == 0) a[i] = 1; ...
C
#include "biblio.h" boolean estUnPalindrome(char *chaine) { int i; int longueur; boolean idem=TRUE; longueur=strlen(chaine); for (i=0;i<longueur/2;i++) { if (chaine[i]!=chaine[(longueur-1)-i]) { idem=FALSE; } } return idem; }
C
#include <stdio.h> #include <string.h> // strNcat kulanınca belirtilen sayı kadar karakter dest'e kopyalanır. eğer belirtilen karakterler kopyalanırken NULL karakteri ile kariılaşılırsa null karakterinden sonraki // karakterler kopyalanmazlar. // strcat belirtilen stringden dest stringine null karakterini görünceye...