运算时数据过大怎么处理啊
我想计算an=a(n-2)+a(n-1),1<=n<=90以下是我的代码
#include<stdio.h>
int main()
{
double n, s,m,t,k;
while (scanf("%lf", &n) && n != 0)
{
k = 2.0;
s = 2.0;
m = 1.0;
if (n == 1)s = 1;
if (n == 2)s = 2;
if (n > 2)
{
while (k<n)
{
t = s;
s = s + m;
m = t;
k++;
}
}
printf("%.0lf\n", s);
}
return 0;
}
在计算n=89和n=90时虽然能输出数据,但是结果还是不对,该怎么处理?求助