language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
// The MIT License (MIT) // // Copyright (c) 2013 Alex Kozlov // // 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, cop...
C
// // Created by Suraj M on 1/27/19. // #include "matrix.h" #include <stdlib.h> #include <stdio.h> #include <memory.h> #include <math.h> int sign(int num){ if((num % 2 ) == 0){ return 1; } else{ return -1; } } Matrix makeMatrix(int num_rows) { Matrix matrix; matrix.va...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> // Swap utility void swap(long int* a, long int* b) { int tmp = *a; *a = *b; *b = tmp; } /* void BubbleSort(long int arr[], long int n) { long int i, j; for (i = 0; i < n - 1; i++) ...
C
#include <stdio.h> // ϱ void main() { float input[3]; for (int i=0; i < 3; i++) { printf("%d ° :", i + 1); scanf("%f", &input[i]); } printf(" : %.3f", (input[0] + input[1] + input[2]) / 3); }
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <linux/input.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #include <errno.h> #include <string.h> #include <signal.h> #define DEVS_FILE "/proc/bus/input/devices" #define BUF_LEN 4096 #define DEV_ST_LINE 9 #define DEV_LIN...
C
#include<stdio.h> void combine (int *arr,int start,int *result,int index,int n,int arr_len) { for(int ct = start;ct < arr_len-index+1;ct++){ result[n-index] = ct; if(index==1){ for(int j = 0;j<n;j++) { printf("%d\t", arr[result[j]]); } printf("\n")...
C
#include <stdio.h> int main() { double width, height, perimeter, area; width = 10.0; height = 32; perimeter = (2*width) + (2*height); area = width * height; printf("Width: %.2f Height: %.2f \n", width, height); printf("Area: %.2f, Perimeter: %.2f \n", area, perimeter); }
C
/* * Assignment 1: my_copy.c * Implement a cp(copy) command with –p option. * * Pre-requisites:- *  Knowledge about system calls, How to read and understand ‘man pages’. *  Command line arguments, File operation system calls (open, read, write, close, fstat ..etc) * * Objective: - *  To understand and imple...
C
#include "Classification.h" Classification_t *ClassificationConstruct(int classificationIndex, char *classificationName) { Classification_t *newClassification = (Classification_t *)malloc(sizeof(Classification_t)); if(newClassification == NULL) { printf("Not enough memory"); exit(0); } ...
C
#include "load_dump.h" #define NUM_ARGS 1 #define DESCRIPTION "integer sum numbers in the first column and output a single value\n\n" #define USAGE "... | bsum\n\n" #define EXAMPLE ">> echo -e '1\n2\n3\n4.1\n' | bsv | bsum | csv\n10\n\n" int main(int argc, const char **argv) { HELP(); SIGPIPE_HANDLER(); L...
C
#include<stdio.h> #include<conio.h> void main() { char ch; printf("\n enter the character:"); scanf("%c",&ch); if(ch>='a' && ch<='Z' || ch>='A' && ch<='A') printf("\nthe character is an alphabet",ch); else printf("\nthe character is not an alphabet",ch); getch(); }
C
/** Pallindrom Check */ #include <stdio.h> #include <string.h> int main(){ char str[100]; int len, mid, i, j, flag=0; printf("Enter your input: "); gets(str); len=strlen(str); mid=len/2; for(i=0, --len;i<=mid;i++, len--){ if(str[i]!=str[len]){ flag=1; } } if(flag==0){ printf("Palin...
C
#include<stdio.h> int main(){ int i; while(1){ printf("Enter no?\n"); //step -1 if(scanf(" %d",&i)>0) //step-2 printf("Num=%d\n",i); else printf("Entered character.Pls enter int\n"); } }
C
/************************************/ /* Owner: Vital@Nirvana */ /* Created: 12/18/00 */ /* Modified: 8/20/01 */ /* Realm: Acadie */ /************************************/ #include <ansi.h> #include "/players/vital/closed/headers/vital.h" ...
C
#include<stdio.h> #include<stdlib.h> int front=-1,rear=-1; int a[20]; void insertfrombeginning(int n){ int data; scanf("%d",&data); if(rear==-1){ front=0; rear=0; } else if(rear==n&&front==0 || front==rear+1){ printf("\n overflow"); return; } else if(front==n...
C
/* * CTYPE.H Character classification and conversion */ #ifndef CTYPE_H #define CTYPE_H extern unsigned char _ctype[]; #define _CTc 0x01 /* control character */ #define _CTd 0x02 /* numeric digit */ #define _CTu 0x04 /* upper case */ #define _CTl 0x08 /* lower case */ #define _CTs 0x10 /* whites...
C
/*** *strdate.c - contains the function "_strdate()" * * Copyright (c) 1989-2001, Microsoft Corporation. All rights reserved. * *Purpose: * contains the function _strdate() * *Revision History: * 06-07-89 PHG Module created, base on asm version * 03-20-90 GJF Made calling type _CALLTYPE1, ...
C
#ifndef SHORTEST_PATH_H #define SHORTEST_PATH_H #include <stdio.h> #include <stdlib.h> #include <string.h> #include <limits.h> #include <assert.h> #define INF INT_MAX typedef struct adj_list_node{ unsigned int vertex; unsigned int weights; struct adj_list_node * next_vertex; }LIST_NODE; typedef struct adj_lis...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* do.c :+: :+: :+: ...
C
/* Terminierung eines Pthreads durch pthread_cancel().*/ #include <pthread.h> #include <stdio.h> /* Funktion, die der Thread ausführen soll */ void *endlosschleife() { while (1) printf("Hier ist ein Thread\n"); } /* Hauptprogramm */ int main(int argc, char *argv[]) { pthread_t th; /* Erzeugung eines Threads...
C
/* * @file process.h * Assignment 3: PCB's and Process Scheduling Simulation * PCB ADT */ #ifndef _PROCESS_H_ #define _PROCESS_H_ #include "list.h" // Maximum length of the message between sender and receiver, // according to the instructions, 40 char max #define MESSAGE_MAX_LENGTH 42 #define CMD_MAX_LENGTH 10 /...
C
#include <wiringPi.h> int main(void){ if (wiringPiSetup()== -1) return 1; int i=0; int pins[] = {0,1,4,5,6,7,8,9,12,13}; int num = 10; for (i=0; i < num; i++) { digitalWrite(pins[i], LOW); } return 0; }
C
#include <stdio.h> struct test { int a; int b; struct test *ptr; }; static void f1(const struct test *const ptr) { } static struct test f2(void) { return (struct test) { 1, 2, NULL }; } int main(int argc, char *argv[]) { f1(&((struct test) { 1, 2, NULL })); f1(&(struct test)f2()); f1(&f2()); return 0; }
C
/** * @file matrice.h * @brief En-ttes de la librairie matrice */ #ifndef MATRICE_H_ #define MATRICE_H_ typedef struct Matrice* Matrice; /** * Alloue une matrice. * * @param nLignes Nombre de lignes de la matrice. * @param nColonnes Nombre de colonnes de la matrice. * @param caractereParDefaut Caractre avec ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* draw.c :+: :+: :+: ...
C
#include <stdio.h> #include "../ex07/ft_find_next_prime.c" int ft_find_next_prime(int nb); int main() { printf("The next prime greater or equal to 5 is: %d\n", ft_find_next_prime(5)); printf("The next prime greater or equal to 10 is: %d\n", ft_find_next_prime(10)); printf("The next prime greater or equal to 100 is...
C
#include<stdio.h> void main() { char a[30],b; int i,j; printf("ENTER STRING : "); gets(a); // printf("ENTER CHAR YOU WANNA DELETE : "); // scanf("%c",&b); for(i=0;a[i]!=NULL;i++) { // if(a[i]==b) if(a[i]==' ') { for(j=i;a[j]!=NULL;j++...
C
// sudoku_check.c // Created by Lauren Kira Murray on 17/02/2014. #include <stdio.h> #include "sudoku_header.h" /* method which takes in an array and returns its state (invalid, incomplete or complete) */ enum tag check_array(int array[]) { //flag to keep track of incomplete arrays int flag = 0; for...
C
#define _BSD_SOURCE 1 #define _SVID_SOURCE 1 #include <stdio.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <linux/limits.h> #include <dirent.h> #include <stdlib.h> #include <sys/wait.h> #include "commands.h" #include "utils.h" int do_launch(int argc, char** argv){ ...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #define N (40 * 1024 * 1024) int main() { srand(time(NULL)); int n, *data = malloc(N); scanf("%d", &n); for (int i = 0; i < N / 4; i++) data[i] = rand(); int idx = rand() % N; printf("data[%d] = %d\n", idx, data[idx]); sca...
C
#include <stdio.h> #include <stdlib.h> int main(){ char cadeia[50]; // Variavel para armazenar a cadeia de caracteres int qtd = 0, // Variavel para armazenar a quantidade de caracteres i, pv = 0; // Contador // Recebimento da cadeia printf("Digite uma cadeia de caracteres: ...
C
#ifndef AST_H #define AST_H #include <stdlib.h> #include <string.h> #include <stdarg.h> #include <stdio.h> int yylex(); void yyrestart(FILE*); int yyparse(); int yyerror(char*); typedef struct AST_Node { int term_type; /* 0 -> token; 1 -> non-terminated */ int token_type; /* type of tokens (enum) */ int ...
C
/** 4.2 write a program to read values of x,y and print as x+y/x-y x+y/2 (x+y)(x-y) */ ///program begin #include<stdio.h> #include<conio.h> //main() function begin int main() { float x,y,a,b,c; printf("Enter x\n"); scanf("%f",&a); printf("Enter y\...
C
#ifndef _random_h_ #define _random_h_ #include "Vec.h" #include <cstdlib> #include <cmath> inline void random_seed (const unsigned int& s) throw () { srand(s); } /** gleichverteilte Zufallszahl in [0,1] */ inline double urandom () throw () { return static_cast<double>( rand())/RAND_MAX; } /** gle...
C
#include <stdio.h> #include <stdlib.h> int N; int lsearch (int v, int arr[], int size){ for (int i = 0; i < N; i++) { if(v == arr[i]) {printf("True\n"); return 1; } } printf("False\n"); return 0; } int main(int argc, char *argv[]){ int a[] = {34,12,56,3,18,10,2,3,1}; int n = atoi(argv...
C
#pragma once #include <ntstatus.h> #define WIN32_NO_STATUS #include <windows.h> #undef WIN32_NO_STATUS #include "..\LinkedList\LinkedList.h" typedef struct Node { LONG Data; struct Node* Right; struct Node* Left; union { struct Node* Parent; PLNode LNode; }; } Node, *PNode; typedef struct Tree { PNode Roo...
C
/************************************************************************ * 8080 Emulator Storage Peripheral v0.0.0 * * Pramuka Perera * * June 23, 2017 * * Non-volatile data storage * ************************************************************************/ #ifndef INCLUDE #include <stdio.h...
C
// 300号题目最长上升子序列的扩展版本 // 首先按照envelopes的长度从短到长排序 // dp[i]表示以envelopes[i]作为最外层的套娃最大深度 // 算法复杂度O(n^2) class Solution { public: int maxEnvelopes(vector<vector<int>>& envelopes) { int n = envelopes.size(); if (n < 1) return 0; int max_ret = 1; vector<int> dp(n, 1); sort(envelopes.begin(), envelopes.end(), cmp); ...
C
#include <stdio.h> #include <string.h> int i, pilih, pmbyr, kmbl, jmlh, no, tmbh, akhir, kmbl1; int total[30]; int ttlhrg=0, ukuran=0; int hrg[4]={12000,10000,6000,9000}; char p[5]; int main () { awal: //label awal printf("====================================\n"); printf("| ...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include "trie.h" static ASCIITrie *ASCIITrie_Buscar_Recursiva(ASCIITrie *T, unsigned char *chave, int tam, int p){ if(T == NULL) return NULL; if(p == tam) return T; return ASCIITrie_Buscar_Recursiva(T->filhos[chave[p]-97], chave, tam, p+1); } static ...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> void error(char *msg); int main() { char buf[40]; int inlet[2], outlet[2]; pipe(inlet); pipe(outlet); pid_t pid = fork(); if(pid == -1) { error("cannot create child process"); } if...
C
#include "int_to_bstr.h" #include <stdio.h> char *int_to_bstr(int number, char *b_str, int size) { int mask = 1; b_str[size] = '\0'; for(size--; size >= 0; size--, number >>= 1) b_str[size] = (mask & number) + '0'; return b_str; }
C
/*C progam to check eligibility of candidates to marry Author: abhijeet Created on 10 Sept, 2019, 06:06 AM */ #include <stdio.h> int main() { int age; char stat,sex; printf("Enter marital status, Gender and Age in (M,F,18) format :"); scanf("%c,%c,%d",&stat,&sex,&age); if(stat=='m') { printf("Yo...
C
#include<stdio.h> int main(){ char nome[]; scanf("%s", nome); printf ("\n%s\n", nome); return 0; }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_cd.c :+: :+: :+: ...
C
#include <stdio.h> #include "node.h" int main() { char data[] = { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7 }; int i; fprintf(stdout, "Array: "); for(i = 0; i < 14; i++) fprintf(stdout, "%hhd ", *(data+i)); fprintf(stdout, "\n"); // Create a linked list of nodes, using the node library // functions where ap...
C
#include <stdio.h> #include <stdlib.h> void foo(int x) { int a[10]; unsigned int z = (unsigned int)x; sparrow_print(z); if (z > 0) { a[z] = 1; /* x is too big by the C casting rule */ /* A helpful footprint should be included in z's abstract value, hopefully, here! */ } } void call_foo...
C
#include<stdio.h> #include<sys/time.h> #include<sys/types.h> #include<unistd.h> #include<sys/stat.h> #include<fcntl.h> int main() { fd_set read_fileset,testfd; int fd2,fd3, retfd; int buf; int val,ret; char buff[4099]; fd2=open("/dev/input/event1",O_RDONLY); if(fd2<0) printf("error while open the file event1\...
C
#include <stdio.h> #include <assert.h> #include "../src/threadpool.h" // ThreadPool_work function prototypes ThreadPool_work_t *ThreadPool_work_create(thread_func_t func, void *arg); void ThreadPool_work_destroy(ThreadPool_work_t *work); // ThreadPool_work_queue function prototypes ThreadPool_work_queue_t *ThreadPo...
C
/* 树的广度优先遍历,将每一层的节点保存在vector中 */ //寻找下一层节点 vector<TreeNode*> FindCnode(vector<TreeNode*> childnode) { vector<TreeNode*> result; for (int i = 0; i < childnode.size(); i++) { if (childnode[i]->left != NULL) { result.push_back(childnode[i]->left); } if (childnode[i]->right != NULL) { result.push_back(ch...
C
#include <stdlib.h> #include <stdint.h> #include <harfbuzz-external.h> #include "tables/category-properties.h" #include "tables/combining-properties.h" HB_LineBreakClass HB_GetLineBreakClass(HB_UChar32 ch) { abort(); return 0; } static int combining_property_cmp(const void *vkey, const void *vcandidate) { con...
C
#include<stdio.h> #include<stdlib.h> struct node { int st; struct node *link; }; struct node1 { int nst[20]; }; static int set[20],nostate,noalpha,s,notransition,nofinal,start,finalstate[20],c,r,buffer[20]; int complete=-1; char alphabet[20]; static int eclosure[20][20]={0}; struct node1 hash[20]; struct...
C
#include <stdio.h> #include <stdlib.h> #include <ctype.h> #include "funciones.h" #define S 20 typedef struct { char nombre[20]; int edad; int dni; int estado; char alta; } eDatosPersonales; void mostrarPersona(eDatosPersonales personas[], int cant); int main() { char segu...
C
#include <stdio.h> #include <stdlib.h> int main(int argc, char const *argv[]) { char url[] = "1_teste.bin"; FILE * file = fopen(url, "rb"); int a[10]; if (file != NULL) { fread(a, sizeof(int), 10, file); printf("Eu lí! :)\n\n"); int i; for (i = 0; i < 10; i++) { printf("%d\n", a[i]); } fread(a,...
C
static inline int mandel(float c_re, float c_im, int count) { float z_re = c_re, z_im = c_im; int i; for (i = 0; i < count; ++i) { if (z_re * z_re + z_im * z_im > 4.) break; float new_re = z_re*z_re - z_im*z_im; float new_im = 2.f * z_re * z_im; z_re = c_re + new_...
C
/************************************************************************* # FileName : server.c # Author : fengjunhui # Email : 18883765905@163.com # Created : 2018年12月29日 星期六 13时44分59秒 ************************************************************************/ #include<stdio.h> #include <sys/types.h> ...
C
#include <mpi.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <pthread.h> #define PING_MODE 1 #define PONG_MODE 2 #define DEBUG 1 #define MSG_SIZE 1 // configurable_values #define STARTING_HOST 0 #define PING_DELAY 50000 #define PONG_DELAY 1000000 // Debug mode default disa...
C
#include<stdio.h> int main() { int a=9, b,c; b = (a==9) ? (a=5;c=1) :10 ;// printf("%d",b); return 0; }
C
#include "bubble.h" int num_comp = 0; int num_swap = 0; void get_results(int *comp_count, int *swap_count) { *comp_count = num_comp; *swap_count = num_swap; num_comp = 0; num_swap = 0; } void swap(int *array, int index1, int index2) { num_swap++; array[index1] = array[index1] ^ array[index2]; array[index2] =...
C
#include <stdio.h> int main(int argc, char *argv[]) { int n, k, kn, s, i, t = 0; scanf("%d %d\n", &n, &k); for (i = 1; i <= n; ++i) { scanf("%d", &s); if (i <= k && s > 0) { ++t; if (i == k) kn = s; } else if (kn == s && s > 0) {...
C
/* * libc.c SYSTEM CALL WRAPPERS */ #include <libc.h> #include <types.h> #include <errno.h> int errno; void itoa(int a, char *b) { int i, i1; char c; if (a==0) { b[0]='0'; b[1]=0; return ;} i=0; while (a>0) { b[i]=(a%10)+'0'; a=a/10; i++; } for (i1=0; i...
C
#include "holberton.h" /** * _strncpy - cpoies a string of n char * @dest: the final string * @src: the string to copy from * @n: the number of char to copy * Return: the final output */ char *_strncpy(char *dest, char *src, int n) { int count; for (count = 0; count < n && src[count] != '\0'; count++) dest[c...
C
#include <stdio.h> void arrayShiftRight(int array[], int size) { int last = size - 1; int tmp = array[last]; for ( int i = 0; i < last; last-- ) { array[last] = array[last-1]; } array[0] = tmp; } int main() { int size = 5; int array[] = { 1, 9, 3, 8, 5 }; ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct Dog { int age; char *breed; }; int main() { /** Create a program that does the following while using the pre-made struct above: ** Create and allocate a dynamic struct array that can hold the information of 5 dogs. ** Ask the us...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> void display_tab(int *od, int *doo) { for(; od<doo; ++od) printf("%d\n", *od); } int counting_lines(char const *name) { FILE *file = fopen(name, "r"); if(file==NULL) { printf("Nie udalo sie otworzyc pliku"); getchar(); exi...
C
#include "blather.h" client_t client_actual = {}; //client as global variable client_t *client = &client_actual; //pointer to client simpio_t simpio_actual; //simpio as global variable simpio_t *simpio = &simpio_actual; //pointer to simpio pthread_t user_thread; //user interaction thread(user input) pthread_t server...
C
#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> // "只有字母和数字[0-9a-zA-Z]、一些特殊符号"$-_.+!*'(),"[不包括双引号]、以及某些保留字,才可以不经过编码直接用于URL。" static int isURIChar(const char ch) { if (isalnum(ch)) return 1; if (ch == ' ') return 0; switch (ch) { case '$': case '-': case '_...
C
/* K&R exercise 1.17 * Prints lines which are longer than 80 characters */ #include <stdio.h> /* Maximum allowed length of line */ #define MAXLEN 1000 int getline (char [], int); main() { char line[MAXLINE]; int len; while ((len = getline(line, MAXLEN)) > 0) if (len > 80) printf("%...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_op_run_dq.c :+: :+: :+: ...
C
#include <stdio.h> struct money_box // ü { int w500; // 500 int w100; // 100 int w50; // 50 int w10; // 10 }; typedef struct money_box MoneyBox; // MoneyBox void init(MoneyBox *s); // MoneyBox ʱȭ void save(MoneyBox *s, int unit, int cnt); // Mo...
C
#include <stdio.h> #include <icmpv6.h> #include <common.h> void print_icmp6_header(const struct icmp6hdr *icmp, int size) { printf("\n\t|-Type: "); switch ((icmp -> type)) { case ICMP6_ECHOREQUEST: printf("Echo Request"); break; case ICMP6_ECHOREPLY: printf("Echo Reply"); break; default: pri...
C
#include<stdio.h> int main() { float x,y,r,x1,y1,a,b,c; scanf("%f%f%f%f%f",&x,&y,&r,&x1,&y1); a=(((x1-x)*(x1-x))+((y1-y)*(y1-y))); b=r*r; c=a-b; if (c<=0){ if (c==0){ printf("Point is on the circle."); } else { printf("Point is inside the circle."); } } else { p...
C
/* scanner.c * * Token scanner (in literature also called symbol scanner) * * A program consist of a sequence of tokens. A token is a group of one or * more characters which have a special meaning in the programming language. * The scanner reads a program character by character (by using the 'reader' * ob...
C
//Program to perform selection sort #include<stdio.h> #include<stdlib.h> int size=10; void insert(int *A); void display(int *A); void sort(int *A); main() { int A[size]; insert(A); printf("\n Your array is \n"); display(A); sort(A); printf("\n Your sorted array is \n"); display(A); } void insert(int *A) { ...
C
#include <stdio.h> #include <stdlib.h> #define TRUE 1 #define FALSE 0 void tri_croissant_pouls(Ligne *tab, int const n){ /* Booléen marquant l'arrêt du tri si le tableau est ordonné */ int en_desordre = TRUE; /* Boucle de répétition du tri et le test qui arrête le tri dès que le tableau est ordonné(en_desordre...
C
/****************************************************************************** * * Модуль управління кроковими двигунами * *****************************************************************************/ #include "stepper.h" #include <project.h> #include <math.h> /******* ВИЗНАЧЕННЯ ГЛОБАЛЬНИХ ЗМІННИХ**************...
C
#include "message.h" #include <stdio.h> void printMessage (Message * message) { printf ("Message producer id = %i \n", message->producerId); printf ("Message key = %i \n", message->key); printf ("Message stop = %i \n", message->stop); struct tm tm = *localtime(&message->createdAt); printf("Messag...
C
#include "binary_trees.h" /** * binary_tree_rotate_right - performs a right-rotation on a binary tree * @tree: pointer to the root node of the tree to rotate * Return: A pointer to the new root of the binary tree */ binary_tree_t *binary_tree_rotate_right(binary_tree_t *tree) { binary_tree_t *root = NULL, *child =...
C
#include <stdio.h> int main () { float valor1, valor2, operacao, resultado; printf("Digite dois valores: "); scanf("%f %f", &valor1, &valor2); printf("Escolha a operao [1. Adio 2. Subtrao 3. Diviso 4. Multiplicao]: "); scanf("%f", &operacao); if (operacao==1) { resultado = valor1 + valor2; } else if (opera...
C
/* * Copyright (c) 2017 Paul Mattes. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of cond...
C
#include<stdio.h> #include<string.h> struct employee { int id; char name[20]; }e1; int main() { e1.id=123; strcpy(e1.name,"rahul"); printf("%d\n%s",e1.id,e1.name); return 0; }
C
// Author: i0gan // Github: https://github.com/i0gan/pwn_waf // Pwn Waf for AWD CTF #include<stdio.h> #include<unistd.h> #include<stdlib.h> int main(void) { setbuf(stdin, NULL); setbuf(stdout, NULL); char buf[128]; puts("Test puts:"); #define show_str "Test write\x00\x01\x02\x03\xff\n" write(1, show_str, sizeof...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> int main() { char str[101]; scanf("%s",&str); int hashtable[200]={0}; for(int i=0, n=strlen(str);i<n;i++) { hashtable[str[i]]++; } int res=0; for(int i=0;i<200;i++) { if(hashtable[i]!=0) res++; } if(r...
C
#include <stdio.h> #include <stdlib.h> #include <lib.h> char getgroup(int pid) { message m; m.m1_i1 = pid; return _syscall(MM, GETSCHEDGROUP, &m); } void setgroup(int pid, char group) { message m; m.m1_i1 = pid; m.m1_i2 = group; _syscall(MM, SETSCHEDGROUP, &m); } int main(int argc, char* argv[]) { p...
C
#include <builtins.h> #include <string.h> void builtin_exit(t_env *env) { int ret; if (env->argc <= 1) ret = 0; else ret = atoi(env->argv[1]); free(env); exit(ret); }
C
typedef unsigned long u32; typedef signed long s32; typedef unsigned short u16; typedef signed short s16; typedef unsigned char u8; typedef signed char s8; #define GPM4CON (*(volatile u32*)0x110002e0) #define GPM4DAT (*(volatile u8*)0x110002e4) #define GPX3CON (*(volatile u32*)0x11000c60) #define GPX3DAT (*(volatile u...
C
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <time.h> #define NUM_THREADS 10 int cntA; int cntB; int cntC; pthread_mutex_t mutaA; pthread_mutex_t mutaB; pthread_mutex_t mutaC; pthread_t threads[NUM_THREADS]; int array[100*NUM_THREADS]; void *init(void *arg) { int idx = (*(int *) arg); int o...
C
#ifdef SEM_IMPEMENTATION #include "sem_implementation/message_queue.h" #else #include "cond_implementation/message_queue.h" #endif #include "console_app_tools.h" #include <stdio.h> #include <stdlib.h> #include <unistd.h> #define PRODUCERS_COUNT 5 #define CONSUMERS_COUNT 4 #define PRODUCER_PUT_DELAY_SEC 2 #define CONS...
C
int main() { for (char c[101]; cin.getline(c, 101);) { char a[101] = { ' ' }; int len = strlen(c), cnt = 0, left[101] = { 0 }; for (int i = 0; i < len; i++) { if (c[i] != '(' && c[i] != ')') a[i] = ' '; else { if (c[i] == '(') { a[i] = '$'; cnt += 1; left[...
C
/*!---------------------------------------------------------------------------+ * File : cbpm_rf_bucket.c | * | * Description : Returns the CESR RF bucket number for the timing setup and | ...
C
// // Created by tobiah on 17/10/17. // #include <dirent.h> #include <memory.h> #include "test_algorithms.h" #include "../../src/huffman_algorithms/standard_huffman.h" #include "../../src/huffman_algorithms/adaptive_huffman.h" #include "../../src/huffman_algorithms/adaptive_sliding_huffman.h" #include "../../src/huff...
C
/** * ╔═════════════════════════╗ * ║ PARSING LAMBDA CALCULUS ║ * ╚═════════════════════════╝ * * \author August-Alm@github.com * * \notes A small library to parse lambda calculus, both into a more * canonical abstract syntax tree presentation and into the de * B...
C
#pragma once #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <assert.h> #include "common.h" typedef struct list ioopm_list_t; /// Meta: struct definition goes in C file typedef struct list_node ioopm_list_node_t; typedef bool (*ioopm_list_predicate)(cmp_func_t cmp_func, elem_t value, void *extra);...
C
#include "Data.h" #include "Main_First.h" #include "Data_Base.h" #include "Data_Expand.h" NODE *FindMidNode(const LINKLIST *pL) { /*法一 **首先遍历一遍单链表以确定单链表的长度L. **然后再次从头结点出发循环L/2次找到单链 **表的中间结点. **算法复杂度为:O(L+L/2) = O(3L/2). NODE *p = pL->pNext; size_t i = 1; size_t length = ListLength(pL); while (p && i<(leng...
C
/* MIT License Copyright (c) 2017 Tim Slator 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, pub...
C
#ifndef _OFFICES_H_ #define _OFFICES_H_ #define ADDRESS_LENGTH 64 #define CITY_LENGTH 32 #define COUNTRY_LENGTH 32 #define POSTAL_CODE_LENGTH 16 typedef enum { OFFICE_NOERR, OFFICE_INVALIDADDRESS, OFFICE_INVALIDCITY, OFFICE_INVALIDCOUNTRY, OFFICE_INVALIDPOSTALCODE } officeError; typedef struct ...
C
#include "shell.h" /** * _strcpy - copy an array. * @dest: destiny * @src: source * Return: void. */ char *_strcpy(char *dest, char *src) { int i, n; n = 0; while (src[n] != '\0') { n++; } for (i = 0; src[i] != '\0'; i++) dest[i] = src[i]; dest[i++] = '\0'; return (dest); } /** * _strlen - len of ...
C
#include "dma.h" #include "csr_control.h" #include "sig_utils.h" #define DMA_NOW (0xffffffff) void dma_in_set(int start_address, int dma_len) { // set up input buffer to receive INPUT_BUF_START size CSR_WRITE(DMA_0_START_ADDR, start_address); CSR_WRITE(DMA_0_LENGTH, dma_len); CSR_WRITE(DMA_0_TIMER_VAL, DMA_NOW);...
C
/** * @brief * Wrappers for exist functions: deal with erro return ... * * @author jervis * @time 09/06/10 11:11:06 * @version 0.1 * * Copyright (C) jervis <bsdcpp@gmail.com> * */ #include "jlib.h" /******************************** * Wrappers for Unix I/O routines ********************************/ int O...
C
#include "initialisation.h" //------------------------------||:FONCTION:||---------------------------------|| void initialisation(Bonhomme **soignant, Bonhomme **lambda, Coordonnees **virus, int * cpt_lambda, int * cpt_virus, int * cpt_soignant, int nrow, int ncol, Case emplacement[nrow][ncol], int vie_virus[]) ...