View Code of Problem 108

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

Double click to view unformatted code.


Back to problem 108