Commit 7d94f3c5 authored by Matthias Braun's avatar Matthias Braun
Browse files

reindent source

parent a0fe04bd
......@@ -22,54 +22,54 @@ static int SIZE = 500; //8190;
/* Gl: 8190 takes too long for continuous testing. */
static void mark_count(int c) {
printf("number of primes in [2..%d) : %d (correct: 2..500: 95)\n", SIZE, c);
printf("number of primes in [2..%d) : %d (correct: 2..500: 95)\n", SIZE, c);
}
static void runSieve(void) {
int ITERATIONS = 100000;
boolean *flags;
int i, prime, k, iter, p;
int iterations = 0;
int count;
int ITERATIONS = 100000;
boolean *flags;
int i, prime, k, iter, p;
int iterations = 0;
int count;
flags = (void *)malloc(sizeof(*flags) * SIZE);
flags = (void *)malloc(sizeof(*flags) * SIZE);
// loop around for measurements
while(ITERATIONS > iterations) {
for(i = 0; i < SIZE; i++)
flags[i] = true;
for(i = 2; i < SIZE; i++) {
if(flags[i]) {
prime = i;
for(k = i + prime; k < SIZE; k += prime)
flags[k] = false;
}
}
iterations++;
}
// test correctness
count = 0;
for(i = 2; i < SIZE; i++) {
if(true == flags[i]) {
count++;
}
}
mark_count(count);
// loop around for measurements
while(ITERATIONS > iterations) {
for(i = 0; i < SIZE; i++)
flags[i] = true;
for(i = 2; i < SIZE; i++) {
if(flags[i]) {
prime = i;
for(k = i + prime; k < SIZE; k += prime)
flags[k] = false;
}
}
iterations++;
}
// test correctness
count = 0;
for(i = 2; i < SIZE; i++) {
if(true == flags[i]) {
count++;
}
}
mark_count(count);
}
int main(int argc, char *argv[]) {
int i;
int i;
printf("Sieve.c\n");
printf("Sieve.c\n");
if (argc <= 1) {
printf("\nUsage: Sieve n\n");
printf("Continuing with default input.\n");
} else {
SIZE = atoi(argv[1]);
}
if (argc <= 1) {
printf("\nUsage: Sieve n\n");
printf("Continuing with default input.\n");
} else {
SIZE = atoi(argv[1]);
}
runSieve();
runSieve();
return 0;
return 0;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment