View Code of Problem 108

#include<stdio.h>
#include<string.h>
int main()
{
	int i,n,N=0,n1,b[100]={0};
	scanf("%d", &n);
	n1=n;
	getchar();
	while (n--)
	{
		char a[51];
		int i, f=0, f1=1, f2=2, l;
		gets(a);
		l = strlen(a);
		if (l == 1)
			b[N++]=1;
		else if (l == 2)
			b[N++]=2;
		else
		{
			for (i = 2;i<l;i++)
			{
				f = f1 + f2;
				f1 = f2;
				f2 = f;
			}
			b[N++]=f;
		}
	}
	for(i=0;i<n1-1;i++)
	{
		printf("%d\n",b[i]);
	}
			printf("%d",b[n1-1]);
}

Double click to view unformatted code.


Back to problem 108