language large_stringclasses 1
value | text stringlengths 9 2.95M |
|---|---|
C | #include"analyse.h"
#include"misc.h"
#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
st_char analytics_table[256];
char print_table=1;
unsigned char head;
unsigned char sorted_table[256];
short table_size=0;
void init_analytics_table(void){
for(unsigned short i = 0; i < 256; ++i){
analytics_table[... |
C | /* Author:Nikhil Kumar Arora,IT branch,IIIT Sonepat
/* C program to check if a tree is height-balanced or not */
#include <stdio.h>
#include <stdlib.h>
#define bool int
/*creating structure of node*/
struct node {
int data;
struct node* left;
struct node* right;
};
/* Returns the height of a binary tr... |
C | #include <ncurses.h>
#include <unistd.h>
#define DELAY 300000
int main(int argc, char *argv[]) {
int x = 0, y = 0;
int PLAYER = 5;
initscr();
noecho();
curs_set(FALSE);
while(1) {
clear(); // Clear the screen of all previously-printed characters
mvprintw(y, x, "%d", PLAYER); // Pr... |
C | /*
2)Napisati program na programskom jeziku C koji razvrstava đake osnovnih škola u željene srednje škole. U
svakom redu datoteke skole.txt se nalaze informacije o srednjoj školi u sledećem formatu: broj slobodnih
mesta (ceo broj), naziv skole (niz znakova, koji može sadržati blanko znake, od najviše 30 karaktera).... |
C | /*
* Energinet Datalogger
* Copyright (C) 2009 - 2012 LIAB ApS <info@liab.dk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that... |
C | #include<stdio.h>
void main()
{
int r=0,i,j,k=0,c=-1,p=1,hs=5,a[5][5]={0};
//Է
while(1)
{
for(i=0;i<hs;i++) // Ǵ
{
k++;
c=c+p;// +1
a[r][c]=k;
}
hs--;
if(hs==0)
break;
for(i=0;i<hs;i++)// Ǵ
{
k++;
r=r+p;
a[r][c]=k;
}
p=p*-1;
}
//ó
//... |
C | #include "check_return_count_in_functions.h"
#include <stdio.h>
#include <string.h> /* strncmp */
static int brace_lvl = 0; /* balance of '{', '}' */
static int state = 0;
static int state_last_warn = 0;
/* reset balance counter when loading new file */
void check_return_count_in_functions_init(void)
{
brace_l... |
C | #include<stdio.h>
//3/4 Hola/s
void main(){
int i,j;
for(i=0;i<=3;i++){
for(j=1;j<=4;j++) printf("Hola ");
printf("\n");
}
}
|
C | /*
Pointers on c - ch5, ex2
encrypt.c - read chars and prints them out encrypting alphas
per algorithm given in ex
author: nicolas miller <nicolasmiller@gmail.com>
*/
#include <stdio.h>
int encrypt(int ch)
{
if(ch >= 'a' && ch <= 'z')
return 'a' + ((ch - 'a') + 13) % 26;
else
return 'A' + ((ch - 'A') + 13) %... |
C | /* Example code for Think OS.
Copyright 2014 Allen Downey
License: GNU GPLv3
*/
#include <stdio.h>
#include <stdlib.h>
int var1;
int main ()
{
int var2 = 5;
void *p = malloc(128);
<<<<<<< HEAD
void *q = malloc(128);
void *t = malloc(2);
void *r = malloc(27);
char *s = "Literal string";
====... |
C | #include <math.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#ifndef ICOSPHERE_H
#define ICOSPHERE_H
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// points
typedef struct {
double x;
double y;
double z;
} cartesian_point;
typedef struct {
double r;
double theta;
d... |
C | #ifdef PROFILE_ENABLE
#include "prof.h"
#include <stdio.h>
#include <string.h>
#include <omp.h>
#include "time_.h"
tick_t profile_time[n_profile] = {0};
int profile_count[n_profile] = {0};
void profile_print(FILE *log, tick_t wall_time)
{
#define X(a) #a,
const char *name[] = {
PROFILE_LIST
NULL
};
#undef X
... |
C | #ifndef _LISTAGENERICA_
#define _LISTAGENERICA_ 1
#include "nodoGenerico.h"
#include <stdlib.h>
struct listadoble {
struct nodo* start = nullptr;
struct nodo* end = nullptr;
int size = 0;
bool isEmpty() {
return size == 0;
}
int getSize() {
return size;
}
void addT... |
C | #include "../headers/player.h"
#include "../headers/globals.h"
#include "../headers/map.h"
#include "../headers/lights.h"
#include <string.h>
void drawPlayerName(Player *player);
void animateIdle(Player *player, float y);
float fontScale = 352.38;
float playerHeight = levelHeight*0.7;
float maxIdleAnimationY = levelH... |
C | #include<stdlib.h>
#include<stdio.h>
#include<string.h>
#define PRIME 100003
//Binary Pattern Searching Rabin Karp with Hash Table
struct node{
int data;
struct node* link;
};
void append(struct node** head, int data)
{
struct node* new_node = (struct node*)malloc(sizeof(struct node));
struct node* l... |
C | #include <stdio.h>
int main(){
int a = 1;
int b = 4;
int c = 6;
char string[10] = "hello";
printf("Value of a: %d ,", a);
printf("address of its memory: %p\n",&a);
//printf("Value of b: %d ,", b);
//printf("address of its memory: %p\n",&b);
//printf("Value of c: %d ,", c);
//printf("address o... |
C | /****************************************************************/
/* NUMBERHANDLER.C */
/****************************************************************/
/* This module supplies routines for number handling. */
/* It consists of the following function: */
/* - digits_n(): it computes the number of digi... |
C |
#include "test.h"
#include <stdio.h>
#include <string.h>
int test_num = 0;
void DECLARE_NEW_TEST(char *description) {
printf("\x1b[33m");
printf("-----------------------------------%s-----------------------------------\n", description);
printf("\033[0m");
}
int assert_equals_int(char *file_name, int ... |
C | #include <stdio.h>
#include <unistd.h>
/*
Used also for parapeter passing with getopt
*/
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <pthread.h>
#include <time.h>
#include <sys/time.h>
#include <math.h>
#include "lib/functionList.h"
#include "lib/globalVars.h"
#include "src/readAdjacencyMatr... |
C | #include <stdio.h>
#include <string.h>
typedef unsigned char *byte_pointer;
void show_bytes(byte_pointer start,int len){
int i;
for (i=0;i<len;i++){
//显示为保留前面2位的16进制数
printf("%.2x",start[i]);
}
printf("\n");
}
void show_int(int x){
show_bytes((byte_pointer) &x,sizeof(int));
}
voi... |
C | #include "../example1.h"
#include <time.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-function-declaration"
void wait_for(double secs) {
clock_t start_time = clock();
double sec_diff = 0;
while(sec_diff < secs) {
clock_t now_time = clock();
sec_diff = ((double) (now_time - start_ti... |
C | #include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
int nf = argc - 1;
if (nf < 1) {
printf("you need to provide some floating-point numbers as arguments!\n");
}
double * fs = malloc(nf * sizeof(double));
for (int i=0; i<nf; i++) {
fs[i] = atof(argv[i+1];
... |
C | #ifndef FONCTIONS_H
#define FONCTIONS_H
#include "macros.h"
#include <gtk/gtk.h>
#include <string.h>
#include <stdarg.h>
typedef GtkWidget Widget;
typedef gboolean boolean;
//// Initialisation ///////////////////////////////////////////////////////
#define initialiser(argc, argv) gtk_init(argc, argv)
#define boucl... |
C | #include "assert.h"
void main() {
int n = __VERIFIER_nondet_int();
int result = 0;
__VERIFIER_assume(n >= 0);
__VERIFIER_assume(LARGE_INT > n);
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
for(int k = 0; k < n; k++) {
result++;
}
}... |
C | #include<stdio.h>
int main()
{
int i,key,low,high,mid,flag;
int arr[]={10,15,25,35,63,98};
int n=sizeof(arr)/sizeof(arr[0]);
printf("\n size of an array is=%d",n);
printf("\n enter element you want to search:");
scanf("%d",&key);
low=0;
high=n-1;
while(low<=high)
{
... |
C | /**
* Note: The returned array must be malloced, assume caller calls free().
*/
int comp(const void* a, const void* b) {
return ((int*)b)[1] - ((int*)a)[1];
}
int* rearrangeBarcodes(int* barcodes, int barcodesSize, int* returnSize){
/* cnts[i][1]是数字cnts[i][0]在barcodes中出现的次数 */
int cnts[10001][2] = {0};
... |
C | #include <arpa/inet.h>
#include <errno.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#pragma pack(1)
char *format(char *name);
typedef struct sockaddr SA;
typedef struct
{
unsigned short transaction_id;
... |
C | //01
#include<stdio.h>
int main (void)
{
int cus_typ;
float bill_amt;
float charge;
float discount = 0;
printf("Customer Type : "); // input customer type
scanf(" %d" , &cus_typ);
printf("Bill Amount :RS. "); //Input Number of units
scanf(" %f" , &bill_amt );
if(cus_typ == 1)
{
i... |
C | #include <stdio.h>
int main(int argc, char const *argv[])
{
// Test 1
// char phrase1[]="ordinateur\0";
// char phrase2[]="dur notaire\0";
// Test 2
char phrase1[]="ordinateur\0";
char phrase2[]="dur notaire\0";
int i,j;
char courant1, courant2;
int trouve;
// Retourner vrai si chacun des caractères de phr... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* syntax_checker_utils.c :+: :+: :+: ... |
C | /* ************************************************************************** */
/* */
/* :::::::: */
/* parse_camera.c :+: :+: ... |
C |
/* seq.c */
/* Sequences of types. */
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <ctype.h>
/* Return the chartype of a char. */
int alpha(int c)
{
return isalpha(c) ;
}
int digit(int c)
{
return isdigit(c) ;
}
int punct(int c)
{
... |
C | // HunterView.c ... HunterView ADT implementation
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include "Globals.h"
#include "Game.h"
#include "GameView.h"
#include "HunterView.h"
#include "Queue.h"
#include "Queue.c"
#include <string.h>
// #include "Map.h" ... if you decide to use the Map ADT
stru... |
C | #include <stdio.h>
#include <stdlib.h>
struct list {
int data;
struct CircularLinkedList *next;
};
struct CircularLinkedList *head=NULL;
void insert(int value){
struct list *node, *i;
node = (struct list*)malloc(sizeof(struct list));
node->data = value;
node->next = NULL;
if(head==N... |
C | #include<stdio.h>
int main(void)
{
char ch;
int count = 0;
while((ch = getchar()) != '#')
{
count++;
printf(" %c:%d %s", ch, ch, (count % 8 == 0) ? "\n" : "");
}
printf("Bye.\n");
return 0;
}
|
C | #include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main ()
{
int number,playernumber,level,methode,attempts=0;
srand(time(NULL));
system("cls");
printf("welcome to less or more game\n\n");
printf("plz chose if you want to play with the computer or with a friend\n");
printf("to play with the computer c... |
C |
/*
* SEQUENTIAL TCP SERVER
* Distributed Programming I
* Exercise2.3 Iterative File Transfer TCP Server
*
* File name: server1_main.c
* Programmer: Victor Cappa
* Date last modification: 15/05/2019
*
*/
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <sys/stat.h>
#inc... |
C | #include <stdio.h>
#include <inttypes.h>
#include <mraa/i2c.h>
#include "lcd.h"
void lcd_begin(){
lcd = mraa_i2c_init(0);
_displayfunction |= LCD_2LINE;
_numlines = 2;
_currline = 0;
sleep(1);
command(LCD_FUNCTIONSET | _displayfunction);
sleep(1);
command(LCD_FUNCTIONSET | _displayfunction);
_displaycontr... |
C | #include <stdio.h>
#include <string.h>
#include <ev.h>
#include <sys/epoll.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/inotify.h>
#define EVENT_SIZE (sizeof (struct inotify_event) )
#define EVENT_BUF_LEN ( 1024 * ( EVENT_SIZE + 16 ) )
static int inot... |
C | // 16-12.c
#include <sys/socket.h>
#include <errno.h>
#include <unistd.h>
int initserver(int type, const struct sockaddr* addr,
socklen_t alen, int qlen){
int fd, err = 0;
if((fd = socket(addr->sa_family, type, 0)) < 0)
return 1;
if(bind(fd, addr, alen) < 0)
goto errout;
if(type == S... |
C | #include<stdio.h>
int hcf(int, int, int);
int main(void)
{
int n1, n2, i;
printf("Enter two numbers: "); scanf("%d %d", &n1, &n2);
printf("The HCF of %d and %d is:", n1, n2);
hcf(n1, n2, i=n1>n2?n1-1:n2-1);
return 0;
}
int hcf(int _1, int _2, int i)
{
if(i==0) // base condition
{
printf("%d", 1);
re... |
C | /* Crie um programa em C que permanece em um laço lendo URLs em sua entrada
* padrão (uma por linha) e dispare um processo filho para fazer o download da
* mesma a partir da internet Dica: utilize os programas wget ou curl para
* efetuar do download.
**/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h... |
C | #include <linux/kernel.h>
// serve per il messaggio kernel info
#include <linux/module.h>
// serve per il modulo
// le funzioni da implementare devono avere proprio le seguenti firme:
// il SO le vede come punto d'ingresso e punto d'uscita
// questa è una versione base: si possono utilizzare anche delle macro
// libr... |
C | # include <stdio.h>
# include <math.h>
float f (float x)
{
float y;
if (x <= 3)
{
y = pow (x,2) - 3 * x + 9;
}
else
{
y = 1 / ( pow(x,3)+6);
}
return y;
}
|
C | #include<stdio.h>
#include<stdlib.h>
int main (int argc, char *argv[]){
int i,id,idade[45],idsoma = 0 ,contadorid,contadoralt;
float alt,altura[45],altsoma = 0,mediaid,mediaalt;
for (i=0;i<=45;i++){
printf("Digite a idade do aluno");
scanf("%d",&id);
printf("Digite a Altura do aluno");
scanf("%f",&alt);... |
C | /**
* File : ../header/rbt_header.h
* Author : Basava Prasad S J
* Date : 20.07.2018
* Last Modified Date: 02.09.2018
* Last Modified By : Basava Prasad S J
*/
/** @brief : Header file to implement red-black tree */
/**Header guards*/
#ifndef RBT_HEADER_H
#define RBT_HEADER_... |
C | #include <stdio.h>
/*
#Take CRLF pairs and outputs LF only
#Single LF chars are left alone
#Single CR chars convert to LF
*/
int main(int argc, char **argv)
{
int c;
int had_cr;
had_cr = 0;
while((c = getchar()) != -1)
{
if(c == '\r')
{ putchar('\n');
had_cr = 1;
}
else if(c == '\n' && had_cr == 1)
h... |
C | int globalVar = 100;
main(){
char middle_initial;
printf("\n");
int num1 = 12, num2 = 15, numAns;
float decimal1 = 1.2, decimal2 = 1.5, decimal_ans;
printf("Integer Calculation %d\n\n", num2 / num1);
printf("Float Calculation %f\n\n", decimal2 / decimal1);
printf("Modulus %d\n\n",num2 % num1);
printf("W... |
C | #include<stdio.h>
int main()
{
int i,n;
while(scanf("%d",&n)!=EOF)
{
for(i=1; i<=n; i++)
{
float c,f,C;
scanf("%f%f",&c,&f);
C=((5.0/9.0)*f)+c;
printf("Case %d: %.2f\n",i,C);
}
}
}
|
C | /**
* +------------------------------+
* |˵:ǰ˽API 汾 |
* |Ҫ,
* |Լں湹һ
* |ǰ˴.
* +------------------------------+
* |ʹҪ:ڰ
* |ǰ <vector> ʹ
* |ռ STD
* +------------------------------+
* |: ܽ
* |zhoujinyu0713@gmail.com |
* +------------------------------+
******************/
#ifndef LO... |
C | #include <stdio.h>
#include <stdlib.h>
void rotateLeft(int * array, int count)
{
int temp;
printf("Swapping %d @%d and %d @ %d\n",array[0],0,array[count-1],count);
char pause;
pause = getchar();
temp = array[0];
array[0]=array[count-1];
array[count-1]=temp;
if (count!=2) rotateLef... |
C | /*
Link: https://open.kattis.com/problems/quadrant
*/
#include <stdio.h>
int main() {
int x,y,q = 1;
scanf("%d %d", &x, &y);
if(x>0) {
if(y<0){
q=4;
}
} else {
if(y<0){
q=3;
} else q=2;
}
printf("%d", q);
}
|
C | #include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <getopt.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <sys/socket.h>
#include <sys/types.h>
#include "modulo.h"
#define mem_block_size 4
st... |
C | /*
problem link = "https://www.hackerrank.com/challenges/richie-rich/problem"*/
----------------------------------------------------CODE---------------------------------------------------
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <std... |
C | #include<stdio.h>
typedef int (*fptrOperation)(int,int);
int add(int num1,int num2){
return num1+num2;
}
int sub(int num1,int num2){
return num1-num2;
}
int compute(fptrOperation operation,int num1,int num2){
return operation(num1,num2);
}
void main(){
printf("%d\n",compute(add,5,6));
printf("%d\n",compu... |
C | /* Print prime numbers program
André Barros de Medeiros
29/08/17
*/
#include <stdio.h>
int main()
{
int num;
int d;
int r;
while (num=num) {
for (d=1; d<num; d=d+1)
{
num = num + 1;
num % d = r;
if (r=0)
printf("nao\n");
else
printf("sim\n");
}
}
return 0;
}
|
C | /*
* License: Public Domain
*/
#include "pmm.h"
#define unlikely(x) __builtin_expect((x),0)
#define likely(x) __builtin_expect((x),1)
uint32_t* pmm_memory_bitmap = (uint32_t *)0x38400;
uint32_t pmm_total_blocks = 0;
uint32_t used_blocks = 0;
extern uint32_t totalRAM;
void * memset(void * ptr, int value, ... |
C | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
int calcula(float valor){
float resultado;
if (valor >=0 && valor <=5){
resultado = (160*M_PI*(pow(valor,3)))/3;
}
if(valor>5 && valor<=9){
resultado = ((160*M_PI*(pow(5,3))/3))+(4000*M_PI*(valor-5));
}
if(valor<0 || valor>9){
resultado = 0... |
C | #include <stdio.h>
int main(void)
{
int i,j;
printf("Enter i = ");
scanf("%d",&i);
printf("Enter j = ");
scanf("%d",&j);
j += i;
printf("%d %d\n",i,j);
j -= i;
printf("%d %d\n",i,j);
j *= i;
printf("%d %d\n",i,j);
j /= i;
printf("%d %d\n",i,j);
return 0;
}
|
C | #include "hash_tables.h"
/**
* hash_table_set - function that adds an element to hash table
* @ht: hash table to add
* @key: key
* @value: value
* Return: 1 on success otherwise 0.
*/
int hash_table_set(hash_table_t *ht, const char *key, const char *value)
{
unsigned long int idx;
hash_node_t *new;
hash_node_t... |
C | #include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <limits.h>
#define MAX 400000000
long int binsearch(long int x, long int v[], long int n)
{
long int low, high, mid;
low = 0;
high = n - 1;
while (low <=high){
mid = (low + high) / 2;
if (x < v[mid])
high = m... |
C | #include<stdio.h> //libreria E/S
int N3;
int N1;
int N2;
int precio;
int main()
{//Inicio
printf("seleccione una opcin:\n1 = Ventas del dia\n2 = men de venta\n");
scanf("%d", &N3);
switch(N3){
case 1:
printf("\nGANANCIA DE:500");
break;
case 2:
printf("La tiendita de Doa Yolis\n");
pr... |
C | #pragma once
#define NORTH 0
#define SOUTH 1
#define EAST 2
#define WEST 3
#define DIRECTIONS 4
ref class MazeCell
{
private:
bool isVisited;
array<bool>^ isPassable; // can you move in the given direction from this cell.
public:
MazeCell();
bool getIsVisited() { return isVisited;}
void ... |
C | #include <R.h>
#include <math.h>
#include "nrutilR.h"
#define TINY 1.0e-20; // A small number
void ludcmp(double **a, int dim, int *indx, double *d){
// Given a matrix a[1..dim][1..dim], this routine replaces it by the LU decomposition of a rowwise permutation of itself.
// a and dim are input.
// a is out... |
C | /*
* one_time_init.c
*
* Implementing a simplified version of pthread_once.
*
*/
#include <stdio.h>
#include <pthread.h>
typedef struct one_time_s {
int is_initialized;
int foobar;
pthread_mutex_t mtx;
} one_time_t;
static one_time_t control = {.is_initialized = 0,
.mtx... |
C | #define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "tree.h"
void errorMes(int e, int line);
uint32_t getU32(FILE * f, int offset);
float price(FILE * f);
char* word(FILE * f);
void getChild(FILE * f, int child);
void find(char * search_word, FILE * f);
void printNotFound(char * wo... |
C | /*
*
* Write a program to display the following stars pattern.
*
***
*****
*******
*********
********... |
C | /*
* cfgfile.c:
*
* Copyright (c) 2003 DecisionSoft Ltd.
*
*/
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include "../include/stringmap.h"
#include "../include/iftop.h"
#include "../include/options.h"
#include "../include/cfgfile.h"
#define CONFIG_TYPE_STRING 0
#define CONFIG_... |
C | #define F_CPU 8000000UL
#include <avr/io.h>
#include <util/delay.h>
void usart_init();
void lcd_cmd(char x);
void lcd_data(char x);
void lcd_string(char *);
void lcd_init();
char rx();
char arr[] = "20002C6F5437";
char arr2[];
int i;
int main(void)
{
DDRA = 0x0F;
DDRB = 0xFF;
usart_init();
lcd_init();
//lcd_... |
C | #include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <pthread.h>
#include <assert.h>
#include <string.h>
#include "march.h"
void hello(void)
{
printf("Hello, world!\n");
}
float norm(struct Vec3 vec)
{
return sqrt(vec.x*vec.x + vec.y*vec.y + vec.z*vec.z);
}
struct Vec3 unit_vec(struct Vec3 vec)
... |
C | #include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
int main(){
int n;
int t;
scanf("%d %d",&n,&t);
int width[n+5];
for(int i = 0; i < n; i++){
scanf("%d",&width[i]);
}
for(int a = 0... |
C |
//工作队列使用说明
内核线程处理工作队列
1>>定义个数据结构
static struct work_struct work;
2>>初始化工作队列
INIT_WORK(&work,work_handler);
3>>进行工作队列调度
schedule_work(&work);//放入队列并唤醒线程
>>源码讲解
static inline bool schedule_work(struct work_struct *work)
{
//放入系统提供的默认队列中
return queue_work(system_wq, work);
}
static inline bool queue_work(struc... |
C | /*
Problem Statement : Write a program which creates three diffrent processess internally as process2,
process3, process4.
*/
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>
int main(int argc,char *argv[])
{
int iRet = 0;
int status = 0;
int pid = 0;
if((iR... |
C | //program to print sum upto given number using recursion.
#include <stdio.h>
int sum(int n);
int main(){
int n;
int x;
printf("Enter a number\n");
scanf("%d",&n);
x = sum(n);
printf("Sum upto %d no. is %d",n,x);
return 0;
}
int sum(int n){
if (n != 0)
return n + sum(n-1);
}
|
C | #include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/* modules */
#include "loopback.h"
#include "xmpp.h"
#define err_exit(str) { \
perror(str); \
exit(errno); \
}
#define PPPOAT_DESCR "PPPoAT"
#define PPPOAT_VERSIO... |
C | char buffer[100];
#include <stdio.h>
#include <string.h>
void main()
{
char *f = buffer;
char *g = buffer;
printf("%8.8x\n", f);
f=(char*)memset(f,0x0a,12);
printf("%8.8x\n", f);
if (f == g) {
int k = 12;
while (k--)
printf("%2.2x", *f++);
}
}
|
C | #include <stdio.h>
#include <stdlib.h>
#define p 3.14
double calc_circle(double radius);
int main(void)
{
double radius;
double ans;
printf("radius:");
scanf("%lf",&radius);
ans = calc_circle(radius);
printf("Area = %f\n",ans);
exit(EXIT_SUCCESS);
}
double calc_circle(double radius)
{
do... |
C | // File: mypthread_t.h
// List all group member's name: Jonathan Konopka, Anthony Siu
// username of iLab:
// iLab Server:
#ifndef MYTHREAD_T_H
#define MYTHREAD_T_H
#define _GNU_SOURCE
/* To use Linux pthread Library in Benchmark, you have to comment the USE_MYTHREAD macro */
#define USE_MYTHREAD 1
/* include lib... |
C | #include <stdio.h>
void sum_odd(int n);
void main() {
int n;
printf("Enter n: ");
scanf("%d",&n);
sum_odd(n);
}
void sum_odd(int n){
int sum=0;
for(int i=0;i<n;i++){
printf("%d",2*i);
if(i!=n-1) printf(" + ");
sum += i*2;
}
printf(" = %d",sum);
}
|
C | struct Room {
char* description;
char* requirement;
struct Item* items;
struct Room* north;
struct Room* south;
struct Room* east;
struct Room* west;
struct Room* up;
struct Room* down;
};
/*
construct a room using malloc
rooms are initialized with a null Item (item(NULL, NULL, NULL);)
*/
stru... |
C | #include <stdio.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <poll.h>
#include <sys/types.h>
#include "packet.h"
// do initial setup for socket
int setup(int* channel, int num_channels){
////////////////////// SETTING UP SE... |
C | #include <stdio.h>
int main() {
int d, c;
int count = 0;
scanf("%d", &d);
for (int i = 0; i < 5; i++) {
scanf("%d", &c);
if (d == c)count++;
}
printf("%d", count);
return 0;
}
|
C | #include "data_store.h"
#include "stream_parse.h"
int stream_input_parse(stream_buffer *sb, char *path);
int main(int argc, char **argv)
{
//step1: 解析参数,参数应该包括需要读取的文件名或者一个网络地址
char *path, *word;
int len, ret;
//step2: 对象初始化,初始化stream buffer和data store
stream_buffer *sb;
data_store *ds;
data_store_... |
C | #include <stdio.h>
#define MAXLINE 1000 /* 入力の最大行数 */
int getline_(char line[], int maxline);
void reverse(char to[], char from[], int len);
int main()
{
int len; /* 現在行の長さ */
char line[MAXLINE]; /* 現在の入力行 */
char reverse_line[MAXLINE];/* 格納されている最長行 */
while ((len = getline_(line, MAXLINE... |
C | #include <stdio.h>
int main(void)
{
int a;
printf("Enter a");
scanf("%d", &a);
if (a >= 90)
{
a=4;
}
else if (a < 90)
{
a=3;
}
else if (a < 80)
{
a=2;
}
else if (a < 70)
{
a=1;
}
else
{
a=... |
C | class Solution {
public:
int longestIncreasingPath(vector<vector<int>>& matrix) {
if(matrix.size()==0){
return 0;
}
vector<int> tmp(matrix[0].size(),-1);
vector<vector<int>> result(matrix.size(),tmp);
int longest=-1;
for(int i=0;i<matrix.size();++i){
... |
C | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "../ran.h"
#include "../mymath.h"
#include "../structure.h"
#include "../Kernels.h"
/*===============================================*/
/*O(MAXPOPS*numalleles + NUMINDS*LINES) */
void
GetNumFromPop (int *NumAFromPop, int *Geno, int *Z, int loc,
... |
C | #include <stdio.h>
#include <stdlib.h>
#define NumberOfNodes 22
#define NilValue -1
/*Τροποποιείση του τύπου ListElementType ώστε να αποθηκευεί
τον ΑΜ και τον Βαθμό του μαθητή και αναλογες αλλαγές στις
συναρτήσεις InitializeStoragePool,ReleaseNode,Insert,TraverseLinked
για να περνάμε και τα δυο δεδομένα.*/... |
C | #include <stdio.h>
void imprimir(int arreglo[], int tamaño){
for (int i=0; i<tamaño; i++){
printf("%d", arreglo[i]);
}
}
void qs(int arreglo[], int inicio, int tamaño){
int cero= inicio, fin = tamaño;
int ref, aux, dd;
dd= (cero + fin)/2;
ref = arreglo[dd];
cero = inicio;
fin = tamaño;
do{
while(cero <tam... |
C | //Returns n-grams for characters as well as words in a character array separated by newline
//Usage : char_ngram(<character array>,<integer n>) or word_ngram(<character array>,<integer n>)
//Dependencies : stdlib.h, stdio.h, string.h
char* char_ngram(char* s, int n)
{
char *ngram = (char*)calloc(100000,sizeof(char... |
C | #include <stdio.h>
int main(){
int t, lesser = 0, greater , n = 10, prev, this, i, j;
scanf("%d", &t);
printf("Lumberjacks:\n");
for( i = 0; i < t; ++i ){
lesser = greater = 0;
n = 10;
for( j = 0; j < n; ++j){
if( j ) prev = this;
scanf("%d", &this);
if( j ){
... |
C | #include "bitBuffer.h"
#include "bitsUtils.h"
#include "stdio.h"
void testFullBytes();
void testBitsAlternados();
void testFullBytesTakenHalf();
void testFullBytesTaken3();
void testManyBytesTaken3();
void testFullBytesTaken5();
void testDeath();
void testWriteShort();
int main() {
// testFullBytes();
// testFullBy... |
C | #include<stdio.h>
#include<string.h>
int i,j,k,l,m,n=0,o,p,nv,z=0,t,x=0;
char str[10],temp[20],temp2[20],temp3[20];
struct prod
{
char lhs[10],rhs[10][10];
int n;
}pro[10];
void findter()
{
for(k=0;k<n;k++)
{
if(temp[i]==pro[k].lhs[0])
{
... |
C | #include <math.h>
#include <stdio.h>
#include <time.h>
typedef int bool;
#define FALSE 0
#define TRUE 1
#define N 10000000
//returns whether num is prime
bool isPrime(long num) {
long limit = sqrt(num);
for(long i=2; i<=limit; i++) {
if(num % i == 0) {
return FALSE;
}
}
ret... |
C | #include <stdio.h>
void triInsertion(int tab[],int nb);
int arr[]={12,11,13,8,7,5,6,9,10};
int main(int argc, char** argv){
printf("Hello world\n");
int nb=sizeof(arr)/sizeof(arr[0]);
for(int i=0;i<nb;i++){
printf("the %d element is %d\n",i,arr[i]);
}
triInsertion(arr,nb);
printf("****... |
C | #include <stdio.h>
int main()
{
int x;
int i,a;
printf("Enter any no.\n");
scanf("%d",&x);
for(i=2;i<=9;i++)
{
while(x%i==0)
{
printf("%d\t",i);
x=x/i;
}
}
return 0;
} |
C | /* Из родительского процесса создается дочерний. Дочерний пишет свой pid и pid родителя в txt файл и генерирует 10 Мб чего-нибудь.
Родительский ожидает окончания дочернего и выводит сколько он ждал
*/
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <time.h>
#... |
C | #include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#define BUFFER_LENGTH 10
#define NDEBUG
int main (int argc, char * argv[]) {
//Arguments for source and destination files
assert(argc > 2);
//Open file pointers for files
FILE * fps = fopen(argv[1], "rb");
FILE * fpd = fopen(argv[2], "wb");
//Set p... |
C | #include "tm_stm32f4_ds18b20.h"
uint8_t TM_DS18B20_Start(uint8_t *ROM) {
if (!TM_DS18B20_Is(ROM)) {
return 0;
}
//Reset line
TM_OneWire_Reset();
//Select ROM number
TM_OneWire_SelectWithPointer(ROM);
//Start temperature conversion
TM_OneWire_WriteByte(TM_DS18B20_CMD_CONVERTTEMP);
return 1;
}
void TM_DS18... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#define N 11
typedef struct NoFuncionario{
char nome[20];
int numid;
char depart[30];
float salario;
struct NoFuncionario *prox;
} NoFuncionario, *Funcionario;
void inicializa (Funcionario *l);
_Bool consulta (Funcionario *l, NoFunc... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.