View Code of Problem 108

#include<stdio.h>
#include<string.h>
int main(){
    int i,j,len,n;
	char str[60];

	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		double f[60]={0};
		scanf("%s",&str);
		len=strlen(str);
		f[0]=1;
		f[1]=2;
		if(str[0]=='0')
			printf("0\n");
		else
		{
		  for(j=2;j<len;j++)
		  {
			f[j]=f[j-1]+f[j-2];
		  }
		   printf("%0.0f\n",f[len-1]);
		}
	}

	return 0;
}

Double click to view unformatted code.


Back to problem 108