View Code of Problem 108

#include <stdio.h>
#include <string.h>
 
int main()
{
	int n, i, t, x;
	scanf("%d\n", &n);
	while(n--)
	{
		int num = 1, count = 0;
		double x1 = 1, x2 = 2, x;
		char word[81];gets(word);
        count = strlen(word);
 
		if(count == 1)
			printf("%.0lf\n", x1);
		else if(count == 2)
			printf("%.0lf\n", x2);
		else
		{
 
			for(i = 0; i < count - 2; i++)
			{
			  x=x1+x2;
			  x1=x2;
			  x2=x;
			}
 
			printf("%.0lf\n", x);
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 108