递推问题
#include<stdio.h>int main(){
int i, last, this, next;
last = 1; this = 1;
printf("各个月份兔子的对数:\n");
for (i = 3; i <= 12; i++){
next = last + this;
last = this; this = next;
printf("%2d月份:%3d对。", i, next);
for ((i - 2) % 4 == 0)printf("\n");
}
return 0;
}
为什么编译器显示这段代码for ((i - 2) % 4 == 0)printf("\n");前面缺少分号? for ((i - 2) % 4 == 0)printf("\n");
for ?
for循环里那个for应该是if if ((i - 2) % 4 == 0)
printf("\n"); for改成if吧
页:
[1]