Fix: no need for the if condition there

Instead check if no arguments were given and exit sooner.
This commit is contained in:
Quinn
2025-04-06 16:55:54 +02:00
parent 6acaff36f7
commit 8c8386740b

View File

@@ -12,8 +12,13 @@ int main(int argc, char** argv) {
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 (argc > 1) {
for (uint32_t i = 1; i < argc; ++i) {
int n = 0;
uint32_t headsc = 0;
@@ -37,10 +42,4 @@ int main(int argc, char** argv) {
// print the results
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;
}