3 ms·
That's too much branching. int i = 0; goto main_part; do { cout << ", "; main_part: cout << i; label_for_continue: // yeah,
by Joker_vD 2y ago
That's too much branching.
int i = 0;
goto main_part;
do {
cout << ", ";
main_part:
cout << i;
label_for_continue: // yeah, what about "continue"?
i++;
} while (i <= 100);
That's what most for-loops get transformed to during the translation anyhow (with the condition check on the bottom), but writing this by hand? Ugh.
Edit: actually, looking at Godbolt, it seems that gcc compiles your suggestion into exactly this shape, while clang splits the first iteration out, into something equivalent to
cout << 0;
for (int i = 1; i < 101; i++) {
cout << ", ";
cout << i;
}
Hmm.