jazykc
2013.3
upoljazykc
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Macros
Pages
jednorozmerna-pole
eratosthenovo-sito.c
Go to the documentation of this file.
1
30
#include <stdio.h>
31
#include <stdlib.h>
32
33
#ifndef MAX
34
#define MAX 100
35
#endif
36
37
int
pole[MAX];
38
39
int
main(
void
) {
40
int
i, j;
41
42
//1. pole vsech cisel
43
for
(i=2; i<MAX; i++) {
44
pole[i] = i;
45
}
46
//2. hledame nevyskrtnute
47
for
(i=2; i<MAX; i++) {
48
int
prvocislo;
49
if
(pole[i]) {
50
printf(
"%d, "
, prvocislo = pole[i]);
51
//3. vyskrtame nasobky
52
for
(j=i; j<MAX; j++) {
53
if
(0 == (pole[j] % prvocislo)) {
54
pole[j] = 0;
55
}
56
}
57
}
58
}
59
return
EXIT_SUCCESS;
60
}
Generated on Sat Dec 7 2013 22:57:26 for jazykc by
1.8.5