language large_stringclasses 1
value | text stringlengths 9 2.95M |
|---|---|
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mini_sort.c :+: :+: :+: ... |
C | /* 뒤에서 k번째 노드는 무엇일까요?
[지시문]
연결리스트의 응용 문제
연결리스트가 하나 주어졋을 때 해당 연결 리스트의 뒤에서 k번째 노드의 값을 출력
연결리스트는 이미 만들어져 있다고 가정 */
#include <stdio.h>
#include <stdlib.h>
typedef struct node
{
int data;
struct node* next;
} Node;
void append(Node* head, int data)
{
Node* node = (Node*)malloc(sizeof(node));
node->data =... |
C | #include "stdlib.h"
struct ListNode {
int val;
struct ListNode *next;
};
// a' + c + b' == b' + c + a'
struct ListNode* FindFirstCommonNode(struct ListNode* pHead1, struct ListNode* pHead2 ) {
// write code here
struct ListNode* p1 = pHead1;
struct ListNode* p2 = pHead2;
while (p1 != p2) {
... |
C | #include <stdio.h>
int argumentLength(int arg) {
int argLength = 1;
while (arg / 10 > 0) {
argLength++;
arg /= 10;
}
return argLength;
}
void outputFraction(int numerator, int denomerator) {
printf("%i\n--\n", numerator);
printf("%i\n", denomerator);
}
void outputReciprocalFraction(int numerator, int denom... |
C | #include <stdio.h>
#include <stdlib.h>
typedef struct node{
float freq;
int leaf;
char ch;
struct node *left,*right;
}Node;
Node** sort(Node** nodes,int n)
{
int i,j;
for (i = 0; i < n; ++i)
for(j=0;j<n-1-i;j++)
if(nodes[j]->freq>nodes[j+1]->freq)
{
Node* n =nodes[j];
nodes[j] = nodes[j+1];
n... |
C | #include <stdio.h>
int gcd2nums(int p, int q) {
if (0 == p) {
return q;
}
return gcd2nums(q % p, p);
}
int gcdnnums(int *arr, int n) {
int gcd = arr[0];
for (int i = 1; i < n; i++) {
gcd = gcd2nums(arr[i], gcd);
}
return gcd;
}
int lcm2nums(int p, int q) {
return (p *... |
C | #include <stdio.h>
void removeString(char string[], int start, int count)
{
int i;
for (i = 0; string[i] != '\0'; ++i)
{
if (i >= start)
string[i] = string[i + count];
}
string[i + 1] = '\0';
}
int main(void)
{
char txt[10] = "what ever";
removeString(txt, 3, 3);
pr... |
C | #include<stdio.h>
void main()
{
int n1,n2;
printf("Enter First Number : ");
scanf("%d",&n1);
while(n1<0)
{
printf("Please Enter Positive Value : ");
scanf("%d",&n1);
}
printf("Enter Second Number : ");
scanf("%d",&n2);
while(n2<0)
{
printf("Please Enter... |
C | #include<stdio.h>
void bubble(int arr[],int n)
{
int i,j,temp;
for(i=0;i<n-1;i++)
{
for(j=0;j<n-i-1;j++)
{
if(arr[j]>arr[j+1])
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
}
void main()
{
int arr[100],n,i;
printf("Enter no of elements:");
scanf("%d",&n);
printf("Enter the el... |
C | #define _CRT_SECURE_NO_WARNINGS –
#pragma once
#include "pa-1.h"
#include <stdio.h>
// "pa-1.c"
int main()
{
//Declaring an array
int list[3];
//Declaring variables
int n = 0;
int x = 0;
int r = 0;
int y = 0;
int z = 0;
int rotateNum = 0;
int searchRecur = 0;
int collatzNum = 0;
int average = 0;
bool resul... |
C | #include<stdio.h>
int main()
{int x, y;
float price;
printf("[1] crisps\n");
printf("[2] popcorn\n");
printf("[3] chocolate\n");
printf("[4] cola\n");
printf("[0] exit\n");
for(x=1;x<=5;x++) {
scanf("%d",&y);
if(y==0) break;
switch(y){
case 1:price = 3.0;break;
case 2:p... |
C | #include <stdio.h>
#include <math.h>
int main()
{
int r;
double area;
scanf("%d",&r);
area=3.1416*pow(r,2);
printf("Area is %lf\n",area);
return 0;
}
|
C | /*
** EPITECH PROJECT, 2020
** settings_move_vol_cursor.c
** File description:
** settings_move_vol_cursor
*/
#include "my_world.h"
void set_volume_up(global_game_t *global_game)
{
int size_scrollbar = global_game->settings->scroll_bar->size.x - 30;
if (global_game->settings->cursor->pos.x < \
global_gam... |
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 | #ifndef __LIST_H__
#define __LIST_H__
struct list {
struct list *prev, *next;
};
static inline int list_empty(struct list *l)
{
return l->next == l;
}
static inline void list_init(struct list *n)
{
n->next = n;
n->prev = n;
}
static inline void list_del(struct list *n)
{
n->next->prev = n->prev;
n->prev->next ... |
C | int ch2int(char ch){
switch(ch){
case 'I':return 1;
case 'V':return 5;
case 'X':return 10;
case 'L':return 50;
case 'C':return 100;
case 'D':return 500;
case 'M':return 1000;
}
return 0;
}
int romanToInt(char* s) {
int length = strlen(s);
if (... |
C | #include <unistd.h>
#include <pwd.h>
#include <grp.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define BUF_SIZE 40
int main(void) {
struct passwd *pw;
struct group *prim_grp, *secondary_grp;
pw = getpwnam("syspro");
prim_grp = getgrgid(pw->pw_gid);
printf("Primary Group\n%s\n", prim_grp->gr_na... |
C | /* Project Name: Ana Process Explorer
* Written By : Ahmad Siavashi -> Email: a.siavosh@yahoo.com,
* Ali Kianinejad -> Email: af.kianinejad@gmail.com,
* Farid Amiri,
* Mohammad Javad Moein.
* Course Title: Principles of Programming.
* Instructor : Dr. Ali Hamze.
* T.A : Mr. Hojat Doulabi.
* Sh... |
C | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
int is_number(char s[])
{
int i = 0;
for (; s[i] != '\0'; i++)
{
if (isdigit(s[i]) == 0)
{
return 0;
}
}
return 1;
}
int main(int argc, char *argv[])
{
// If there is no argument, ... |
C | /*
If the lengths of the sides of a triangle are denoted by a, b, and c, then area
of triangle is given by
area=sqrt(S(s-a)(s-b)(s-c))
where, S = ( a + b + c ) / 2
*/
#include<stdio.h>
#include<math.h>
int areat(int a, int b, int c)
{
int s,area;
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
return(area);
}... |
C | #include"iostream.h"
int main()
{
int a,s,l,b;
cout"enter length and breath"
cin>>l;
cin>>b;
a=l*b;
s=2*(l+b);
cout<<a<<s<<endl;
}
|
C | /*
* UART.c
*
* Description: Source file for the UART AVR driver
* Created on: Jan 29, 2020
* Author: Mostafa Alaa
*/
#include "UART.h"
#include "Config/UART_Config.h"
#define BAUD_PRESCALE (((F_CPU / (UART_BAUDRATE * 8UL))) - 1)
/*****************************************************
* Functions Defi... |
C | #include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main(int argc, char **argv) {
srand(time(NULL));
int n = rand() - RAND_MAX / 2;
printf("n = %d\n", n);
if (n > 0) {
int i;
i = 0;
printf("Inside \"if\", i = %d\n", i);
}
else {
int i;
i = 127;
printf("Inside \"else\", i = ... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_uitoa_base.c :+: :+: :+: ... |
C | #include <stdio.h>
#include <stdlib.h>
int *soma (int *v1, int *v2, int x){ //Função para a soma dos vetores
int i;
int *v3 = malloc(x * sizeof(int));
for(i=0; i<x; i++){
v3[i] = v1[i] + v2[i];
}
free(v2);
free(v1);
return v3;
}
int vcont (int t1, int t2){ ... |
C | // 소리 파일 저장용량 계산하기
#include <stdio.h>
int main() {
long long int h, b, c, s; // 가장 큰 정수형
double mb;
scanf ("%lld %lld %lld %lld", &h, &b, &c, &s);
mb = h * b * c * s;
mb = mb / 8 / 1024 / 1024; // MB 값으로 변환
printf ("%.1lf MB", mb);
return 0;
} |
C | /*
* Advanced Calculator
*
* This is a quick and dirty ncurses based calculator written
* as practice to brush up on C. This will also be used as
* a program for to port to as many languages as cared.
*
* Author: Cameron Roy
* Date Begun: 2020/12/31
* Date Completed:
*
*/
//Libraries included
#include <std... |
C | #include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
#include<stdlib.h>
#include<limits.h>
/*#include<algorithm>*/
/*using namespace std;*/
typedef long int LD;
typedef long long int LLD;
typedef float F;
typedef double LF;
typedef unsigned int U;
typedef unsigned long int LU;
typedef unsigned long ... |
C | /** @file mat4f.c
* @author Cy Baca
*/
#include <math.h>
#include <assert.h>
#include <stdlib.h>
#define MAT4ARRAY_LEN 16
#define MAT4VEC_LEN 4
enum {
MAT4ARRAY_U_ERROR
, MAT4ARRAY_IDENTITY
, MAT4ARRAY_ZERO
, MAT4ARRAY_DEBUG
/* , MAT4ARRAY_MODEL
, MAT4ARRAY_VIEW
, MAT4ARRAY_CLIP */
, ... |
C | // INITIALIZATION OF AN ARRAY
#include <stdio.h>
int main()
{
int a[] = {34, 232, 23};
float b[] = {3.4, 23.2, 2.3};
printf("The value of a[0] is %d\n", a[0]);
printf("The value of a[1] is %d\n", a[1]);
printf("The value of a[2] is %d\n", a[2]);
printf("The value of b[0] is %.2f\n", b[0]);
... |
C | #include <stdio.h>
#include <stdbool.h>
#include "clam.h"
int main(int argc, char **argv)
{
for (int a = 0; a < argc; a++) {
const char *arg = argv[a];
clam_match_result_t i = 0;
if ((i = clam_match_posix_option(arg, "h")) || (i = clam_match_posix_long_option(arg, "-help"))) {
... |
C | /* ******************************************************************
Arquivos de exemplo para o desenvolvimento de um algoritmo de
branch-and-cut usando o XPRESS. Este branch-and-cut resolve o
problema da mochila 0-1 e usa como cortes as desigualdades de
cobertura simples (cover inequalit... |
C | #include <stdio.h>
#include <stdlib.h>
/* Faca um programa que leia dois numeros e mostre qual deles eh o maior. */
int main() {
float num1, num2;
printf("Digite o primeiro numero: ");
scanf("%f", &num1);
printf("Digite o segundo numero: ");
scanf("%f", &num2);
if(num1 > num2) {
prin... |
C | #include <stdio.h>
#include <stdbool.h>
void removeString (char source[], int start, int count)
{
int i = 0;
while ( source[i] != '\0' ) {
if ( i >= start )
source[i] = source[i + count];
++i;
printf("i: %i, %s\n", i, source);
}
}
int main(void)
{
void removeString(char source[], int start, int count);
... |
C | /**************************************************************
Program prebere vhodno sliko in na podlagi danih n
korakov zgenerira novo sliko, kjer se slikovne pike
spreminjajo glede na sosedne pike, ki jih obdajajo.
Avtor: Žiga Kljun
**************************************************************/
#include "... |
C | /*
* CNRSIM
* translate_notation.h
* Library that parses a tab-separated file
* provided by the user containing the
* notation dictionary.
*
* @author Riccardo Massidda
*/
#ifndef TRANSLATE_NOTATION
#define TRANSLATE_NOTATION
#include <uthash.h>
#include <stdbool.h>
typedef struct region_index_t region_index_... |
C | /*
** EPITECH PROJECT, 2021
** Live-Astek-Linked-List
** File description:
** game
*/
#include "game.h"
#include <SFML/Graphics.h>
#include <stdlib.h>
void game_init(game_t *game)
{
*game = (game_t){
.window = sfRenderWindow_create(
(sfVideoMode){1280, 720, 32},
"TchouTchou",
... |
C | /***************************************************
3. (int *) fun();
main() { int *p; p=fun(); printf(“\n %u”,p);}
int *fun() { int ivar=20; return &ivar; }
***************************************************/
#include<stdio.h>
(int*) fun();
//int *fun();
main()
{
int *p;
p=fun();
printf("%u \n",p);
}... |
C | // gcc generate_matrix.c -o generate_matrix
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
int i, j, n = 3, m = 3, max_val = 50, min_val = -max_val;
if (argc < 3) {
fprintf(stderr, "Too few arguments\n");
return 1;
}
n = atoi(argv[1]);
m = atoi(argv... |
C | #include<stdio.h>
int main()
{
int n;
int a=2;
int i = 0;
int arr[1000];
scanf("%d", &n);
int m = n;
if (n == 0)
printf("0");
while (n != 0)
{
if (n == 1)
{
arr[i] = 1;
i++;
break;
}
else if (n % 2 == 0)
{
arr[i] = 0;
n /= -2;
}
else
{
arr[i] = 1;
n = -(n - 1) / 2;
... |
C | #include "posicion.h"
Posicion crear_posicion(char* string_posicion)
{
Posicion posicion;
posicion.posX = string_posicion[0]-'0';
posicion.posY = string_posicion[2]-'0';
return posicion;
}
int distancia_entre(Posicion posicion1, Posicion posicion2) { return abs(posicion2.posX-posicion1.posX)+abs(posicion2.posY-po... |
C | /*
File Name : doubly.h
Description : Function Definitions to implement a doubly linked list
Programmer : Sparsh Jain
Roll No : 111601026
Date : October 17, 2017
*/
void createDoubly(struct doubly *list)
{
list->head = NULL;
list->tail = NULL;
list->length = 0;
}
void addHead(struct doubly *list, data)
{
struc... |
C | #include <stdio.h>
#include <cs50.h>
int main(void){
// get card_number from user
printf("Number: ");
long long entered_card_number = get_long_long();
long long card_number = entered_card_number;
// initialize checksum variable and card number length variable
int checksum = 0;
int card_numb... |
C | #include "card_array.h"
#include <assert.h>
#include <err.h>
#include <stdio.h>
card_array*
card_array_new(size_t num_cards)
{
card_array* new_card_array = malloc(sizeof(card_array));
if (new_card_array == NULL) {
err(1, "new_card_array malloc failed");
}
new_card_array->cards = malloc(num_cards*sizeof(... |
C | #include <assert.h>
#include <stdlib.h>
#include <salis.h>
#define MBST_MASK 0x80
#define USED_MASK 0x40
#define INST_MASK 0x3f
static sbool g_isInit;
static suint g_order;
static suint g_size;
static suint g_mbsc;
static suint g_used;
static suint g_cap;
static sbyte * g_data;
void
sm_i... |
C | #include <stdio.h>
/*
CS50x: Week 4 Shorts - Collatz challenge
Write a recursive function that utilizes the Collatz Conjecture.
https://en.wikipedia.org/wiki/Collatz_conjecture
Author: Adrian Arumugam
Date: 2016-01-08
*/
int collatz(int n)
{
// Base case.
if (n == 1)
return 0;
... |
C | /**
* @brief It implements the command interpreter
*
* @file command.c
* @author Paloma Ruiz Matesanz
* @version 2.0
* @date 22-02-2021
* @copyright GNU Public License
*/
#include <stdio.h>
#include <strings.h>
#include "command.h"
#define CMD_LENGHT 30
char *cmd_to_str[N_CMD]
[N_CMDT] = {{... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define key(a) (a.votos)
#define keyCode(a) (a.code)
#define less(a, b) (key(a) < key(b))
#define lessCode(a, b) (keyCode(a) < keyCode(b))
#define exch(a, b) { Item t = a; a = b; b = t; }
#define cmpexch(a, b) { if (less(b, a)) exch(a, b); }
typedef struct it... |
C | /*
Project teammates-
Shantanu Purandare, ASU ID- 1217160516
Girish Kumar Ethirajan, ASU ID- 1216305688
*/
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include "sem.h"
#include <unistd.h>
semaphore_t mutex,w_sem,r_sem;
int done = 0,arr[3];
void childwork(int *n)
{
// This is the child thread ... |
C | /*
Fernando Garrote de la Macorra A01027503
Alejandra Nissan Leizorek A01024682
Actividad 3 Ejercicio 2
*/
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
#include <dirent.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
typedef struct{
int min;
int max;
int numArchivos;
... |
C | /*
randomstring.c
Matthew Meyn
My random tester finds the error message by having inputChar() generate random characters and having
inputString() generate a string of random characters within a relatively small range: each of the 5
non-null characters will be within a range of 5 characters of the corresponding "err... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rotate.c :+: :+: :+: ... |
C | #include <stdio.h>
#include <stdlib.h>
#include "dog.h"
/**
* new_dog - copies a struc
* @name: dog name
* @age: dog age
* @owner: owner name
* Return: the copied struct
*/
dog_t *new_dog(char *name, float age, char *owner)
{
struct dog *new_dog_reg;
int i = 0, j = 0, k;
char *aka, *master;
if (name == NUL... |
C | #include <assert.h>
int main()
{
char a[] = "a\0b\0";
assert(sizeof a == 5);
assert(a[0] == 'a');
assert(a[1] == '\0');
assert(a[2] == 'b');
assert(a[3] == '\0');
assert(a[4] == '\0');
return 0;
}
|
C | #include <stdio.h>
#include <string.h>
#include "levenshtein.h"
// CLI.
int
main(int argc, char **argv) {
char *a = argv[1];
char *b = argv[2];
if (argc == 2) {
if (!strcmp(a, "-v") || !strcmp(a, "--version")) {
printf("%s", "0.1.1\n");
return 0;
}
if (!strcmp(a, "-h") || !strcmp(a, "--... |
C | #include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#define MAXBITS 32
void main()
{
int bits[MAXBITS]; // declare array bits, to hold the bits.
int index;
int number;
int num;
number = 16; // choose a number to test the code
printf(" Binary of Decimal %5d = ", number);
index ... |
C | /**
* 希尔排序:C 语言
*
* @author skywang
* @date 2014/03/11
*/
#include <stdio.h>
// 数组长度
#define LENGTH(array) ( (sizeof(array)) / (sizeof(array[0])) )
/*
* 希尔排序
*
* 参数说明:
* a -- 待排序的数组
* n -- 数组的长度
*/
void shell_sort1(int a[], int n)
{
int i,j,gap;
// gap为步长,每次减为原来的一半。
for (gap = n / 2; gap... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 26
struct node {
char data;
struct node *next;
};
struct node * get_node(){
struct node *p = (struct node *)malloc(sizeof(struct node));
return p;
}
void hash_insert(char c, struct node *hash_table[SIZE]){
int hash_value = c - 'a';
stru... |
C | #include "SDL2/SDL.h"
#include "constants.h"
void render(SDL_Renderer *renderer, Bird bird, Pipe pipes[])
{
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_RenderClear(renderer);
/* SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); */
SDL_Rect bird_rect = {bird.x, bird.y, BIRD_WIDTH, BIRD_HEIG... |
C | #include "sys.h"
#include "stdio.h"
uint32_t sys_call_table[SYSCALL_MAX_SIZE];
static void set_sys_call(int num, uint32_t sys_call);
void init_sys_call()
{
//1.查看内存中进程数量的系统调用
set_sys_call(SYS_PROC_NUM, (uint32_t) sys_get_proc_num);
//2.清屏
set_sys_call(SYS_WRITE_CLEAR, (uint32_t) sys_write_clear);
//3.进程退出
se... |
C | #include "stdio.h";
#include "stdlib.h";
#include "io.h";
#include "math.h";
#include "time.h";
#define OK 1;
#define ERROR 0;
#define TRUE 1;
#define FALSE 0;
#define MAXSIZE 1000;
typedef int QElementType;
typedef struct QNode
{
QElementType data;
struct QNode *next;
} QNode, *QueuePtr;
typedef struct
{
... |
C | #include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<pthread.h>
#include"server.h"
#include <sys/stat.h>
#include<fcntl.h>
#include<sys/sendfile.h>
#include<sys/wait.h>
typedef struct sockaddr sockaddr;
typedef struct soc... |
C | #include <stdio.h>
#include <stdlib.h>
#include "Circular_Dupla.h"
struct tipo_lista
{
int valor;
struct tipo_lista *pred;
struct tipo_lista *prox;
};
CircularDupla *criar()
{
return NULL;
}
CircularDupla *alocar(int valor)
{
CircularDupla *novo = (CircularDupla *) malloc (siz... |
C | /*
** main.c for sources in /home/dabbec_j/projets/sysunix/allum1/sources
**
** Made by jalil dabbech
** Login <dabbec_j@epitech.net>
**
** Started on Tue Jul 02 12:18:27 2013 jalil dabbech
** Last update Sat Jul 13 05:42:33 2013 jalil dabbech
*/
#include <stdlib.h>
#include <unistd.h>
#include "my_printf.h"
#inc... |
C | #include "declerations.h"
// a function that gets a command and a list of apartments and adds the apartmets to the list's tail
void addAnApt(char** command, List* list,int* code) {
char* copy = NULL;
char* address = NULL;
char* temp;
int price;
short int rooms;
Date date;
//cTime avaluation
time_t currentTime;
... |
C | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
int t,length,count,i,k;
long long int a;
char *b,*c;
char d;
b = malloc( 200*sizeof(char) );
c = malloc( 200*sizeof(char) );
scanf("%d",&t);
while(t--)
{
count=0;
scanf("%s",b);
length= strlen(b);... |
C | #include "substances.h"
static double min(double a, double b){
return (a < b ? a : b);
}
inline double substances_calculate_alcohol_dose(Person * p_person){
return 0.0;
}
double substances_calculate_MDMA_dose(Person * p_person){
// A "linear dose" in milligrams; 1.5 mg/kg * body_mass
double linear_d... |
C | /*Search a 2D Matrix II
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:
Integers in each row are sorted in ascending from left to right.
Integers in each column are sorted in ascending from top to bottom.
Consider the following matrix:
[
[1, 4, ... |
C | #define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
double myPower(double num, int order);
double myRoot(double num, int order, double precision);
int main(void)
{
double num1, num2;
int order1, order2;
double preci;
printf("제곱할 값(실수)과 차수(정수)를 입력하세요 ");
scanf("%lf %d", &num1, &order1);
printf("%f의 ... |
C | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
typedef int element;
typedef struct DQNode {
element data;
struct DQNode *llink;
struct DQNode *rlink;
}DQNode;
typedef struct {
DQNode *front, *rear;
}DQueType;
DQueType* createDQue() {
DQueType *DQ;
DQ = (DQueType... |
C | /* queue.h -- Queue的接口 */
#ifndef _QUEUE_H_
#define _QUEUE_H_
#include <stdbool.h>
// 在这里插入Item类型的定义,例如
typedef struct item {
long arrive; //一位顾客加入队列的时间
int processtime; //该顾客咨询时花费的时间
} Item;
// 或者 typedef struct item {int gumption; int charisma;} Item;
#define MAXQUEUE 10
typedef struct node{
It... |
C | /*
* 120b_lab5_ex2.c
*
* Created: 10/18/2019 11:52:48 AM
* Author : Matthew L
*/
#include <avr/io.h>
enum States{init, inc, dec, zero, wait, wait2} state;
unsigned char button0;
unsigned char button1;
unsigned char tempC;
void button_Press(){
button0 = ~PINA & 0x01;
button1 = ~PINA & 0x... |
C | /******************************************************************************
* The Linux Programming Interface practices.
* File: t_system.c
*
* Author: garyparrot
* Created: 2019/07/31
* Description: Demonstrate system()
****************************************... |
C | #include <stdio.h>
int main()
{
char ch;
printf("input");
scanf("%c",&ch);
if ( (ch>='a' &&ch<='z')||(ch>='A'&& ch<='Z'))
printf("%c is a alphabet", ch);
else
printf("%c is a not a alphabet", ch);
return 0;
}
|
C | #include "process.h"
childArgs processWork(int tNum, pthread_mutex_t *mutex) {
childArgs child;
childArgs *c = &child;
c->pid = getpid();
message mrcv;
key_t key;
int msgid;
long ranges[2];
//ftok to generate unique key
if ((key = ftok("msgq.txt", 70)) == -1) {
perror("ftok");
exit(1);
}
//msgget cre... |
C | /*
* 返回值演示
* */
#include <stdio.h>
int read(void) {
int val = 0;
printf("请输入一个数字:");
scanf("%d", &val);
return val;
}
int main() {
int val = read();
printf("val是%d\n", val);
return 0;
}
|
C | #include <stdio.h>
#include "atomic.h"
#define PRINT_VALUE(msg) \
printf(#msg": a = %d\n", atomic_read(&a));
int main()
{
atomic_t a = ATOMIC_INIT(9);
int c;
PRINT_VALUE("initial");
atomic_add(4, &a);
PRINT_VALUE("add 4");
atomic_sub(5, &a);
PRINT_VALUE("sub 5");
atomic_inc(&a);
PRINT_VALUE("inc");
at... |
C | #include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
#include <fcntl.h>
#include <math.h>
#include "float_vec.h"
#include "barrier.h"
#include "utils.h"
void swap_float(float * a, float * b)
{
float t = *a;
*a... |
C | #include "file.h"
#include "freemap.h"
#include "inode.h"
#include "utils.h"
static ssize_t mfs_file_write(struct file * filp, const char __user * buf, size_t len, loff_t * ppos)
{
int err = 0;
struct super_block *sb = NULL;
struct inode *inode = NULL;
struct mfs_inode *minode = NULL;
size_t newle... |
C | #include<stdio.h>
#include<string.h>
int main()
{
int n,i,j,count=0;
scanf("%d",&n);
char s[n];
scanf("%s",s);
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(s[i]==s[j])
{
count++;
s[i]='0';
}
}
}
printf("%d",(strlen(s)-count));
return 0;
} |
C | #include<stdio.h>
int sumofsquares(int n)
{
return (n * (n + 1) * (2 * n + 1)) / 6;
}
int main()
{
int n;
printf("Please enter the number of terms : ");
scanf("%d",&n);
printf("The sum of squares of the first n natural numbers is : %d\n",sumofsquares(n));
} |
C | #include<stdio.h>
int main(){
printf("please input a chain of chracters(no more than 50)\n");
char a[50];
int i = 0;
int amount = 0;
int k = 0;
while((a[i]= getchar()) != '\n'){
i++;
}
for(k = 0;k<i;){
if((a[k]>='A'&&a[k]<='Z')||(a[k]>='a'&&a[k]<='z')){
k++;
... |
C | #include <stdio.h>
void main() {
int a, b;
a = 5;
b = 3;
while (a > b) {
a = a - b;
}
printf("%d \n", a);
}
|
C | /*
** EPITECH PROJECT, 2017
** copy_buff.c
** File description:
** Function that delete the number at the top of the map
*/
#include "bsq.h"
#include <stdlib.h>
void copy_buff(char *buffer)
{
char *buff = malloc(sizeof(char) * my_strlen(buffer) + 1);
int i = 0;
int j = 0;
while (buffer[i] != '\n') {
i = i + 1;... |
C | //sourcecode
#include<stdio.h>
#include<stdlib.h>
main()
{
int n,a[1000],i;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
a[n]=1;
a[n+1]=1;
for(i=0;i<n;i+=3)
printf("%d ",a[i]*a[i+1]*a[i+2]);
}
//product of three
/*
Sample IP:
1 2 3
Sample OP:
6
*/
|
C | #include <stdio.h>
int main () {
int input;
int count = 0;
while( count < 1 ){
/* この部分に必要なプログラムを補う */
printf("偶数は0回入力されています.正の整数を入力して下さい.");
scanf("%d",&input);
if (input %2 == 0)
{
count = count+1;
}
}
while( count < 2){
printf("偶数は1回入力されています.正の整数を入力して下さい.");
... |
C | #include <stdlib.h>
#include <string.h>
#include "sway/commands.h"
static struct cmd_results *parse_border_color(struct border_colors *border_colors, const char *cmd_name, int argc, char **argv) {
struct cmd_results *error = NULL;
if (argc != 5) {
return cmd_results_new(CMD_INVALID, cmd_name, "Requires exactly fiv... |
C | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <getopt.h>
#include <cblas.h>
#include <lapacke.h>
typedef double* matrix;
matrix create(size_t m, size_t n)
{
matrix mat;
mat = malloc(m * n * sizeof(double));
for(size_t i = 0; i < m*n; ++i)
{
mat[i] = 0;
... |
C | ///////////////////////////////////////////////////////////////////////////////
//
/// \file fastpos.h
/// \brief Kind of two-bit version of bit scan reverse
///
// Authors: Igor Pavlov
// Lasse Collin
//
// This file has been put into the public domain.
// You can do whatever you want wit... |
C | /*
* Copyright 2014 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkHalf_DEFINED
#define SkHalf_DEFINED
#include "include/core/SkTypes.h"
#include "include/private/SkNx.h"
// 16-bit floating point value
// format is 1 bit sign, 5 b... |
C |
#include "libasm.h"
void test_strdup(void)
{
printf("\n\n@@@@@@@@@@@@@@@@@- Tests strdup -@@@@@@@@@@@@@@@@@\n\n");
printf("--------------------------------------\n");
printf("|test|\n");
printf("|%s|\n", strdup("test"));
printf("|%s|\n", ft_strdup("test"));
printf("--------------------------------------\n");
p... |
C | /**
* Agents are the core elements of the Robotic Framework
* which correspond to state machines executing the program
* and transmitting information between each other
*/
#ifndef ROBOTIC_FRAMEWORK_AGENTS_H
#define ROBOTIC_FRAMEWORK_AGENTS_H
#include <RF_events.h>
#include <RF_queue.h>
typedef enum
{
RF_HANDLED ... |
C | /* ************************************************************************** */
/* */
/* :::::::: */
/* img_bmp_gen.c :+: :+: ... |
C | /* ring.c */
#include <fcntl.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <utmp.h>
#define LONG_TIME 300000 /* half second worth of usec's */
#define SHORT_TIME 100000 /* quarter second worth of usec's */
#ifndef UTMP_FILE
# define UTMP_FILE "/var/adm/utmp"
#endif
#define TRUE 1
#defin... |
C | #include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
int main(void)
{
int fd[2],nbytes;
int childpid;
char string[] = "Helloi world!\n";
char readbuffer[80];
pipe(fd);
childpid = fork();
if(childpid == 0)
{
close(fd[0]);
write(fd[1],string,(strlen(string)+1));
exit(0);
}
else
{
close(fd[1... |
C | #include<stdio.h>
int count=0;
int a[5001][5001]={0};
int path(int i,int j)
{
if(i<0||j<0||a[i][j]==1)
return;
else if((i==0)&&(j==0))
++count;
else
{
path(i-1,j);
path(i,j-1);
}
}
int main()
{
int m,n,k,i,a1,a2;
scanf("%d %d %d",&m,&n,&k);
for(i=0;i<k;++i)
{
scanf("%d %d",&a1,&a2);
a[a1-1][a... |
C | #include<stdio.h>
/* program for celsius - fahrenheit table*/
main()
{
int lower=0,upper=100,step=10;
float fah,celsius;
celsius=lower;
printf("CELSIUS-FAHRENHEIT TABLE\n");
while(celsius<=upper)
{
fah=(celsius*5)/9+32;
printf("%.0f\t%.1f\n",celsius,fah);
celsius=celsius+step;
}
}
|
C | //incorrect swap
//by Kevin Schwaar
#include <stdio.h>
void swap (int *x, int *y);
int main(void){
int x=1;
int y=123;
printf("Before the swap, x=%d and y=%d\n",x,y);
swap(&x,&y);
printf("After the swap, x=%d and y=%d.\n",x,y);
}
void swap (int *x, int *y){
int tmp = *x;
*x = *y;
*y = tmp;
} |
C | #include <stdio.h>
#define MAX_LEN 1000 + 1
int dp[MAX_LEN][MAX_LEN];
char str[2][MAX_LEN];
int len[2];
#define min(a, b) (((a) > (b)) ? (b) : (a))
#define max(a, b) (((a) > (b)) ? (a) : (b))
int main() {
scanf("%s %s", str[0], str[1]);
for (len[0] = 0; str[0][len[0]]; ++len[0]);
for (len[1] = 0; str[1][len[1]];... |
C | /* LAB-4 library source file -Challenge1
SUBIR KUMAR PADHEE
ECEN5613
*/
#include "main.h"
/* Function definitions */
/* computes time elapsed between start and stop of timer 2 */
void compute_time()
{
long long time_computed = 0;
long UB = 0;
UB = 0x00FF & TH2;
//printf("\r... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.