Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
140114_CribaErasthotenes
//Title of this code //gcc 4.8.2 #include <stdio.h> #include <math.h> #define _D 10000 void mostrarArray(long d, long v[d]); long rellenarMatrizConPrimos(long d, long v[d]); void cribarArray(long d, char c[d]); int main(void) { long primos[_D]; long primosAsignados; primosAsignados = rellenarMatrizConPrimos(_D, primos); mostrarArray(primosAsignados, primos); return 0; } void mostrarArray(long d, long v[d]) { long i; for(i = 0 ; i < d ; i++) { if(i % 10 == 0) printf("\n"); printf("%7ld", v[i]); } return; } long rellenarMatrizConPrimos(long d, long v[d]) { long ncriba = 100000; char cadenaCriba[ncriba]; long i, j; cribarArray(ncriba, cadenaCriba); for(i = 1 , j = 0 ; j < d && i < ncriba ; i++) { if(cadenaCriba[i] == 'p') { v[j++] = i; } } return j; } void cribarArray(long d, char c[d]) { long i, j; for(i = 1 ; i < d ; i++) { c[i] = 'p'; } for(i = 2 ; i <= sqrt(d) ; i++) { if(c[i] == 'p') { for(j = 2 * i ; j < d ; j += i) { c[j] = 'c'; } } } return; }
run
|
edit
|
history
|
help
0
Struct
Assignment 4
Ultimo avance de pregunta 1 guía4
First program.c
iplk
DISEÑO DE TECLADO
Random by thread
romitk
binary to txt
A_141121_factorial02