Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
150112_CribaErastotenes
//Title of this code //gcc 4.8.2 #include <stdio.h> #include <math.h> #define _T 10000 #define _CRIBA 500000 void mostrarArray(long d, long p[d]); short rellenarConPrimos(long d, long p[d]); int main(void) { long primos[_T] = {0}; if(rellenarConPrimos(_T, primos) == 0) { mostrarArray(_T, primos); } else { printf("No me toquen los cojones\n\n\n"); } return 0; } void mostrarArray(long d, long p[d]) { short i; for(i = 0 ; i < d ; i++) { if(i % 10 == 0) printf("\n"); printf("%7ld", p[i]); } return; } short rellenarConPrimos(long d, long p[d]) { char criba[_CRIBA]; long i, j; for(i = 1 ; i < _CRIBA ; i++) { criba[i] = 'p'; } for(i = 2 ; i <= sqrt(_CRIBA) ; i++) { if(criba[i] == 'p') { for(j = 2 * i ; j < _CRIBA ; j += i) { criba[j] = 'c'; } } } for(i = 1 , j = 0 ; j < d && i < _CRIBA ; i++) { if(criba[i] == 'p') p[j++] = i; } if(i == _CRIBA) return -1; return 0; }
run
|
edit
|
history
|
help
0
Check EOF Value
A_141124_arrayMaxMin02
a
Cbinsearch
PRIMER AVANCE DE NETFLIX
Sumit
Pregunta de función cantidad de digitos
Pozdravljeni v mali soli C.
My first 2D array
A_141124_arrayMaxMin01