#include<stdio.h>
int main()
{
int n,i,un1,un2,un;
for(n=2;n<3;)
printf("please enter required number of generation:");
scanf("%d",&n);
if(n<3) printf("\n enter error!\n"); /*控制輸入正確的n值*/
}
un=un2=1;
printf("the repid increase of rabbits in first %d generation is as felow:\n",n);
printf("l\tl\t");
for(i=3;i<=n;i++)
un1=un2;
un2=un;
un=un1+un2; /*利用通項公式求解n項的值*/
printf(i%10?"%d\t":"%d\n",un);
printf("\n");
#include<stdio.h>
int main()
{
int n,i,un1,un2,un;
for(n=2;n<3;)
{
printf("please enter required number of generation:");
scanf("%d",&n);
if(n<3) printf("\n enter error!\n"); /*控制輸入正確的n值*/
}
un=un2=1;
printf("the repid increase of rabbits in first %d generation is as felow:\n",n);
printf("l\tl\t");
for(i=3;i<=n;i++)
{
un1=un2;
un2=un;
un=un1+un2; /*利用通項公式求解n項的值*/
printf(i%10?"%d\t":"%d\n",un);
}
printf("\n");
}