You can merge any count of loops, using multiplication and rest from division (just the multiplication has not to overflow).
void f(int iter, int row, int col) {
for (int i = 0; i < iter * row * col; i++) {
printf("%s%s%s%s",
i % col == 0 ? "*" : "",
"_",
i % col == col - 1 ? "*
" : "",
i % (row * col) == (row * col) - 1 ? "
" : "");
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…