斐波那契数列是指一串数字,从第三项开始每一项都是前两项数字之和。例如:0,1,1,2,3,5,8,13.....................
代码如下:
int main(){ int i,n, t1=0,t2=1,nextTerm;printf("输入项目数:");scanf("%d",&n);printf("斐波那契数列应用:");for(i=1;i<=n;i++){printf("%d,",t1);nextTerm=t1+t2;t1=t2;t2=nextTerm;}return 0;}