Fix: no need for the if condition there
Instead check if no arguments were given and exit sooner.
This commit is contained in:
13
src/main.c
13
src/main.c
@@ -12,8 +12,13 @@ int main(int argc, char** argv) {
|
|||||||
srand((uint32_t)(ts.tv_nsec ^ ts.tv_sec)); // combine seconds and nanoseconds
|
srand((uint32_t)(ts.tv_nsec ^ ts.tv_sec)); // combine seconds and nanoseconds
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// just print whether it's heads or tails
|
||||||
|
if (argc == 1) {
|
||||||
|
printf("%s\n", (rand() & 1) ? "heads" : "tails");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// if we have input; perform coinflips for those times
|
// if we have input; perform coinflips for those times
|
||||||
if (argc > 1) {
|
|
||||||
for (uint32_t i = 1; i < argc; ++i) {
|
for (uint32_t i = 1; i < argc; ++i) {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
uint32_t headsc = 0;
|
uint32_t headsc = 0;
|
||||||
@@ -37,10 +42,4 @@ int main(int argc, char** argv) {
|
|||||||
// print the results
|
// print the results
|
||||||
printf("results:\n heads: %u\n tails: %u\n", headsc, tailsc);
|
printf("results:\n heads: %u\n tails: %u\n", headsc, tailsc);
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// just print whether it's heads or tails
|
|
||||||
printf("%s\n", (rand() & 1) ? "heads" : "tails");
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user