假如输出应该是一个Fibonacci数列.这样为啥不行?
#include<stdio.h>int main(void)
{
int total;
int baby;
int n;
int days;
total=1;
baby=1;
printf("For which day do you want to know the number of roborabbits?\n");
scanf("%d",&days);
if (0<days<=2){
printf("On day %d there is 1 roborabbit.", days);
}
else if (days>2){
for(n=1;n<=days-2;n++){
total=total+baby;
baby=total-baby;
}
printf("On day %d there is %d roborabbit.", days, total);}
}
[ 本帖最后由 given01 于 2012-11-4 05:23 编辑 ]