fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5. int fibonacci(int n){
  6. vector<int> s;
  7. s.push_back(0);
  8. s.push_back(1);
  9. for (int i=2;i<n;i++){
  10. s.push_back(s[i-1]+s[i-2]);
  11. }
  12. for(auto i=s.begin();i!=s.end();i++){
  13. cout<<*i<<" ";
  14. }
  15. cout<<endl;
  16. int max=*(s.end()-1);
  17.  
  18. }
  19. int main() {
  20. // your code goes here
  21. int n=10;
  22. int max=fibonacci(n);
  23. cout<<max<<endl;
  24.  
  25.  
  26. return 0;
  27. }
Compilation error #stdin compilation error #stdout 0s 15240KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int fibonacci(int)’:
prog.cpp:16:18: error: invalid type argument of unary ‘*’ (have ‘__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}’)
  int max=*s.back();
                  ^
stdout
Standard output is empty