创建了一个C for循环,它没有进入其中。它完全跳过了它,我不知道为什么
int main(void) {
int N = 5;
int input;
scanf("%d", &input);
int c;
for(c=0; c==N; c++) {
srand(time(0));
int random = rand() % 99;
printf("Loteria: %dn", random);
if (input == random) {
printf("nAcertou!n");
}
}
return 0;
}
您似乎误解了for循环的终止条件。
for ( ; condition ; )
中的条件部分没有指定何时停止,而是在为true时继续多长时间。只要稍微改变一下你的状况就可以了。
for (c = 0; c < N; c++) {
这是迭代一个循环正好N次的惯用代码。