int main() { int a = 0; int b = 0; for (a = 1, b = 1; a <= 100; a++) { if (b >= 20) break;//跳出for循环,执行for循环下面的语句 if (b % 3 == 1) { b = b + 3; continue;//跳过此次for循环,即跳过后面的代码,直接重新执行for循环 } b = b - 5; } printf("%d\n", a);//答案是8 return 0; }
int main() { int a = 0; int b = 0; for (a = 1, b = 1; a <= 100; a++) { if (b >= 20) break;//跳出for循环,执行for循环下面的语句 if (b % 3 == 1) { b = b + 3; continue;//跳过此次for循环,即跳过后面的代码,直接重新执行for循环 } b = b - 5; } printf("%d\n", a);//答案是8 return 0; }