language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include<stdio.h> int main(){ int cont; cont = 0; while(cont <= 10){ printf("Contador é igual a %d\n", cont); cont++; } return 0; }
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #define SLEN 20 char * s_gets(char *st, int n); int cal_ch(char ch, FILE *fp); int main(int argc, char *argv[]) { char ch; FILE *fp; int count; if (argc < 2) { fprintf(stderr, "Usage: %s char [filename] or printf.\n", argv[0]); ...
C
#include<stdio.h> int main() { double etox = 1, n,x,i,j,k; scanf("%lf %lf", &x,&n); if (n<0) { printf("error"); } else { for(i=1;i<=n;i++) { double po=1,m=1; for(j = i;j>0;j--) { po = po*j; } for(k=0;k<i;k++) { m=m*x; } etox+=m/po; }printf("%lf",etox); } return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #ifndef PORT #define PORT 30000 #endif #define MAX_BACKLOG 5 #define MAX_CONNECTIONS 12 #define BUF_SIZE 128 struct sockname { int sock_fd; char *username;...
C
#include <stdio.h> #include <ncurses.h> #include "vkb.h" #define WIDTH 30 #define HEIGHT 10 WINDOW *mainwin; int startx = 0; int starty = 0; void vkb_init(){ initscr(); clear(); noecho(); cbreak(); startx = (80 - WIDTH) / 2; starty = (24 - HEIGHT ) / 2; mainwin = newwin(WIDTH,HEIGHT,startx,starty); ke...
C
#include <stdio.h> int add(void *a,void *b){ int result=0; result= *(int*)a + *(int *)b; return result; } int main(int argc, char *argv[]) { int a=100; int b=15; void *p=&a; //void * ָκ printf("a=%d\n",*(int *)p); int res=add(&a,&b); printf("res=%d\n",res); return 0; }
C
/********************************************************** * Author : 梁金荣 * Email : Liangjinrong111@163.com * Last modified : 2019-09-14 13:00 * Filename : exnum.c * Description : 模块初始化函数中求最大数(使用内核中的代码) * *******************************************************/ //必要的头文件 #include<linux/kern...
C
/* Program 7.11 A dynamic prime program */ #include <stdio.h> #include <stdlib.h> #include <stdbool.h> int main(void) { unsigned long *prime = NULL; unsigned long trial = 0; bool found = false; size_t total = 300; size_t count = 0; prime = malloc(total * sizeof(int)); *prime = 2; *(prime+1) = 3; *...
C
// C Primer Plus // Chapter 16 Exercise 4: // The ANSI library features a clock() function with this description: // #include <time.h> clock_t clock (void); // Here, clock_t is a type defined in time.h. The function returns the // processor time, which is given in some implementation-dependent units. (If // the proc...
C
#include <stdlib.h> #include <sys/types.h> #include <math.h> #include "slm.h" #include "ehmm.h" long double llog10(long double x) { if (x < FLOOR_VALUE) return LOG_FLOOR_VALUE; return (long double)log10((double)x); } SLMEHMMState *SLMAllocEHMMState(int n_state,int n_vocab) { int i; long double *sprob...
C
#include"global.h" #include"posix_api.h" void main(int argc,char **argv) { int n = 0; int fd; char *path; char buf[BUFSIZ]; if(argc != 2){ printf("invalid argument!\n"); exit(1); } path = argv[1]; fd = _OpenFile(path,O_RDONLY); printf("readfile fd -- %d\n",fd); if...
C
#include <stdio.h> #include <stdlib.h> struct fdQueue { struct Node* front; struct Node* rear; }; struct fdNode { int data; struct Node* next; }; // To Enqueue a node void fdEnqueue(struct fdQueue *queue, int number) { struct fdNode* temp = malloc(sizeof(struct fdNode)); temp->dat...
C
#include <stdio.h> #include <stdlib.h> int main() { int N,*X,i; scanf("%d",&N); X = (int*)malloc(sizeof(int)); for(i=0;i<N;i++) { scanf("%d",&X[i]); }for(i=0;i<N;i++){ if(X[i]%2==0 && X[i]>0){ printf("EVEN POSITIVE\n"); }else if(X[i]%2!=0 && X[i]>0){ printf("ODD POSITIVE\n"); }else if(X[i]%2!=0 &&...
C
#include<stdio.h> #include "9.4header.h" // 显示菜单,并返回操作选项 int menu(void) { int ret, status; printf("\n%s%s\n", STAR, STAR); printf("Please enter the option of the desired hotel:\n"); printf("1.Ximalay Hotel\t\t2.Hiberton Hotel\n"); printf("3.LA Hotel\t\t4.Seven Eleven Hotel\n"); print...
C
#include <gtk/gtk.h> #define NAME "hepan" #define PWD "693640" void init_login_widget(); void enroll(GtkWidget *widget,gpointer data); void login(GtkWidget *widget,gpointer data); void gtk_win_destroy(GtkWidget *widget,gpointer data); void make_dialog(); void gtk_dialog_destroy(GtkWidget *widget, gpointer data...
C
#include <stdbool.h> #include <stdio.h> #include <sys/time.h> #include <math.h> static double CurrentTimeInSeconds() { struct timeval tv; gettimeofday(&tv, NULL); return tv.tv_sec + tv.tv_usec / 1000000.0; } bool CalcTime(int * times, double * start) { if(*times == 0) { *start = CurrentTimeInSeconds();...
C
////nota!! in problema sa cere sa folosim fct chmod! #include<stdio.h> #include<stdlib.h> #include<unistd.h> #include<pwd.h> #include<string.h> #include<errno.h> #include<fcntl.h> #include <sys/stat.h> struct stat fs; void permisiunile_sunt(struct stat x){ printf( (x.st_mode & S_IRUSR) ? "r" : "-"); printf( (x....
C
#include "listg.h" int main(int argc, char **argv) { List *list = (List *)malloc(sizeof(List)); printf("%d\n",empty(list)); /* putList(list ,1,5); putList(list ,1,6); putList(list ,2,7); putList(list ,3,8); putList(list ,1,9); putList(list ,2,10);*/ for(int i =1; i<11;i++){ putList(list,i,i); } dispList...
C
/*********************************** Trabalho : T3F4 Objectivo : Introducao a programacao em C Funcionamento : Programa para leitura de ADC e transmissão de dados via USART0 Linguagem : C Ficheiro ASM : getadc.asm Ano : 2015/2016 Unidade Cur. : Sistemas Digitais 2 Semestre : 3 Autor : Luís Silv...
C
#include<stdio.h> #include<stdlib.h> #include "string.h" typedef struct user{ int m_account_number; char m_phone_number[12]; char m_date[10]; char m_address[100]; char m_type_account[50]; char m_name[100]; int m_age; char m_country[50]; int m_id[9]; }user_t; typedef struct node{ ...
C
#ifndef __STACK_LIST_H__ #define __STACK_LIST_H__ #include <stdlib.h> // a LIFO stack using linked list typedef struct StackNode { void* key; struct StackNode* next; } StackNode; typedef StackNode* StackList; // initialize stack void init_stack_list (StackList*); // pop the stack and return the last introduced e...
C
/* * Copyright (C) 2020 */ #include <stdio.h> #include <time.h> #include <stdlib.h> #include "util.h" int partition(int* arr,int beg, int end) { int pivot_element = arr[end]; int i = beg - 1; for(int j = beg; j != end; ++j) { if(arr[j] <= pivot_element) swap(&arr[++i], &arr[j]); } swap(&arr[++i], &arr...
C
#include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <unistd.h> unsigned make_seed() { time_t tt; struct tm ttt; ttt.tm_year = 2019 - 1900; // from nini2 in IDA Pro ttt.tm_mon = 8; // sep ttt.tm_wday = 3; // wed ttt.tm_mday = 11; // only correct solu...
C
#include<stdio.h> void funcToCheckPtr(int *ptr){ printf("The pointer in funtion is %d\n",*ptr); } int main(){ int i=10; int *ptr = &i; funcToCheckPtr(ptr); printf("The pointer in main is %p\n",ptr); }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "interface.h" #define MAX_BUFFER 1024 extern struct { char *token; int (*f)(State *, char **); } function_table[]; int main() { int tokens, i, j; char command[MAX_BUFFER]; char *args[MAX_BUFFER]; State s; ...
C
#pragma once #include <stddef.h> #include <stdlib.h> #include <stdio.h> #include <string.h> static inline void* memory_allocate(size_t number, size_t size) { void* m = calloc(number, size); if (m) return m; fprintf(stderr, "out of memory\n"); exit (EXIT_FAILURE); } static inline void* memory_resize(void* mem...
C
#include<stdio.h> int main () { int a,b; scanf("%d",&a); scanf("%d",&b); if(a==b*b) printf("%d*%d=%d",b,b,a); else if(b==a*a) printf("%d*%d=%d",a,a,b); else printf("none"); return 0; }
C
/************************************************************ * Test convolution * * author: blkaron * e-mail: tekla.makkan@yahoo.co.uk ************************************************************/ #include "conv.h" int main() { int i; int *s; int size_x; int size_y; int x[] = {1, 2, 3, 4,...
C
/*Program to process data using a struct From notes Brian Willis 6/3/2013 */ #include <stdio.h> #include <stdlib.h> struct record { char last_name[20]; char first_name[15]; int age; float salary; }; void main() { typedef struct record person; person employee; char choice='y'; FILE *people; people=fopen("em...
C
#include<stdio.h> #include<stdlib.h> main(){ float salario,salario_alm,altura,peso,imc; int op; do{ printf("\n********************MULTIFUNCIONAL********************"); printf("\n*********(1) calculo de IMC ***************"); printf("\n*********(2) Almento de 10% no salario ***************"); printf("\...
C
#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> // //int main() //{ // int n = 9; // // // //0 00000000 00000000000000000001001 // //(-1)^0 * 0.00000000000000000001001 * 2^-126 // // // float *pFloat = (float *)&n; // printf("nֵΪ%d\n", n);//9 // printf("*pFloatֵΪ%f\n", *pFloat);//0.000000 // // *pFloat = 9.0...
C
#include<stdio.h> struct comp{ float real; float imag; }; struct comp comp1,comp2; struct comp sum_complex(struct comp complex1,struct comp complex2){ struct comp temp; temp.real = complex1.real + complex2.real; temp.imag = complex1.imag + complex2.imag; return temp; } int main(){ struct com...
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
#include <stdlib.h> #include <stdio.h> int funcao(int a, int b) { return a+b; } int main(int argc, char *argv[]) { int (*p)(int, int); p = &funcao; printf("%d\n", p(5,6)); return 0; }
C
#include <iostream> #include <fstream> #include "TFile.h" #include "TH1D.h" using namespace std; int main(int argc, char* argv[]){ string rmin = argv[1]; string rmax = argv[2]; cout << "Runs: " << rmin << " - " << rmax << endl; // read file with dst paths string fname = "livetime/dst_list" + rmin...
C
// strspn_ex.c : strspn() example // ------------------------------------------------------------- #include <string.h> // int strspn( const char *s1, const char *s2 ); #include <stdio.h> int main() { char wordin[256]; double val; puts( "Enter a floating-point number, please:" ); scanf( "...
C
#include <stdarg.h> #include <stdio.h> #include "variadic_functions.h" /** * print_strings - prints strings * @separator: string pritns between numbers * @n: integers passed to the funtion **/ void print_strings(const char *separator, const unsigned int n, ...) { va_list arguments; unsigned int i = 0; char ...
C
#include <raykernel.h> #define MAX_TRIES 10 #define FAST_START 550 UINT32 MathSquareRoot(UINT32 value) { UINT8 tries; UINT32 sqr_est = FAST_START; for (tries = 0; tries < MAX_TRIES; tries++) { sqr_est = (sqr_est + value/sqr_est)>>1; } return sqr_est; }
C
/** lab28.h * =========================================================== * Name: Jim Wang, 03 November 2019 (I know it's late) * Section: M4A * Project: Programming Assessment 3 Practice * Documentation: None * =========================================================== */ #ifndef MYEXE_LAB28_H #define MYEXE_LAB28_H ...
C
/*----------------------------------------------------------------------------* * Copyright (c) 2006 Southeastern Universities Research Association, * * Thomas Jefferson National Accelerator Facility * * * ...
C
/************************************************************************* FindCP.c - Change Point Detection Method ------------------- last modified : Mon Dec 19 2016 (NS) email : hawyang@princeton.edu, nsong@princeton.edu *************************************************************************/ #includ...
C
/*------------------------------------------------------------------------ MCPY.C : ॢ ணࠬ SSP 믮 뭪 .. : 01.00 / 10.08.1997 / ------------------------------------------------------------------------*/ #include "ssp.h" /* ............................................................... SUBROUTINE...
C
// // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. // /*============================================================= ** ** Source: test5.c ** ** Purpose: Do more complex overlapping. Move a section of memory back ...
C
#include <stdio.h> #include <string.h> #include <iostream> using namespace std; char m[4][4]; int iswin(char c) { int i,j; for(i=0; i<4; i++) { for(j=0; j<4; j++) if (!(m[i][j] == c || m[i][j] == 'T')) break; if (j >= 4) return 1; for(j=0; j<4; j++) if (!(m[j][i] == c || m[j][i] == 'T')) break;...
C
#include <stdlib.h> #include <stdio.h> #define MAX 30 typedef struct Pile { int taille; char tab[MAX]; } Pile; // initialisation d'une pile void init(Pile *p) { p->taille=0; } void affichage(Pile *p) { int i; printf("Pile :"); for (i=0; i<p->taille; i++) { ...
C
/* * File: dlist.h */ #include <stdio.h> #ifndef DLIST_H #define DLIST_H #ifdef __cplusplus extern "C" { #endif/*__cplusplus*/ typedef enum _DListRet { DLIST_RET_OK, DLIST_RET_OOM, DLIST_RET_STOP, DLIST_RET_INVALID_PARAMS, DLIST_RET_FAIL }DListRet; struct _DList; typedef struct _DList DList; typedef voi...
C
/** ****************************************************************************** @file @author PavelB @version V1.0 @date 03-April-2017 @brief ****************************************************************************** */ /* Includes ----------------------------------------------------...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> #include <time.h> #include "command.h" #include "irc.h" #include "diceroll.h" void snarky_answer(char *username) { char *message; int msglen = strlen(channel) + strlen(username) + 78; message= malloc(msglen); sprintf(mes...
C
#include <stdlib.h> #include <stdio.h> #include <time.h> int main(int argc, char* argv[]){ srand(time(NULL)); int max=0; int size=0; int i=0; if(argc != 4) { printf("argument count is wrong!\n"); return 0; } FILE* fp = fopen(argv[1], "w"); max = atoi(argv[3]); size = atoi(argv[2]); for (i...
C
#include<stdio.h> int nthFibonacci(int n, long long int *arr) { if (n==0) { arr[0] = 1; arr[1] = 1; return 0; } int mod = 1000000007; nthFibonacci(n/2, arr); long long int a, b, c, temp; a = arr[0]; b = arr[1]; if (a < 0) a += mod; if (b < 0) b += mod; temp = (2*b - a); printf("a * temp %lld\n", a...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <pthread.h> #include <errno.h> pthread_t thread1, thread2; pthread_mutex_t kill_thread_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t operacao_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t fazer_operacao = PTHREAD_COND_INITIALIZER; vo...
C
#include<stdio.h> #include<stdlib.h> struct s_point { int x; int y; }; typedef struct s_point t_point; void scan_dim(t_point *dim) { printf("entrer la dimension du tableau\n"); scanf("%d%d",&(dim->x),&(dim->y)); printf("dim= (%d,%d)\n", dim->x, dim->y); }
C
#pragma once typedef int socklen_t; typedef unsigned short int sa_family_t; struct sockaddr { sa_family_t sa_family; char sa_data[]; }; struct sockaddr_storage { sa_family_t ss_family; }; typedef struct fd_set { unsigned int fd_count; /* how many are SET? */ int fd_array[10]; /* an array o...
C
#include <stdio.h> int main(void) { int price = 45; int s, bottles; printf("input amount of money: "); scanf("%d", &s); bottles = s/price; // количество бутылок printf("Amount of bottles: %d\n", bottles); return 0; }
C
/* Author: Ankit Mahale. email-id: amahale2@binghamton.edu. */ #ifndef MAHALE_PA2_TRO1_H_INCLUDED #define MAHALE_PA2_TRO1_H_INCLUDED //Place the tromino tiles in correct positions void placeTiles(vector< vector<int> > &board, int bsize, int iterator_i, int iterator_j, int upper_l_i, int upper_l_j)...
C
#include "libft.h" long long int ft_atoi(const char *nptr) { unsigned long long int nb; unsigned long long int limit; int signe; signe = 1; while (*nptr == ' ' || *nptr == '\n' || *nptr == '\t' || *nptr == '\r' || *nptr == '\v' || *nptr == '\f') nptr++; if (*nptr == '+' || *nptr == '-') if (*nptr...
C
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <inttypes.h> #include <ctype.h> #include <vector.h> #include <map.h> #include <string.h> #include <assert.h> #define SPACE " \t\v" #define LNEND "\r\n" #define ALPHA "abcdefghijklmnopqrstuvwxyz" #define DIGIT "0123456789" //Kind of like a relational ...
C
/* : 0̻ 100 ߿ ¦ ϴ α׷, do while ϰ 2550 */ #include <stdio.h> int main() { int sum = 0; int i = 0; do { sum += i * 2; i++; } while (i <= 50); printf(" %dԴϴ.", sum); }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_split.c :+: :+: :+: ...
C
#include<stdio.h> #include<stdlib.h> int main(){ int n, *arr; scanf("%d", &n); for(int i=0; i<n; i++) scanf("%d", arr+i); int leader=arr[n-1]; printf("%d ", leader); for(int i=n-2; i>=0; i--){ if(arr[i] > leader){ leader = arr[i]; printf("%d ", leader); ...
C
#ifndef HEAP_H #define HEAP_H #include <stdlib.h> #include <stdio.h> #include "string.h" #include "stdbool.h" typedef struct Info{ char* key; int count; }HeapInfo; typedef struct Heap{ HeapInfo info; struct Heap *left; struct Heap *right; }HeapNode; typedef struct Queue{ int front, rear; ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* bsq_cmp.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdint.h> #include <math.h> #include <stdlib.h> #include <assert.h> #include <string.h> /* It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square. 9 = 7 + 2×1^2 15 = 7 + 2×2^2 21 = 3 + 2×3^2 25 = 7 + 2×3^2 27 = 19 + 2...
C
#include "holberton.h" /** * _getError - prints error message for shell * @ssh: the ssh _unix */ void _getError(_unix *ssh) { register int len; static char error[BUFSIZE]; char *ptr, *alpha; alpha = itoa(ssh->lineCounter); _strcat(error, ssh->shellName); _strcat(error, ": "); _strcat(error, alpha); _strcat...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #define lli long long int struct Node { lli key; lli key1; lli key2; struct Node* left; struct Node* right; }; struct Node* insert(struct Node* node,lli item) { if(node == NULL) { struct Node* c = (struct Node*)malloc...
C
#include "cursed_window.h" /* Обработчик сигнала SIGWINCH */ void sig_winch(int signo) { struct winsize size; ioctl(fileno(stdout), TIOCGWINSZ, (char *)&size); resizeterm(size.ws_row, size.ws_col); } /* Старт и первичная инициализация библиотеки ncurses */ void ncurses_start() { initscr(); noecho(...
C
#include <stdlib.h> #include <string.h> #include "assert.h" #include "exception.h" #include "arena.h" const exception_t Arena_NewFailed = {"Arena Creation Failed"}; const exception_t Arena_Failed = {"Arena Allocation Failed"}; static arena_t freechunks; static int nfree; #define THRESHOLD 10 union align{ int i; l...
C
#include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> #include <stdio.h> #include <stdlib.h> #include <sys/msg.h> #include <unistd.h> #include "string.h" #include <netinet/in.h> #include <arpa/inet.h> #define SHMSZ 2000 struct ClientInfo { pthread_t thread_id; pthread_t serverThreadId; long msg...
C
/* * $Id: kkern.c,v 1.2 1996/05/01 12:08:38 gunter Exp $ * * $Log: kkern.c,v $ * Revision 1.2 1996/05/01 12:08:38 gunter * Replace several strcpy by memmove * * Revision 1.1.1.1 1996/03/08 15:32:57 mclareni * Kuip * */ /*CMZ : 2.06/03 09/01/95 10.05.13 by N.Cremel*/ /*-- Author : Alfred Nathaniel ...
C
/*** PROBLEM STATEMENT Multiply two matrices using a fucntion and pass two input matrices as parameter of the fucntion Input Format n1 = enter number of rows in 1st matrix n2 = enter number of rows in 2nd matrix m1 = enter number of columns in 1st matrix m2 = enter number of columns in 2nd matrix a = enter the 1st mat...
C
#include "gfx/libaria/inc/libaria_editwidget.h" #include "gfx/libaria/inc/libaria_context.h" #include "gfx/libaria/inc/libaria_string.h" static laResult startEdit(laEditWidget* edit) { return LA_FAILURE; } static void endEdit(laEditWidget* edit) { } static void clear(laEditWidget* edit) { } static void accept...
C
#include <stdio.h> #include <stdlib.h> #include "compression.h" int main (int argc, char **argv){ FILE *file, *file2; file = fopen(argv[1], "rb"); file2 = fopen(argv[2], "wb"); //incrementNbits(512); if(!file || !file2){ fprintf(stderr, "Error : file is inaccessible.\n"); return 1; } ...
C
#include <CUnit/CUnit.h> #include <CUnit/Basic.h> #include <CUnit/Automated.h> #include <time.h> #include <stdlib.h> #include <stdio.h> #include <mergesort.h> void test_merge_sort_simple() { int array[] = {14, 33, 27, 10, 35, 19, 42, 44}; int length = sizeof(array) / sizeof(int); merge_sort(array, 0, length - 1);...
C
/* ==== test_create.c ============================================================ * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu * * Description : Test pthread_create() and pthread_exit() calls. * * 1.00 93/08/03 proven * -Started coding this file. */ #define PTHREAD_KERNEL #include <pth...
C
/* Copyright (C) 2014 Frank Duignan This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in th...
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
#include <ignotum.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <fcntl.h> #include <sys/mman.h> void test2(void){ ignotum_search_t search; ignotum_maplist_t list; ignotum_mapinfo_t *map; off_t addr; size_t i; /* alloc two pages next to each other *...
C
/* Test dynamic refcount and copy behavior of separate structure members. */ #include <assert.h> #include <stdbool.h> #include <openacc.h> struct s { signed char a; float b; }; static void test(unsigned variant) { struct s s = { .a = 73, .b = -22 }; #pragma acc enter data copyin(s.a, s.b) assert(acc_is_pre...
C
#include <stdio.h> int main() { int a; for(a=0;a<=255;a++) { printf("The value of ASCII of %c is %d\n", a, a); } return 0; }
C
/** * Author: Kothar Al Naamani * Date: 2020/08/20 * * A simple hello world program in C */ #include <stdlib.h> #include <stdio.h> int main(int argc, char **argv) { printf ("Kothar Al Naamani!\n"); printf("Civil Engineering!\n"); printf ("Lawand Anwer!\n"); printf("Computer Science!\n"); ret...
C
#include <stdlib.h> extern char *getenv(const char *name); extern int foo(); extern int bar(); struct s3 { int i1; int i2; char *t3; }; struct s2 { int i1; char *t2; struct s3 s3; }; struct s1 { char *t1; struct s2 s2; }; int main() { struct s1 s1; s1.s2.s3.t3 = getenv("gude...
C
#include<stdio.h> int main() { int _=10; //underscore_character is use as variable printf("%d\n",_); return 0; } /*OUTPUT 10 */
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/stat.h> #include <string.h> #include <ctype.h> char input[1024]; int input_Pos = 0; char buff[1024]; int buff_Pos = 0; void lex() { // Token 을 짤라서 buff[] 에 넣어주는 함수 memset(buff, 0, sizeof(buff)); buff_Pos = 0; while (isspace(input[input_Pos...
C
#include <stdio.h> #include <unistd.h> #include <signal.h> /** * Simple implementation of the siginterrupt */ int siginterrupt(int sig, int flag) { struct sigaction sa; // retrieve current sigaction if (sigaction(sig, NULL, &sa) == -1) return -1; if (flag) sa.sa_flags &= ~SA_RESTART; else sa.sa_flags ...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> struct node { char data[1000]; char name[1000]; int marks; struct node* next; }; typedef struct node node; void print(node* p,node *p1) { node *q=p1; while(p) { int sum=0; printf("%s %s ",p->data,p->name...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <math.h> #define GOOD_EXIT 1 #define BAD_EXIT 0 #define MAX_INPUT 60 #define BEGINNING_LINE 0 #define SKIP_FIRST 2 //prototypes int processLine(char *input, int totVSize, int curVSize, float *vect, int startI); char * mak...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> #define MAX 2 #define MIN 1 struct stat file; //MAX = (file.st_blksize+34)/42; struct node { int count; int offset[MAX+1]; char word[MAX+1][26]; struct node *link[MAX+1]; }; struct meaning { char word[50]; char mean[150]; }; str...
C
// // Created by xixi2 on 2020/3/7. // 通过定时器来读取当前进程的未决信号集 #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <sys/types.h> #include <signal.h> #include <string.h> #include <sys/time.h> void signalHandler() { sigset_t *set; sigpending(set); // 读取当前进程的未决信号集 for (int...
C
#include<stdio.h> #include<conio.h> #include<string.h> void convert(char a[20],int,int); void main() { char arr[20]; int base1,base2; printf("Enter the base : "); scanf("%d",&base1); printf("Enter the input : "); scanf("%s",arr); printf("Enter the base to convert : "); scanf("%d",&base2); convert(arr,base1,bas...
C
/* Private version of _pcre_valid_utf */ /************************************************* * Perl-Compatible Regular Expressions * *************************************************/ /* PCRE is a library of functions to support regular expressions whose syntax and semantics are as close as possible to t...
C
#include <stdio.h> int main() { double var_runoob[10]={0,1,2,3,4,5,6,7,8,9}; double *p; p = &var_runoob[9]; // p = NULL; for(int i=0;i<10;i++) { printf("%p\n",p); printf("%f\n", *p); p--; printf("%f\n",var_runoob[i]); } return 0; }
C
/*At11.C*/ #include <stdio.h> int main() { int num, soma = 0; printf("\nDigite uma sequencia terminada por zero: "); do { scanf("%d", &num); soma = soma + num; } while (num != 0); printf("\nSoma da sequencia: %d\n", soma); return 0; }
C
#include <stdio.h> int main() { int arr[30],i,size,n,in,flag=0; printf("enter array size:"); scanf("%d",&size); printf("enter array:"); for(i=0;i<size;i++) { scanf("%d",&arr[i]); } printf("\nenter number to be inserted:"); scanf("%d",&n); printf("\nenter index:"); sc...
C
#include<stdio.h> void sort(int *arr,char*suit) { int i,j,n,flag,temp; n=5; for(i=1;i<n;i++) { flag=0; for(j=0;j<n-i;j++) if(arr[j]>arr[j+1]) { flag=1; temp=arr[j]; arr[j]=arr[j+1] ; a...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* model.c :+: :+: :+: ...
C
/* ============================================================================ Name : ejercicio_clase_9_bien.c Author : cgimenez Version : Copyright : Your copyright notice Description : Hello World in C, Ansi-style ============================================================================ ...
C
#include <stdio.h> int add(int a, int b){ return (a + b); } int find_product(int* array, int len){ if (len == 1) return array[0]; return(add(find_product(array, len - 1), array[len - 1])); } int main(int argc, char const *argv[]) { int nums[] = {1,2,3,4,5,6,7,8,9,10}; int sum = find_product(nums, (sizeof(nu...
C
#include "decoder_task.h" uint32_t strBinToInt (char* strBin) { uint32_t result = 0; uint32_t p2 = 1; for (int c = strlen(strBin) - 1;c >= 0;c--) { if (strBin[c] == '1') { result += p2; } p2 *= 2; } return result; } void cardClear() { card.read = 0; for (int i = 0...
C
/*Find four elements i,j,k and l in an array such that i+j=k+l Method 1: Brute force for(i=1 to n) for(j=i+1 to n) for(k=j+1 to n) for(l=k+1 to n) TC=O(n^4) - useless! SC=O(1) Method 2: For every pair of elements in the array, add a node to the balanced BST. Each node contains (sum of pair,#pairs with this sum ...
C
/* atan function */ #include "xmath.h" double atan(double x) { /* compute atan(x) */ unsigned short hex; static const double piby2 = {1.57079632679489661923}; switch (_Dtest (&x)) { /* test for specia1 codes */ case NAN: errno = EDOM; return (x); case INF: return (DSIGN...