View Code of Problem 108

#include<stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#define Max 100
int main()
{
	int n;
	char a[100];
	scanf("%d",&n);
	while(n--)
	{
		double x1=1,x2=2,x;
		gets(a);
		
		if(strlen(a)==1)
		  printf("%.0lf\n",x1);
		else if(strlen(a)==2)
		  printf("%.0lf\n",x2);
		else{
		 for(int i=0;i<strlen(a)-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