2019-01-23 19:13:19 +01:00
|
|
|
#include <math.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
|
|
|
|
#define N 100
|
|
|
|
|
|
|
|
struct bool_store {
|
|
|
|
int v : 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct bool_store _a[N - 1];
|
|
|
|
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
int A_bf2_get(int i)
|
|
|
|
{
|
|
|
|
if (i < 2)
|
|
|
|
return 0;
|
|
|
|
return _a[i - 2].v;
|
|
|
|
}
|
|
|
|
|
|
|
|
void A_bf2_set(int i, int b)
|
|
|
|
{
|
|
|
|
_a[i - 2].v = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TRUE 1
|
|
|
|
#define FALSE 0
|
|
|
|
|
|
|
|
void doSE()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 2; i <= N; i++)
|
|
|
|
A_bf2_set(i, 1);
|
|
|
|
for (i = 2; i <= sqrt(N); i++)
|
|
|
|
if (A_bf2_get(i)) {
|
|
|
|
int j;
|
|
|
|
for (j = i * i; j <= N; j += i)
|
|
|
|
A_bf2_set(j, FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define FILL_CHAR '-'
|
|
|
|
|
2019-01-23 19:22:57 +01:00
|
|
|
void do_and_print_eratostenes()
|
2019-01-23 19:13:19 +01:00
|
|
|
{
|
|
|
|
doSE();
|
|
|
|
int i;
|
|
|
|
for (i = 0; i <= N; i++) {
|
|
|
|
if (i % 10 == 0)
|
|
|
|
putchar('\n');
|
|
|
|
putchar(' ');
|
|
|
|
if (A_bf2_get(i))
|
|
|
|
printf(" %2d", i);
|
|
|
|
else {
|
|
|
|
if (i >= 100)
|
|
|
|
putchar(FILL_CHAR);
|
|
|
|
else
|
|
|
|
putchar(' ');
|
|
|
|
if (i >= 10)
|
|
|
|
putchar(FILL_CHAR);
|
|
|
|
else
|
|
|
|
putchar(' ');
|
|
|
|
putchar(FILL_CHAR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
putchar('\n');
|
2019-01-23 19:22:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void do_and_print_mersenne()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
do_and_print_eratostenes();
|
|
|
|
do_and_print_mersenne();
|
2019-01-23 19:13:19 +01:00
|
|
|
return 0;
|
|
|
|
}
|