#斐波那契数列(不要用递归,容易内存超限) while True: try: n=int(input()) a=0 b=1 for i in range(1,n): res=a+b a=b b=res print(res) except: break
#include <iostream> using namespace std; int main(){ int n; while(cin >> n){ int a=0,b=1,f=0; for(int i=1;i<n;i++){ f=a+b; a=b; b=f; } cout << f <<endl; } return 0; }