Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
99058 | 蔡佳轩 | 斐波那契数列 | C++ | Compile Error | 0 MS | 0 KB | 481 | 2024-11-24 11:04:20 |
#include <iostream> using namespace std; int main(){ int a; cin>>a; for(int j=1;j<=n;j++){ int n; int x=1,y=1,z; cin>>n; if(n==1 || n==2){ //数列的第1项和第二项 cout<<x<<endl; } else{ for(int i=3;i<=n;i++){ //求第a项的值 z = x+y; x = y; y = z; } cout<<z<<endl; } } }
Main.cc: In function 'int main()': Main.cc:6:20: error: 'n' was not declared in this scope for(int j=1;j<=n;j++){ ^