language large_stringclasses 1
value | text stringlengths 9 2.95M |
|---|---|
C | /*
* =====================================================================================
*
* Filename: 1243.c
*
* Description: Divorce of the Seven Dwarfs
*
* =====================================================================================
*/
#include <stdio.h>
#include <string.h>
int main(v... |
C | /* FILE: summer.c
* DESCRIPTION:
* Implementation of a piezosummer driver using avr clocks to control output
* AUTHOR: Filip Henningsson, c18fhn@cs.umu.se
*/
#include "summer.h"
#include <avr/interrupt.h>
#include <math.h>
#include <avr/pgmspace.h>
// Structural defines for notes
// 3MS... |
C | /* default_argument.c
Book example showing why relying on the default
argument promotions is dangerous.
C Programming: A Modern Approach, Second Edition
Chapter 9, Page 195
Ray Santos
December 19, 2015
*/
#include <stdio.h>
int main(void)
{
double x = 3.0;
printf("Square: %d\n", square(... |
C | #include <stdio.h>
int main(void){
char ch[10], chi[10];
fread(ch, sizeof(char), 10, stdin );
for (int i = 0; i < 10; i++){
chi[9-i] = ch[i];
}
fwrite(chi, sizeof(char), 10, stdout);
}
|
C | /******************************************************************************
Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.
***********************************************... |
C | #include "thread_pool.h"
#include <stdio.h>
thread_pool tp;
int threads_number = 5;
void * task(void *arg)
{
printf("I'm Vector!\n");
}
int main()
{
init_pool(&tp,threads_number);
int i;
for(i=0;i<10;i++)
{
add_task(&tp,task,NULL);
printf("%s%d\n", "add ",i+1);
}
destroy_pool(&tp);
return 0;
} |
C | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
void* ecMalloc(unsigned int size){
void* ptr = malloc(size);
if(ptr==NULL){
printf("Memory Error\n");
exit(-1);
}
return ptr;
}
int main(int argc, char *argv[]){
return 0;
}
|
C | #include <stdio.h>
#pragma warning(disable : 4996)
int main(void)
{
double kg;
scanf_s("%lf", &kg);
if (kg > 88.45) {
printf("Heavyweight");
}
else if (kg <= 88.45 && kg > 72.57) {
printf("Cruiserweight");
}
else if (kg <= 72.57 && kg > 61.23) {
printf("Middleweight");
}
else if (kg <= 61.23 && kg > 50... |
C | /*
*Ծ
*/
int Board_evaluate(int x,int y,int me)
{
int value;
value =2* Count_Stone(me);
return value;
}
int My_Board[12][12];
/*жǷ*/
int IF_Be_Mak(char cur_board[12][12])
{
int Danger=0;
for (int i = 0; i < 12; i++)
{
for (int j = 0; j < 12; j++)
{
if (cur_board[i][j] == me_flag)
{
for (int a = 0;... |
C | /*
** EPITECH PROJECT, 2020
** generic linked list
** File description:
** structs create
*/
#include "structs.h"
#include <stdlib.h>
#include <string.h>
persona_t *persona_create(char *first_name, char *last_name, int age)
{
persona_t *new = malloc(sizeof(persona_t));
if (!new)
return (NULL);
ne... |
C |
int *a;
int *b;
float ****c;
int* func1(int p, int q);
float** func2(int a,int * b,int*** c,float *****d);
int* func1(int p,int q)
{
int *f,*g,*a,*b;
float *c;
int *r;
*a = *a + *b;
*a = *b;
*c = 3.2 + 5.2;
if(!(*f == *g))
*a = *a + *b - *f - *g;
return f;
}
float** func2(int q, int * r, int*** s, floa... |
C | /*
********************************************************************************
* @author xdh
* @version V1.0
* @date 2017-xx-xx
* @apply 3000WControl
********************************************************************************
*/
#include "sht10.h"
#include <math.h>
#include "delay.h"
//ȡʪȵı
u32 ... |
C | /* Min Su Kim, mskim3494 */
/* CS152, Winter 2015 */
/* Homework 3 */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "hw3.h"
int main(int argc, char *argv[])
{
int alen = atoi(argv[1]);
int a[alen];
int i;
for (i=alen; i>0; i--){
scanf("%d", &a[i-1]);
... |
C | #include "stacked.h"
#include <time.h>
void swap(int array[], int i, int j) {
int temp_holder = array[i];
array[i] = array[j];
array[j] = temp_holder;
}
void shuffle(int array[], int size){
for (int i = size - 1; i >= 1; i--){
int j = (rand() % (((i) - 0) + 1) + 0);
swap(array, i, j);
}
}
int player_one_tur... |
C | #include <stdio.h>
#define FALSE 0
#define TRUE !FALSE
int main(){
/*
E possível acessar o endereço de um ponteiro e guardá-lo em outro
ponteiro? Se possível, mostre como.
*/
int x = 5, *y, **z; // para isso precisamos mais um nivel de referencia
y = &x; // passando um endereço a um ponteiro
printf("%p > %d\n... |
C | #include<stdio.h>
int main(int argc, char*argv[]) {
int a,b;
a=5;
b=3;
printf("a+(-b) %d \n", a+(-b));
} |
C | #include "lab1.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
void run_child_mode() {
struct sigaction sa;
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = &handle_child;
pid_t pid = fork();
if (pid == 0) {
// Child-процесс
printf("Child: PID=%d, GID=%d\n", getpid(), getpgid(get... |
C | /*
* key.c
*
* Created on: Jan 18, 2021
* Author: linhao
*/
#include "key.h"
uint8_t Key_Scan(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
{
if (HAL_GPIO_ReadPin(GPIOx, GPIO_Pin) == KEY_ON)
{
/*等待按键释放 */
while (HAL_GPIO_ReadPin(GPIOx, GPIO_Pin) == KEY_ON)
;
return KEY_ON;
}
else
{
... |
C | #include <stdio.h>
#include <math.h>
/* Finish the function. Use printf() to answer.
Both stdio.h and math.h have already been included */
void distance(float *p1, float *p2)
{
printf("%.2f", sqrt(pow(p2[0] - p1[0], 2) + pow(p2[1] - p1[1], 2) + pow(p2[2] - p1[2], 2)));
} |
C | #include <stdio.h>
#include <math.h>
int main()
{
while(0)
{
printf("sis tekst nebus redzams\n");
break;
}
while(1)
{
printf("sis ir bezgaligs teksts ar 'break'\n");
break;
}
double a = 3.5e-1;
double b = 0.5e-1;
while(a<=1.0) //(vai a ir mazaks vai vienads ar 1.0)
{
printf("a = %.2... |
C | #include <stdio.h>
#include <stdlib.h>
#include "reversi.h"
void MakeBoard(int size, choose*** mat) {
int i, j;
*mat = (choose **) malloc ( size * sizeof(int *));
for (i = 0; i < size; i++) {
(*mat)[i] = (choose *) malloc ( size * sizeof(int) );
for (j = 0; j < size; j++) {
(*mat)[i][j] = Empty;
}
}
int... |
C | #ifndef EVENTTYPE_H
#define EVENTTYPE_H
enum eventType{NONE, SUPER_S,LEFT,RIGHT, UP, DOWN, ENTER};
struct Xevent {
Xevent(eventType ltype) : type(ltype){}
void setType(eventType ltype){
type = ltype;
}
eventType type;
};
#endif // EVENTTYPE_H
|
C | #include <stdio.h>
int main()
{
int a[6],g[3],b[3],c[3],d,i;
while(scanf("%d %d %d %d %d %d %d %d %d",&g[0],&b[0],&c[0],&g[1],&b[1],&c[1],&g[2],&b[2],&c[2])==9)
{
a[0]=g[0]+c[0]+g[1]+b[1]+b[2]+c[2];
a[1]=g[0]+c[0]+b[1]+c[1]+g[2]+b[2];
a[2]=b[0]+c[0]+g[1]+c[1]+g[2]+b[2];
a[3]=... |
C | #include <string.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <netdb.h>
#include <getopt.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/types.h>
#define BUFSIZE 512
#define TRUE 1
#define LOCALHOST "127.0.0.1"
void write_file(char *filename, int client_so... |
C | /*
** EPITECH PROJECT, 2018
** my_index_of
** File description:
** return the index of the first occurence of a char in a
** char *, -1 if the char is not in the char *
*/
#include "lib.h"
int my_index_of(char c, char *str)
{
int i = 0;
while (str[i] != '\0') {
if (str[i] == c)
return (i)... |
C | #include "./TLSE.h"
/*
Q3) Considerando a declaração da Q1, escreva uma função em C que, dada uma lista l
qualquer, desloque uma vez os elementos de l, de acordo com n. Se n é ímpar, o
elemento que está na última posição passa a ser o primeiro quando a lista é deslocada.
Senão, o elemento que está na p... |
C | /*
* Copyright 2014-2017 CyberVision, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable... |
C | #include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include "utils.h"
#define HOST "127.0.0.1"
#define PORT 10001
int main(int argc, char** argv) {
init(HOST,PORT);
/* message declarations */
msg r, t;
my_msg m;
int res;
/* file declarations... |
C | /**
@file codepoints.c
@author David Lovato
This component will read and maintain the list of codepoints,
where each codepoint has a numeric code and a string name.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
/** Description for Code Point is only 90 chars long */
#defin... |
C |
int a[20]={0},b[20]={0},i=0;
void f(int x)
{
if (x==1)
{
a[i]=x;
i++;
}
else
{
f(x/2);
a[i]=x;
i++;
}
}
int main()
{
int x,y,j,counter=0,k;
cin>>x>>y;
f(y);
for (j=0;j<20;j++)
{
b[j]=a[j];
a[j]=0;
}
i=0;
f(x);
for (j=0;j<20;j++)
{
if (b[j]==a[j]&&b[... |
C | #include <stdio.h>
// N = 5e3이다.
// 3개를 골라야 하는데 N^3로는 불가능하다.
// 그럼 N^2로 줄여야 한다는 말인데,
// 무작위로 고르는 3개의 수를 0에 최대한 수렴하게 한다는게 키포인트다.
// 그러니 배열을 정렬된 상태로 만들어주고,
// 2중 반복문으로 구현하되 하나는 투 포인터를 이용하면 쉽게 해결된다.
// |INPUT|이 최대 1e9라는 걸 명심해야한다.
typedef long long ll;
int arr[5000];
int temp[5000];
int ans[3];
ll res;
int n;
ll llabs... |
C | #include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "../dist/sqlite/sqlite3.h"
#define DATABASE_FILENAME "db.db"
static int callback(void *NotUsed, int argc, char **argv, char **azColName){
int i;
for(i=0; i<argc; i++){
fprintf(stderr, "%s = %s; ", azColName[i... |
C | /*
* arithmetic operatiions
*/
#include <msp430.h>
void main(void)
{
WDTCTL = WDTPW|WDTHOLD;
int a = 32767;
int b;
unsigned int c = 0xFFFF;
unsigned char d = 0x00;
int e = 10;
float f = 10.1;
int g = 0;
float h = 0.0;
a += 1;
b = 17 / 2;
c += 0x0001;
d -= 0x01;
e /= 0;
f /= 0;
g /= g;
h /= h;
}
|
C | #include <stdio.h>
#include "ok_png.h"
int main(int _argc, char **_argv) {
FILE *file = fopen(_argv[1], "rb");
ok_png image = ok_png_read(file, OK_PNG_COLOR_FORMAT_RGBA | OK_PNG_PREMULTIPLIED_ALPHA | OK_PNG_FLIP_Y);
fclose(file);
if (image.data) {
printf("Got image! Size: %li x %li\n", (long)im... |
C | #include <stdio.h>
int main(void)
{
int x, i = 1, n1, n2;
int n = 0;
scanf("%d", &x);
while (1)
{
n = (i *(i + 1)) / 2;
if (x > n)
{
i++;
}
else
{
i--;
n = (i *(i + 1)) / 2;
break;
}
}
if (i % 2 == 0)
{
n1 = i + 2 , n2 = 0;
n = x - n;
n1 = n1 - n;
n2 = n2 +... |
C | // copy from http://krishnamohanlinux.blogspot.com/2015/02/getuserpages-example.html
#include <linux/device.h>
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/pagemap.h>
#include <linux/sched.h>
#include <linux/slab.h>
static struct class *proc_class;
sta... |
C | /* ndtrl.c
*
* Normal distribution function
*
*
*
* SYNOPSIS:
*
* long double x, y, ndtrl();
*
* y = ndtrl( x );
*
*
*
* DESCRIPTION:
*
* Returns the area under the Gaussian probability density
* function, integrated from minus infinity to x:
*
* x
... |
C |
#include <wixel.h>
#include "Interpolate.h"
//////////////
/*
* Interpolate between two signed numbers
* value - the current value to be used
* minVal - the minimum that 'value' can be
* maxVal - the maximum that 'value' can be
* minRtn - the return value if 'value = minVal'
* maxRtn - the return value if 'v... |
C | #include<stdio.h>
int addDigits(int num) {
int ans;
while(1) {
ans = 0;
while(num != 0) {
ans = ans + num%10;
num = num/10;
}
if (ans/10 == 0)
return ans;
else
num = ans;
}
}
int main() {
int ans;
ans = addDigits(3749);
printf("\nSingle digit answer is %d\n", ans);
return 0;
}
|
C | #define DOUBLE_STACK_ALLOCATOR_IMPLEMENTATION
#include "double_stack_allocator.h"
#include <criterion/criterion.h>
#define LOG_ALLOCATOR(a) \
cr_log_info("{capacity = %d, bottom = %d, top = %d}", a.capacity, a.bottom, a.top)
Test(dsa_double_stack_allocator, initialization) {
int size = 16;
dsa_double_stack_alloc... |
C | #include <assert.h>
#include <libinput.h>
#include <stdlib.h>
#include <wlr/backend/session.h>
#include <wlr/interfaces/wlr_switch.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/util/log.h>
#include "backend/libinput.h"
#include "util/signal.h"
struct wlr_switch *create_libinput_switch(
struct libinput_dev... |
C | #include <stdio.h>
#include <stdlib.h>
//Defining static stuff
#define photoSize 512
typedef unsigned char BYTE;
int main(int argc, char *argv[])
{
//Check usage
if (argc < 2)
{
printf("Usage: ./recover image\n");
return 1;
}
//filename
char *gallery = argv[1];
// open i... |
C | #include <bst.h>
int max(int a, int b)
{
if (a < b)
return (a);
return (b);
}
int height(t_node *node)
{
if (!node)
return (0);
return (max(height(node->left), height(node->right)) + 1);
}
|
C | #include <unistd.h>
void ft_putchar(char c)
{
write (1, &c, 1);
}
void ft_putstr(char *str)
{
while (*str != '\0')
ft_putchar(*(str++));
}
int main(int argc, char **argv)
{
while (argc > 1)
{
ft_putstr(argv[--argc]);
ft_putchar('\n');
}
return (0);
}
|
C | #ifndef SUPPORT_METHODS_H
#define SUPPORT_METHODS_H
#include "simulatore_drone/support_types.h"
float my_abs(float n)
{
if(n < 0)
return -n;
return n;
}
float pointDist(Point p, Point q)
{
return my_abs(sqrt( pow( ( p.x - q.x), 2 ) + pow( ( p.y - q.y ), 2 ) ));
}
lato_t _verticalOpposite(corner_... |
C | #ifndef _H_STACK_
#define _H_STACK_
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
/*
* define stackitem
*/
typedef struct stackitem stackitem;
struct stackitem {
char *data;
int length;
};
/*
* initstack() initializes the memory for the stack.
*/
void initstack();
/*
* destroys... |
C | //
// Created by timan on 2018-11-21.
//
#include <stdio.h>
#include <stdlib.h>
#include "../server.h"
#include "../netbuffer.h"
#include "message_contents.h"
#define MAX_LINE_LENGTH 1024
/*
*
* Message Contents
* DATA
* I: 354 -> data -> S: 250 // 354 Start mail input; end with <CRLF>.<CRLF>
*
* ... |
C | #ifndef LINKLIST_H
#define LINKLIST_H
#include <stdlib.h>
#include <stdio.h>
typedef char ElemType;
typedef struct LNode
{
ElemType data;
struct LNode *next;
} LinkList;
//链表的头插法
void CreateListHead(LinkList *&L, ElemType a[], int n);
//链表的尾插法
void CreateListTail(LinkList *&L, ElemType a[], int n);
//释放链表
vo... |
C | #define HASHSIZE 101
#define MAXLEN 100
// I omitted a lot of error checking
// 1. All #define directives should be at the top like above.
// 2. The program doesn't consider about string literals, character constants, comments.
// 3. It even converts macro name in #define directive.
#include <stdio.h>
#include <stdli... |
C | #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int isTrianglePossible(int a, int b, int c) {
return ((a + b) > c) && ((a + c) > b) && ((b + c) > a);
}
void readNumsFromLine(char* line, int* a, int* b, int* c) {
int nums[3] = { 0, 0, 0 };
int i = 0;
for (char* c = line; c != '\n' && c != '\0'; c++) {
if (*... |
C | #include <stdio.h>
int ft_unmatch(int *tab, int length);
int main(void)
{
int tab[7] = {1, 1, 3, 4, 3, 4, 2};
printf("%d\n", ft_unmatch(tab, 7));
int tab2[5] = {6, 6, 3, 10, 3};
printf("%d\n", ft_unmatch(tab2, 5));
int tab3[11] = {10, 1, 1, 3, 4, 677, 3, 4, 677, 9, 10};
printf("%d\n", ft_unmatch(tab3, 11));... |
C | #include <stdio.h>
int main()
{
float R1, R2, Rs, Rp;
printf("Unesi vrijednost R1: ");
scanf("%f", &R1);
printf("Unesi vrijednost R2: ");
scanf("%f", &R2);
Rs = R1 + R2;
Rp = R1 * R2 / (R1 + R2);
printf("Serijski otpor je: %.2f\n", Rs);
printf("Paralelni otpor je: %.2f\n", Rp);
... |
C | #include "encoding.h"
#include "platform.h"
#include "proto.h"
#define SIZE 256
int a[SIZE];
void PROFILE loop()
{
volatile int n = 0;
int i=0;
for (i = 0; i < SIZE; ++i)
{
a[i] = i;
n += a[i];
}
}
void PROFILE unroll4()
{
volatile int n = 0;
int i=0;
for (i = 0; i < SIZE; i+=4)
{
a[i] = i;
a[i+1] ... |
C | /*
* =====================================================================================
*
* Filename: main.c
*
* Description:
*
* Version: 1.0
* Created: 2017年02月20日 13时02分20秒
* Revision: none
* Compiler: gcc
*
* Author: YOUR NAME (),
* Organization:... |
C | #include <stdio.h>
int main ()
{
int M, N, R;
printf (" Ingrese dos enteros positivos: ");
scanf ("%d %d", &M, &N);
if (M < N)
{
R = M; // utilizamos R como variable auxiliar
M = N;
N = R;
}
for (R = M%N ; R != 0 ; R = M%N)
{
M = N;
N = R;
}
printf (" El m... |
C | /* Implements a dynamically-allocated symbol table */
#ifndef TABLE_H
#define TABLE_H
#include <stdio.h>
#include <stdlib.h>
/*function that add to the attrebute of the symble another attrebute*/
void add_attribute_to_item(table item, char* attribute);
/* the function search for the symbol and return the pointer to t... |
C | /*
* stringutils.c
* functions to manipulate strings
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "stringutils.h"
#include "basic-types.h"
char * merge(const char * string1, const char * string2) {
Uint string1_length = strlen(string1);
Uint string2_length = strlen(string2);
char *r... |
C | #ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(void)
{
char * line = NULL;
size_t len = 0;
ssize_t read;
read = getline(&line, &len, stdin);
printf("Retrieved line of length %zu :\... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parse.c :+: :+: :+: ... |
C | int f(int n)
{
int a[n];
int sum = 0;
for (int i = 0; i < n; ++i)
for (int j = 0; i + j <= n; ++j)
sum += a[i + j];
return sum;
}
|
C | /* program to double the last digit of no.*/
#include<stdio.h>
void main()
{
int n;
printf("please enter the no. of which you want to double the last digit");
starts:
printf("please keep the last digit less than 5");
scanf("%d",&n);
if(n%10>=5)
{ goto starts;
}
else
{n=n+(n%10);}
... |
C | // Polynomial rings R[x], and polynomial rings modulo polynomials,
// i.e. R[x]_{f(x)}.
// Requires:
// * gmp.h
// * field.h
#ifndef __PBC_POLY_H__
#define __PBC_POLY_H__
// Initializes a polynomial ring.
void field_init_poly(field_ptr f, field_ptr base_field);
// Initializes a polynomial modulo ring.
// Requires po... |
C | #include <stdio.h>
#define N 5 //how many elements input?
int main() {
int a[N], b[N], aub[2*N];
printf("Enter elements of set A (integer type) : ");
for (int i = 0; i < N; i++)
{
scanf_s("%d", &a[i]);
}
printf("Enter elements of set B (integer type) : ");
for (int i = 0; i < N; i++)
{
s... |
C | #include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "SDL_timer.h"
#include "framework.h"
#include "glsys.h"
#define ARRAY_COUNT(array) (sizeof(array)/sizeof(array[0]))
typedef enum EVertexAttrIndex {
VERTEX_ATTR_VS_INDEX_POSITION
} EVertexAttrIndex;
static const FrameworkShaderA... |
C | #include<stdio.h>
int main()
{
int i,j;
int tda[3][3]={8,4,-1,0,1,3,5,4,8};
int ttdda[3][3]={-4,6,2,1,3,7,5,4,1};
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d ",tda[i][j]);
}
printf("\n");
}
printf("\n\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)... |
C | //4. Logical operators = &&, ||, !
/*Logical Operators are used with binary variables.
They are mainly used in conditional statements and loops for evaluating
a condition.
&&:will return true if both variables are true, else it would return false.
||:will return false in both variables are false, else it would ret... |
C | ///////////////////////////////////////////////////////////////////////////////
// 1. Includes, macros, etc.
///////////////////////////////////////////////////////////////////////////////
// includes
#include <unistd.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#i... |
C | #include<stdio.h>
#include<sys/stat.h>
#include<time.h>
#include<stdlib.h>
int main(int argc, char *argv[])
{
struct stat buf;
if(stat(argv[1], &buf) == -1)
{
perror("stat");
return 1;
}
printf("i-node number: %ld\n", (long) buf.st_ino);
printf("Link count: %ld\n", (long) buf.st_nlink);
printf("UID: %ld GI... |
C | /*
Package: Q - Fixed point (Q15.16) math. (adapted from libfixmath)
File : Q_sqrt.c
Author : Afonso Santos, Portugal
Last revision: 11h05 August 29 2016
*/
#include "Q.h"
Q
Q_sqrt
( const Q inValue )
{
const uint8_t neg = (inValue < 0) ;
uint32_t num = neg ? -inValue : inValue ;
uint32_t result =... |
C | #include "holberton.h"
#include <stdio.h>
/**
* main - this program adds two numbers
(* a blank line
*@argc: this is the quantity of parameters
*@argv: the parameter to put in the program.
* Description: this program adds two numbers)?
* Return: return 0 or 1
*/
int main(int argc, char *argv[])
{
int i, j;
int res... |
C | /**
* @file print_server_client.h
* @author Jeramie Vens
* @date 2015-02-23
* @date 2015-02-23: Last updated
* @brief The public API of libprinter.so library
* @copyright MIT License (c) 2015
*/
/*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDI... |
C | #include <stdio.h>
int main() {
long long int A, B, res;
scanf("%lld %lld", &A, &B);
res = A * B;
printf("%lld", res);
return 0;
}
|
C | //program to check a perfect number
#include<stdio.h>
void main()
{
int num,i,sum=0;
printf("Enter a number to check: ");
scanf("%d",&num);
for(i=1;i<num;i++)
{
if(num%i==0)
{
sum+=i;
}
}
if(sum==num)
printf("\n%d is a perfect number\n",num);
else
printf("\n%d is not a perfe... |
C | #include <stdio.h>
void calcuadrado (l1,l2){
int sup;
sup=l1*l2;
printf("la superficie es %d",sup);
return 0;
}
|
C | #include <stdio.h>
void change(int *a, int *b)
{
int *c = a;
a = b;
b = c;
}
int main(void)
{
int a = 10;
int b = 20;
printf("%d %d\n", a, b);
change(&a, &b);
printf("%d %d\n", a, b);
return 0;
} |
C | #include<stdio.h>
int DigitPrinter(int num) {
int digit;
while(num >= 10) {
digit = num % 10;
printf("%d ",digit);
num = num / 10;
}
return digit;
}
int main() {
int num = 12345;
int l_digit = DigitPrinter(num);
printf("%d\n",l_digit);
}
|
C | #include "led.h"
uint16_t led_time[4][2] = {0};
uint16_t led_count[4] = {0};
uint8_t led_flag[4] = {0};
void Led_GPIO_Init(void) {
RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN;//GPIOD clock enable
GPIOD->MODER &= ~0xFF000000;//Clear Pin 12,13,14,15 mode
GPIOD->MODER |= 0x55000000;//PD12,13,14,15 output
GPIOD->OSPEEDR &= ~... |
C |
/* file: logistic.c Ikaro Silva Oct 10, 2014
Last revised: -
-------------------------------------------------------------------------------
hennon: TODO:Description
Copyright (C) 2014 Ikaro Silva
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Pu... |
C | /*Federico Madden
COEN 12 Prof. Liu
MFW 10:30AM
5/8/2018
*/
#include<stdio.h>
#include<assert.h>
typedef struct student
{
int age;
int id;
}STUDENT;
typedef struct set
{
int count;
int length;
STUDENT* students;
}SET;
SET* createDataSet(int maxStudents);
void destroyDataSet(SET *sp);
STUDENT* searchAge(... |
C | /*
* @Author: jiejie
* @Github: https://github.com/jiejieTop
* @Date: 2019-12-25 23:54:19
* @LastEditTime: 2020-06-17 15:23:09
* @Description: the code belongs to jiejie, please keep the author insalof_formation and source code according to the license.
*/
#include "format.h"
#include "salof_defconfig.h"
#ifdef ... |
C | /** @file
* GL EmbeddedProCamp - Task#3
*
* Create queue library based on array:
* - int Put(int); // add element
* - int Get(*int); // read element and remove from queue
* - Int Read(*int); // read element without removing it from stack
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "... |
C | #include <stdio.h>
#include <omp.h>
#include <stdlib.h>
#include <math.h>
int primo(int n){
int i, j = sqrt(n);
for(i = 2; i <= j; i++)
if (n % i == 0)
return 0;
return 1;
}
int trial(int n_primo){
int i,j,k;
i =1;
j =2;
while(i < n_primo){
if(primo(++j)){
i++;
}
}
return j;
}... |
C | #include <stdio.h>
int main(void)
{
int a,b,i,n;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d %d",&a,&b);
printf("Case #%d: %d + %d = %d\n",i,a,b,a+b);
}
} |
C | #include <stdio.h>
#include <stdlib.h>
#include "memoryAllocator.h"
void TestMemoryAllocatorInit()
{
void * allocaition = malloc(40);
MemoryAllocator * memory = MemoryAllocator_init(allocaition, 40);
if (memory->m_size != 40)
{
printf("%s", "Test MemoryAllocatorInit Fail\n");
}
else
pri... |
C | /* SPDX-License-Identifier: BSD-3-Clause */
/*
* Eventing - infrastructure for signal passing between independent contexts
*
* Copyright (c) 2018-2019 Mutant Industries ltd.
*/
#ifndef _SYS_EVENT_H_
#define _SYS_EVENT_H_
#include <stddef.h>
#include <defs.h>
#include <action/signal.h>
#include <action/queue.h>
... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line.c :+: :+: :+... |
C | #include <ctype.h>
#include <mem.h>
#include <stdlib.h>
#include <stdio.h>
#include "main.h"
int isWhite(char c), isDelim(char c);
int getIdCommand(char *command);
void basicPrint(struct Program *program),
basicInput(struct Program *program),
basicIf(struct Program *program),
basicGoto(struct... |
C | #include<stdio.h>
long int rev(long int x)
{
int i,j;
long int ans=0;
for(i=0;x!=0;i++)
{
j=x%10;
ans=10*ans+j;
x=x/10;
}
return ans;
}
int main()
{
int i,t,j;
long int n,s,r;
scanf("%d",&t);
for(i=0;i<t;i++)
{
scanf("%ld",&... |
C | #ifndef __HASH_T__
#define __HASH_T__
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
#include <stdbool.h>
typedef unsigned int Index;
typedef struct HashTable_SC hashtbl;
typedef struct ListNode list;
typedef list *Position;
typedef struct HashTable_LP hashtbl_LP;
... |
C | /*
* File: Field.c
* Author: Jarod Wong
*
*/
#include "Field.h"
#include "FieldOled.h"
#include "Oled.h"
#include "OledDriver.h"
#include "Protocol.h"
void FieldInit(Field *f, FieldPosition p)
{
int row;
int col;
for (row = 0; row < FIELD_ROWS; row++) {
for (col = 0; col < FIELD_COLS; col++) ... |
C | /*usando a estrutura de repetio WHILE*/
#include<stdio.h>
int main ( void ) {
int contador = 1;
do {
printf( "%d ", contador); /*exibe o contador*/
} while ( ++contador <= 10 );
return 0;
}
|
C | /*
** EPITECH PROJECT, 2018
** get_item_by_id
** File description:
** get_item_by_id
*/
#include "my_rpg.h"
item_t *get_item_by_id(list_t **head, char *id)
{
list_t *curr = *head;
while (curr) {
if (my_are_equals(curr->item->id, id) == 1)
return (curr->item);
curr = curr->next;
}
return (NULL);
}
|
C | /*
19. OpenGL8
Visual Studio 2013
22.03.2016
:
1) 7 :
, , , , , ,
( - F8, F9, F11, NUMPAD0, NUMPAD1, NUMPAD2 )
2) - Q E
3) , , ( , , )
. , ,
:
1. F5 - -
2. F6 - -
3. F7 - -
3. F9 - -
4. F10 - - () ()
5. F11 - - () ()
6. N... |
C | /* sbfi.c -- Simple Reference BrainFuck Interpreter
**
** Written by Robert Quattlebaum <darco@deepdarc.com>
** This program can be considered PUBLIC DOMAIN.
**
** This interpreter assumes no-change on EOF.
*/
#include <stdio.h>
#include <time.h>
#define PRINT_BFOPS_AT_EXIT (1)
#define MAX_PROG_SIZE (6... |
C | #include "spi_driver.h"
#include "lcd_driver.h"
#include <avr/io.h>
#include <stdbool.h>
volatile bool mosiState = false;
volatile bool misoState = false;
void spiStructInit(volatile uint8_t *Port, unsigned char SSPin, unsigned char SCKPin, unsigned char MOSIPin, unsigned char MISOPin)
{
spiInit.spiPort = Port;
s... |
C | #include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#define BUFFER_SIZE 1000
//removes empty lines from a file e.g. lines which have only the new line character
int filter(FILE *input, FILE *output) {
while (!feof(input)) {
if (ferror(input)) {
return 1;
}
char ch;
... |
C | #include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
#include <math.h>
#include <float.h>
const long double TOTAL_WORK = 99.0e50;
const long double NUM_WORKERS = 99.0;
const long double WORK_PER_WORKER = 1.0e50;
long double PI = 0.0;
int client(long start_n);
int server(void);
long double calc(long start_n);
/*... |
C | //
// shake.h
// SplitFilterDemo
//
// Created by 胡阳 on 2020/4/24.
// Copyright © 2020 胡阳. All rights reserved.
//抖动滤镜: 颜色偏移 + 微弱的放大效果
precision highp float;
// 纹理
uniform sampler2D inputTexture;
// 传递过来的 纹理坐标
varying vec2 v_textureCoordinate;
// 传递进来的时间
uniform float time;
// 一次特效的持续时间
const float duration = 0.... |
C | /* First 21 Fibonacci Numbers are :-
F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765
*/
// #include <stdio.h>
// int fibonacci(int number){
// if (number == 0 || number == 1)
// {
// retur... |
C |
#include "include/private/types.h"
static uint32_t last_error_code;
static const char *last_param;
void ecs_throw(
uint32_t error_code,
const char *param)
{
last_error_code = error_code;
last_param = param;
}
uint32_t ecs_raise(void)
{
uint32_t code = last_error_code;
if (last_error_code) {... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.