language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
//#include "cuda_runtime.h" //#include "device_launch_parameters.h" #include <stdlib.h> #include <stdio.h> //#include <iostream> #include <math.h> //#include <iomanip> #define X 1 #define Y 4 #define Z 4 #define N 1 static inline int MAX(int a, int b) { if (a > b) { return a; } return b; } void printMatrixMul...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* type_csp.c :+: :+: :+: ...
C
/* Take a note of the main function parameter. There is an extra item of char * envp[]. This allows the program to retrieve the system environment variable. */ #include <stdio.h> int main(int argc, char *argv[], char *envp[]){ int i; for(i = 0; envp[i]; i++){ printf("[%d] = %s\n", i, envp[i]); ...
C
#include<stdio.h> #include<math.h> void main(){ int x1, y1, x2, y2, radius; float dis; printf("Enter the center points "); scanf("%d %d", &x1, &y1); printf("Enter the radius of the circle: "); scanf("%d", &radius); printf("Enter the points "); scanf("%d %d", &x2, &y2); dis = sqrt(pow(x2-x1,...
C
/* ** EPITECH PROJECT, 2021 ** zappy ** File description: ** main */ bool add_id(int **ids, int const id) { int *tmp = *ids; unsigned int len = 0; int *new = NULL; if (tmp) for (unsigned int j = 0; tmp[j]; ++j) ++len; new = malloc(sizeof(char) * (len + 2)); ...
C
/* * Developed by Rafa Garcia <rafagarcia77@gmail.com> * * queue.c is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * queue.c...
C
/** * @file sudoku.c * @author Juan Gonzalez * @brief main sudoku code */ #include <stdio.h> #include <string.h> #include <stdint.h> #include <inttypes.h> #include <stdlib.h> #include <stdbool.h> #include <getopt.h> #include "sudoku.h" #include "version.h" enum moves_t { ZERO = 0x0, ONE = 0x1, TWO = 0x2, THRE...
C
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <assert.h> typedef struct node { struct node *next; int64_t val; } listnode_t; /* floyd's cycle detection algorithm */ int cycle_detect(listnode_t *head) { listnode_t *fast, *slow; slow = head; fast = head; while...
C
#include <stdio.h> #include <stdlib.h> int main() { long num; long suma=0L; int stan; printf("wpisz liczbe calkowita"); printf("wpisz litere aby zakonczyc\n"); stan=scanf("%d",&num); while(stan==1) { suma+=num; printf("podaj kolejna liczbe calkowita"); printf...
C
#ifndef NEWLINE_H #define NEWLINE_H string add_newline(string str) { string lchar; if(!str) return "\n"; lchar = extract(str,strlen(str)-1); return (lchar == "!" || lchar == "." || lchar == "?") ? str + "\n" : (lchar == "\n") ? str : str + ".\n"; } #endif
C
#include <stdio.h> int main () { long int l=0,r,k; scanf("%d",&k); while(k) { r=k%10; k=k/10; l++; } printf("%d",l); return 0; }
C
#include <stdio.h> #include <stdlib.h> #include "nmea.h" /* takes a line from a NMEA file and extracts the message and the checksum */ status_t get_NMEA_message(string NMEA_message, uint *checksum) { char *tmp; if(NMEA_message == NULL || checksum == NULL){ return ERROR_NULL_POINTER; } /* Go o...
C
/* | PC-LISP (C) 1984-1989 Peter J.Ashwood-Smith */ #include <stdio.h> #include <math.h> #include "lisp.h" /************************************************************************* ** buascii : given a realatom parameter it will return an alpha atom of** ** one character corresponding to the ascii value of the ...
C
//damorenor + joacarrilloco #include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> #define REGISTER_SIZE ( (int) 1e7 ) #define NOMBRE_SIZE 32 #define TIPO_SIZE 32 #define RAZA_SIZE 16 #define TOTAL_NAMES 1716 #define TOTAL_BREEDS 13 #define HASH_SIZE 10007 #define MOD 256 struct dogType { ...
C
/* a. write(STDOUT_FILENO, &buff, count) This will write the contents on char buffer named 'buff' (from its index 0 to the index 'count-1') to the standard output (default; to the terminal) b. Theoretically it is possible to read and write from both ends. But if both parent and child write to the pipes at same ti...
C
#include <GL/glut.h> /* 再描写時に実行される関数*/ void display(void) { /* 画面全体を指定した色で塗りつぶす */ glClear(GL_COLOR_BUFFER_BIT); /* まだ実行されていない命令をすべて実行 */ glFlush(); } int main(int argc, char **argv){ glutInit(&argc, argv); /* ウィンドウの位置とサイズを指定 */ glutInitWindowPosition(100, 100); glutInitWindowSize(400...
C
#include "buttons.h" // Button states // 0 : Idle // 1 : Press :: first press // 2 : Release :: still pressed char btn_sw1_state=0, btn_sw2_state=0; void btn_onSW1ButtonDown(void); void btn_onSW2ButtonDown(void); void btn_onSW1ButtonUp(void); void btn_onSW2ButtonUp(void); /**************************...
C
#include <stdio.h> #include <stdlib.h> int main () { int i = 5, *p; p = &i; printf(“%u %d %d %d %d \n”, p, *p+2, **&p, 3**p, **&p+4); return 0; }
C
#include <avr/io.h> #include <avr/interrupt.h> #include <avr/signal.h> unsigned int A=0; // unsigned int B=0; unsigned int C=0; unsigned int i=0; void INIT() // { PORTB=0; DDRB=0xff; PORTG=0; DDRG=0b11;// 0 1 2 3 4 5 6 7 8 9 const unsigned int buffer[9]={63,6,91,79,102,109,125,7,127,111}; ...
C
#include "graph.h" //This file contains graph utility functions // create a new adjacency list node Node* newListNode(int v, int w) { Node* newNode = (Node*)malloc(sizeof(Node)); newNode->v = v; newNode->w = w; newNode->next = NULL; return newNode; } // A utility function that creates a graph of...
C
#include "FIF.h" PRAGMA_FIF_OBJ PRAGMA_FIF_Initialize(PRAGMA_FIF_CONFIG config) { PRAGMA_FIF_OBJ F; F.FIF.SELF = config.FIF_MAP; F.FIF.RTR = 1; F.FIF.RTS = 0; F.FIF.DESTINATION = 0x00; F.FIF.TIP = 0; F.PRAGMA_FIF_cntMAP = config.PRAGMA_FIF_cntMAP; F.state = READY; return F; } void...
C
/* ** PERSONAL PROJECT, 2019 ** 2_pow_computer ** File description: ** 2 powers computer settings setup */ #include <stdlib.h> #include <getopt.h> #include "../include/2pow.h" #include "../include/my.h" static uint limit_slow(int slow) { if (slow > 100000000) return (0); return (slow); } static char ...
C
#include <stdio.h> int main(){ double N[12][12], sum=0; char O[2]; int i, j, n=1, m=10; scanf("%s", &O); for(i = 0; i < 12; i++) for(j=0; j < 12; j++) scanf("%lf", &N[i][j]); for(i = n; i < m; i++){ for(j = 0; j <= 5; j++){ sum += N[i][j]; } n++; m--; } ...
C
#include <stdio.h> #include <errno.h> #include <string.h> #include <stdlib.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> /* receive udp packets * * usage: recv-udp [port] */ #define BUFSZ 200 int main(int argc, char *argv[]) { char buf[BUFSZ]; int rc, port; /********************...
C
//#define _XOPEN_SOURCE 500 #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <signal.h> #include <string.h> #include <sys/wait.h> #include "sh.h" #include <pthread.h> void sig_handler(int sig){ printf("\ncaught signal\n"); signal(sig, SIG_IGN); } int main(int argc, char **argv, char **envp)...
C
#include <stdio.h> #include <stdlib.h> /* Zad. 8. Napisz funkcj, ktra znajduje sum elementw oraz sum wartoci bezwzgldnych elementw tablicy. */ void suma(int tab[], int *sum){ int i; for (i=0; i<5; i++){ if(tab[i] <0) tab[i]*=(-1); *sum += tab[i]; } printf("suma %d", *sum); } int tab1[5] ={8, -...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <stdbool.h> #include "common.h" void create_report(int size, struct report *r) { FILE *report_file; int i = 0; report_file = fopen("report.mpi-matrix.txt", "a"); printf("\nReport of MPI performance for %d as the specified si...
C
// htab_clear.c // Brief: IJC-DU2, part 2) // Date: 19.4.2020 // Author: Peter Urgoš - xurgos00, FIT VUT Brno #include "htab_internal.h" void htab_clear(htab_t * t) { for (size_t i = 0; i < htab_bucket_count(t); i++) { if (t->items[i] == NULL) { continue; } struct ...
C
#include <stdio.h> #include <math.h> int main(int argc, char** argv) { float x, y; scanf("%f %f", &x, &y); x = x * M_PI / 180; y = y * M_PI / 180; //(1-tg x)^(ctg x)+ cos(x-y). printf("%f\n", pow(1 - tan(x), (cos(x) / sin(x))) + cos(x - y)); return 0; }
C
/* El Servidor */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <signal.h> #include <sys/types.h> #include <sys/socket.h> #include <arpa/inet.h> #include <netinet/in.h> #include <netdb.h> #include <sys/un.h> #include <time.h> #include <sys/time.h> #include <sys/un.h> #include<unistd.h> #include ...
C
/*C program used to keep track of the number of people entering an Art Exhibition. This program has 4 functions, One which is called when a person enters the exhibition. One which is called when a person leaves the exhibition. The ticket costs 8. Another Function should keep a track of total amount of money that has b...
C
#include "cp2task1headers.h" void bcvelocity(int nx, int ny, float* u, float* v){ /*Sets zero-gradient collocated BCs*/ int i,j,ij,ijw,ije,ijn,ijs; for(i=0;i<nx+2;i++){ //Bottom surface j=0; ij = i +j*(nx+2); ijn = i + (j+1)*(nx+2); u[ij] = u[ijn]; v[ij] = v[ijn]; //Top surface j = ny+1;...
C
int main(int argc, char* argv[]) { char s[101],pre; int i; gets(s); pre='-'; for(i=0;s[i]!='\0';i++) { if(s[i]!=' ') printf("%c",s[i]); else if(pre!=' ') printf(" "); pre=s[i]; } return 0; }
C
#ifndef __AC_KSW_H #define __AC_KSW_H struct _ksw_query_t; typedef struct _ksw_query_t ksw_query_t; typedef struct { // input unsigned gapo, gape; // the first gap costs gapo+gape unsigned T; // threshold // output int score, te, qe, score2, te2; int tb, qb; // tb and qb are only generated when calling ksw_alig...
C
#include <p24F16KA102.h> #include "uart.h" void UART1Init(int BAUD){ U1BRG = BAUD; U1MODE = 0x8000; U1STA = 0x8400; IFS0bits.U1RXIF = 0; } void UART1DMXInit(int BAUD){ U1BRG = BAUD; U1MODEbits.RXINV = 0;//idle is one? U1MODEbits.BRGH = 1; //high speed mode U1MODEbits.PDSEL = 0b11;//9...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> struct cmd { //char *command[8]; char command[8][256]; char in[256]; char out[256]; }x, *p = &x; void analysis_cmd(char *a) { int i = 0, j = 0, k = 0; int flag = 1; int in_i = 0, out_i = 0; int len; //p = (struct cmd *)mall...
C
#include<stdio.h> #include<string.h> int main() { char str[60]; int l,n,flag,count=0; scanf("%d", &n); while(n--) { l=0; flag=1; fflush(stdin); gets(str); l=strlen(str); if(l%2!=0) flag=0; else { } ...
C
#include <WiFi.h> #include "PubSubClient.h" #include "arduino_json.h" const char* mqtt_server = "192.168.0.100"; unsigned int red = 0, green = 0, blue = 0; // the Red Green and Blue color components bool color_change = false; bool power_off = false; WiFiClient espClient; PubSubClient client(espClient); long...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_itoa.c :+: :+: :+: ...
C
#include "holberton.h" /** * rot13 - function that encodes * @s: string to be encoded * * Description: function that encodes a string using rot13 * Return: an encoded string */ char *rot13(char *s) { int i, j; char ab[] = {"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"}; char ro[] = {"nopqrstuvwxyzab...
C
/*! Command.c Authors: Gabriela Marques and Leonardo Mizoguti Updated: 2015-10-28 */ #include "Command.h" /*! @const CMND_NEXT_STATE @abstract Table indicating to which state the automaton must go given a current state and the value of the input token. @discussion The lines in this table repr...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> char aStack[20]; int aTop = -1; //Please implement all the functions int isEmpty (char stack[], int* pTop) { // This assignment was extremely vague and poorly defined // imma do obfusicated C challenge :D return !*stack; // pls add `inline` to fxn def } i...
C
#include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <sys/wait.h> #include <stdio.h> #include <limits.h> int main(int argc, char *argv[]) { int fd1 = open(argv[2], O_RDONLY); int fd2 = open(argv[3], O_CREAT | O_WRONLY | O_APPEND, 0660); int fd3 = open(argv[4], O_CRE...
C
#include<stdio.h> #include<conio.h> void main() { int i,j; clrscr(); for (i = 1,j = 10;i<10 && j>=1;i+=2, j -=2) printf(" %d %d",i,j); getch(); }
C
#include<stdio.h> #include<stdlib.h> #include<string.h> void main(int argc,char **argv) { int i,c; char ch,s[50]; FILE *fp; if(argc!=3) { printf("Missing operand.\nUsage.: ./a.out file word\n"); return; } fp=fopen(argv[1],"r"); if(fp==0) { printf("File is not present.\n"); return; } c=0; while(fscanf(fp,"%s",s)!=-...
C
/*****************************************************************/ /* Class: Computer Programming, Fall 2019 */ /* Author: 胡紹宇 */ /* ID: 108820008 */ /* Date: 2019.11.14 ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_printf.c :+: :+: :+: ...
C
/* ** EPITECH PROJECT, 2018 ** PSU_2017_nmobjdump ** File description: ** stor_function */ #include <zconf.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include "server.h" #include "lib/get_next_line.h" static bool err_create_file(server_t *serv) { write_to_client(serv, "550 Faile...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strcdup_loop.c :+: :+: :+: ...
C
#include <stdarg.h> #include <stdio.h> int sum(int n, ...) { int sum = 0; va_list vl; va_start(vl, n); for (int i = 0; i < n; i++) { sum += va_arg(vl, int); } va_end(vl); return sum; } int main() { printf("%d\n", sum(3, 2, 3, 4)); return 0; }
C
#include "Z-OS.h" #include <stdlib.h> #include <string.h> Int16 TotalMemAllocs = 0; Int64 TotalMemUsage = 0; #define Word UInt16 #define WordSize sizeof(Word) #define HeapSize 5000 __attribute__ ((__far__)) Word MainHeap[HeapSize] = {0}; size_t FreeWords = HeapSize; void HeapInit(void* heap, size_t ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define NIL -1 int test_biggest = 0; int biggest_scc = 0; int number_connections_scc = 0; int number_of_scc = 0; int visited = 0; typedef struct edge Edge; typedef struct stack Stack; typedef struct vertex Vertex; typedef struct list List; typedef struct sta...
C
/* ** nbr.c for nbr in /root/rendu/CPE_2014_corewar/asm ** ** Made by ** Login <-n@epitech.net> ** ** Started on Sun Aug 10 12:08:01 2014 ** Last update Sun Aug 24 21:29:05 2014 chenev_d chenev_d */ #include "utils.h" static void _check_nbr(const char *str) { int i; i = (str[0] == '-') ? 0 : -1; if (str[0]...
C
/* Write a C program that reads the hours an employee worked in a week, computes the gross pay and income tax, and prints the gross pay, income tax and net pay on the screen. Assume that the pay structure and tax rate are given as follows: (1) the basic pay rate is $6.00 per hour; (2) the over-time pay rate (in exc...
C
int minlen(char** strs, int strsSize){ int i,j,len=0,min=99999999; for(i=0;i<strsSize;i++){ if(strs[i]==NULL) return 0; len=0; for(j=0;strs[i][j]!='\0';j++){ len++; } if(len<min) min=len; } return len; } char* longestCommonPrefix(char** strs, int strsS...
C
#include<stdio.h> #include<stdlib.h> main () { float f,c,pol,mm; printf("Escreva a temperatura: \n"); scanf("%f",&f); c=(5*f-160)/9; printf("%f\n",c); printf("Escreva a quantidade de chuva: \n"); scanf("%f",&pol); mm=pol*25.4; printf("%f\n",mm); sy...
C
#ifndef CHAPTER03_LINKED_QUEUE_H #define CHAPTER03_LINKED_QUEUE_H typedef char ElemType; // 链队数据结点类型 typedef struct QNode { ElemType data; // 下一结点指针 struct QNode *next; } DataNode; // 链队结点类型 typedef struct { // 指向队首结点 DataNode *front; DataNode *rear; } LinkQuNode; /** * 初始化链队 * @param queu...
C
#include<stdio.h> int main() { long long int a; scanf("%I64d",&a); if(a%2==0 && a!=2) printf("YES"); else printf("NO"); return 0; }
C
/** * Samuel Sweet * CS 5600-1 Assignment 5 * * Represents useful information about * an object that a ray has hit. */ #ifndef HITDATA_H #define HITDATA_H #include "vector.h" #include "material.h" typedef struct _HitData { Vector3D surfaceNormal; Vector3D intersectPoint; Material material; float in...
C
#include "aluno.h" #define SUCCESS 0 #define INVALID_NULL_POINTER -1 #define OUT_OF_MEMORY -2 #define OUT_OF_RANGE -3 #define ELEM_NOT_FOUND -4 #define INVALID_POS -5 typedef struct list List; List *list_create(); //Cria a Lista int list_free(List *li); //Libera a lista int list_push_front(List *li, Aluno al); //In...
C
#include <stdio.h> #include <string.h> struct student { char name[30]; char id[10]; int age; char course[30]; } student1; void main() { // struct student student1; // struct student student1 = {"Vic", "123456", 25, "CS"}; struct student s[10]; // Declaring the variables manually // strcpy(studen...
C
#include<stdio.h> int n; char s[6000]; int min(int a,int b) { return a>b?b:a; } int isPallin(int i,int j) { int k,l; for(k=i,l=j;k<j;k++,l--) if(s[i]!=s[j]) return 0; return 1; } int calc(int i,int j) { if(i>j||i==n||j==n) return 0; if(isPallin(i,j)){ prin...
C
/* ** Warning: for big pattern length, libgmp will be required to handle >64bits integers */ #include <stdio.h> #include <stdlib.h> #include <string.h> #define REHASH(a,b,h) ((((h) - (a)*d) << 1) + b) int rabin_karp(char *text, char *pattern) { unsigned int tsize, psize; int ht, hp; int i, d; tsize = strlen(tex...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_lserror.c :+: :+: :+: ...
C
#include <stdio.h> void main() { int array[10] = {785, 428, 612, 812, 307, 19, 723, 1024, 305, 492}; int i; for(i = 9;i>= 0;i--) printf("%d ", array[i]); }
C
#include<stdio.h> #define NAME_LEN 64 struct student { char name[NAME_LEN]; int height; float weight; long schools; }; int main(void) { struct student takao = {}; printf("请输入姓名为:"); scanf("%s", &takao.name); printf("请输入身高为:"); scanf("%d", &takao.height); printf("请输入体重为:"); scanf("%f",...
C
/* * items.c * * Created on: Sep 26, 2020 * Author: eddie */ #include "items.h" #include <stdlib.h> #include <stdio.h> #include <string.h> /** * Takes in name and description strings and a pointer to item to link to * Creates items with given data and returns pointer to item */ struct It...
C
/*PMSat -- Copyright (c) 2006-2007, Lus Gil 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, modify, merge, publish, distr...
C
#include<stdio.h> #include<conio.h> int a[15],i,ptr,t,j,n; void main() { clrscr(); printf("\nEnter no. of array elements"); scanf("%d",&n); printf("\nEnter array elements"); for(i=1;i<=n;i++) { printf("\nEnter %d element",i); scanf("%d",&a[i]); } for(i=1;i<=n-1;i++) { ptr=1; while(ptr<...
C
//Whatever you are trying to return from dequeue function to show it as an error should not be a member of queue. //We are going to use circular representation of an array in order to use the free spaces available in queue. //Even though the size of array is max we will use it as if it is max-1 queue and leave a blan...
C
#include "ush.h" static t_list *get_process_by_cmd(char *arg, t_list *processes) { t_list *ret_process = NULL; unsigned int count_processes = 0; t_process *tmp = NULL; while (processes) { tmp = (t_process*)processes->data; if (!mx_get_substr_index(tmp->cmd, arg)) { count_pr...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <stdbool.h> #include <limits.h> #define N 10 #define M 10 #define LOWER 0 #define UPPER 100 void matrixFillRand(int matrix[N][M], int height, int width, int lowerBound, int upperBound) { for (int i = 0; i < height; i++) { for (int j = 0; j < width; ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* light.c :+: :+: :+: ...
C
#ifndef __VINT2_H__ #define __VINT2_H__ #include "StdMath.h" #include "VFactor.h" struct VInt2 { int32_t x; int32_t y; static const VInt2 zero; static const int32_t Rotations[]; int32_t sqrMagnitude() const { return (int32_t)sqrMagnitudeLong(); } int64_t sqrMagnitudeLong()...
C
#include "driverlib.h" #include "device.h" #include "events.h" #include "everythings.h" #include "leds.h" bool systickFlag=false; __interrupt void cpuTimer2ISR ( void ); void initCPUTimers ( void ); void ...
C
#include <stdio.h> #include <string.h> #include <ctype.h> #include "statistics/datafile.h" #include "statistics/ttest.h" #include "util.h" typedef struct parse_test_type_result_t{ TTestType type; bool isValid; } ParseTestTypeResult; ParseTestTypeResult parseTestType(const char * type) { if (0 == strcasecm...
C
#ifndef TREE_H #define TREE_H // Tree structure based on double-linked lists and array. struct Tree; typedef struct Tree Tree; // Main functions. extern void initializeTree(Tree**); extern void destroyTree(Tree*); // Auxiliary functions. extern void addTreeNode(Tree*, int); void splitTreeNodeByIndex(Tree*, int, int)...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <errno.h> #include <sys/mman.h> #include <sys/stat.h> #include <fcntl.h> #define NAME_POSIX_SHM "/mmapfile" #define SZ_SHM_SEGMENT 4096 int main() { int shm_fd; char *shm_ptr; int n_read = 0; size_t n_input = 128; char *p_i...
C
#include <stdio.h> int main() { int row,column,s1,s2,x,y,score=0; scanf("%d%d",&row,&column); char array[row][column]; char flag,a; for(int i=0;i<row;i++) { for(int j=0;j<column;j++) { if(i==0||i==row-1||j==0||j==column-1) { array[i][j]='#'; } else { array[i][j]=' '; } } } scanf...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #define N 4 #define M 33 int main(int argc, char *argv[]) { int array[N][N]; int final_array[N][N]; int i, j; clock_t start, end; start = clock(); for (i = 0; i < N; i++) { for (j = 0; j < ...
C
/* ** Packed Move ** ** Moves string `s' to storage area `b' of length `l' bytes. If ** `s' is too long, it is truncated, otherwise it is padded to ** length `l' with character `c'. `B' after the transfer is ** returned. */ char *AApmove(s, b, l, c) register char *s; register char *b; register int l; register int c;...
C
#include "./ft_strcpy.c" #include <stdio.h> int main(void) { char *src = "A vida e loka"; char dest[13]; printf("%s\n", dest); ft_strcpy(dest, src); printf("%s\n", dest); }
C
#ifndef _H_MISC #define _H_MISC /** A compile time assertion check. * * Validate at compile time that the predicate is true without * generating code. This can be used at any point in a source file * where typedef is legal. * * On success, compilation proceeds normally. * * On failure, attempts to typedef...
C
#include <stdio.h> int main() { /* Para as declarações do tipo char e int os valores mostrados pelo programa estão bem parecidos com o que eu idealizei. Agora para os valores mostrados para as variáveis quando elas são declaradas como dos tipos float e double, minhas suposições não estavam corretas, po...
C
#include <stdio.h> int main(void) { int i, j, r, c, row, col, addrow, addcol; char init[50][50], mid[250][250], end[250][250]; scanf("%d %d %d %d", &row, &col, &addrow, &addcol); for(r = 0; r < row; r++) for(c = 0; c < col; c++) scanf(" %c", &init[r][c]); for(r = 0; r < row; r++) { i = 0; for(c = 0; c...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* client.c :+: :+: :+: ...
C
#include "mt.h" int main(int argc, char *argv[]) { if(argc != 2) { printf("Uso: %s <dirección IP>\n", argv[0]); return -1; } struct sockaddr_in sin; sin.sin_family = AF_INET; sin.sin_port = htons(PORT); if(inet_aton(argv[1], &sin.sin_addr) == 0) { printf("IP inválido.\n"); return -1; } int s = socke...
C
#include "state_machine.h" typedef enum { STATES_A = 0x0100, STATES_B, STATES_C } ; static void _action_a (state_machine_t* this, char* reason) { } static void _action_b (state_machine_t* this, char* reason) { } static void _action_c (state_machine_t* this, char* reason) { } void SM_second_state_2_acti...
C
#include <stdio.h> #include <string.h> #include <ctype.h> #include <math.h> #define N 100 int powplus(int n, int k) { int s = 1; while (k--) { s *= n; } return s; } int sum1(int n) { return powplus((n + 1) * n / 2, 2); } int sum2(int n) { return (n * (n + 1) * (2 * n + 1)) / 6; } ...
C
#include <Python.h> int fac_function(int n){ if (n > 1) { return n*fac_function(n - 1); } return 1; } static PyObject* _fac_function(PyObject *self, PyObject *args) { int _n; int res; if (!PyArg_ParseTuple(args, "i", &_n)) return NULL; res = fac_function(_n); return PyLong_FromLong(res); } static PyMeth...
C
#include <stdio.h> #include <stdlib.h> struct Node{ int data; struct Node *next; struct Node *prev; }; struct Node *head = NULL; void display_beg(){ if(head == NULL){ printf("\nList is empty....\n"); } else{ struct Node *temp; temp = head; printf("\nThe elements...
C
#include <stdio.h> void printArr(int *arr, int size) { int i; for (i = 0; i < size; ++i) { printf("arr[%d]=%d\n", i, arr[i]); } } void printArrString(char *arr, int size) { int i; for (i = 0; i < size; ++i) { printf("arr[%d]=%c\n", i, arr[i]); } } void passAsPointer(int *arr, int siz...
C
#include "AI.h" #include "Game.h" #include "PlayList.h" // Handle a Human v. AI game void Inky(int board[3][3], PLAY *p1, PLAY *p2, PLIST *l) // Human is always player1 and AI is player2 { printf("Human v. AI game started\n"); PLAY *d = CreatePlay(0, '0', 'd', "ZZ", board); AppendPlaySnapshot(l, d); print_fun(boar...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.c :+: :+: :+: ...
C
/*模块头文件*/ #include <linux/init.h> #include <linux/module.h> /*驱动注册的头文件,包含驱动的结构体和注册和卸载的函数*/ #include <linux/platform_device.h> /*注册杂项设备头文件*/ #include <linux/miscdevice.h> /*注册设备节点的文件结构体*/ #include <linux/fs.h> /*其他需要头文件*/ #define DRIVER_NAME "hian_deviceName" #define DEVICE_NAME "hian_deviceName" MODULE_...
C
#include "soplib.h" #define BACKLOG 3 volatile sig_atomic_t do_work = 1; void sigint_handler(int sig) { do_work = 0; } void usage(char *name) { fprintf(stderr, "USAGE: %s socket port\n", name); } void calculate(int32_t data[5]) { int32_t op1, op2, result, status = 1; op1 = ntohl(data[0]); op2 = n...
C
#include <stdio.h> #include <stdlib.h> int main() { char *strss; int num = 66; sprintf(strss, "%d", num); printf("str = %s\n", strss); return(0); }
C
//非递归的先序遍历 //先序遍历的顺序是根左右。对于任意一个结点都可以看成是一个根结点,直接对其访问,如果访问完成后,左孩子不为空,将左孩子看成是一个新的根结点,重复以上步骤。对于一般程序而言,递归程序转换为非递归程序需要引入栈这个数据结构。注意到栈的先进先出的特性,根节点入栈,判断右孩子是否为空,若为空,则右孩子入栈。若为左孩子或右孩子为空则出栈访问,最后知道栈为空,则出栈访问 void PreOrderBiTree(BiTNode *T){ SqStack(&S); InitSqStack(S); BiTNode *p=T; Push(S,p); while(p||isEmpty(&S)!=0){ p=Po...
C
#include <stdio.h> #include <stdlib.h> #include"plante.h" #include <string.h> #include<gtk/gtk.h> enum { ID, NOM, EMPLACEMENT, PERIODE, DATE, NOMBRE, TEMPS, COLUMNS }; //////////////////ajouter une plante void ajouter_plante(plante p) { FILE *f; f=fopen("plantes.txt","a+"); if (f!=NULL) {fprintf(f,"%s %s %...
C
#ifndef CACHEDQUEUE_H_ #define CACHEDQUEUE_H_ #include "queue.h" typedef struct CachedQueue CachedQueue; struct CachedQueue { Queue* queue; /* base class */ /* new attributes */ char filename[80]; int numberElementsOnDisk; /* aggregation in subclass */ Queue* outputQueue; /* inherite...