#include<iostream> int main(){ int M; int a[1000]; a[0]=1,a[1]=1; for(int i=2;i<n;i++){ a[i]=a[i-1]+a[i-2]; } while(scanf("%d",&M)&&M!=0){ cout<<a[M]<<'\n'; } } /* Main.cc: In function 'int main()': Main.cc:6:16: error: 'n' was not declared in this scope for(int i=2;i<n;i++){ ^ Main.cc:10:3: error: 'cout' was not declared in this scope cout<<a[M]<<'\n'; ^~~~ Main.cc:10:3: note: suggested alternative: In file included from Main.cc:1: /usr/include/c++/8/iostream:61:18: note: 'std::cout' extern ostream cout; /// Linked to standard output ^~~~ */ |
Double click to view unformatted code.