View Code of Problem 108

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

Double click to view unformatted code.


Back to problem 108