写递归函数会超时(⊙﹏⊙b汗,注意ans还要初始化,不然过不去
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
double fei(int n){
int i;
double num1 = 1, num2 = 1, ans = 0;
if ( n == 1 || n == 2)
return 1;
else{
for ( i = 3; i <= n; i++){
ans = num1 + num2;
num1 = num2;
num2 = ans;
}
}
}
int main(){
int i, n;
scanf("%d", &n);
printf("%.2f", fei(n));
return 0;
}