View Code of Problem 108

#include <stdio.h>

int main()
{
	int n, i, t, x;
	scanf("%d", &n);
	while(n--)
	{
		int num = 1, count = 0, x1 = 1, x2 = 2;
		scanf("%d", &t);

		for(i = 10; num != 0; i *= 10)
		{
			num = t / i;
			count++;
		}

		if(count == 1)
			printf("%d\n", x1);
		else if(count == 2)
			printf("%d\n", x2);
		else
		{

			for(i = 0; i < count - 2; i++)
			{
				x = x1 + x2;
				x1 = x2;
				x2 = x;
			}
			printf("%d\n", x);
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 108