Problem R: 求斐波那契数列的前n项值
#include<stdio.h> int main() { int n; while(scanf("%d",&n)!=EOF){ int x1,x2,i,x; x1=1; x2=1; if(n==1) printf("1"); if(n==2) printf("1 1"); if(n>2) { printf("%d %d",x1,x2); for(i=3;i<=n;i++) { x=x1+x2; printf(" %d",x); x1=x2; x2=x; }} printf("\n"); } return 0; }