View Code of Problem 23

#include  <stdio.h>
#include  <stdlib.h>
#include  <math.h>
#include  <string.h>

// 斐波纳契序列
int main()
{
	int m,i;
	long int fbnq[100];

	//
	fbnq[0]=1;fbnq[1]=1;
	for (i=2;i<=90;i++) 
	{
		fbnq[i] = fbnq[i-1] + fbnq[i-2];
	}

	while (scanf("%d",&m)!=EOF)
	{
		if(m==0) break;
		printf("%d\n",fbnq[m]);		
	}
	
	return 0;
	
}

Double click to view unformatted code.


Back to problem 23