답안 #14798

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
14798 2015-06-26T07:33:23 Z aloshipda 최댓값 (tutorial2) C++
컴파일 오류
0 ms 0 KB
#include <cstdio>
#include <algorithm>
#include <vector>
int main()
{
 	int n;
  	vector<int> v;
  	scanf("%d",&n);
  for(int i=0;i<n;++i){
   	int a;
    scanf("%d",&a);
    v.push_back(a);
  }
  sort(v.rbegin(),v.rend());
  printf("%d",v[0]);
  return 0;
  
}

Compilation message

tutorial2.cpp: In function ‘int main()’:
tutorial2.cpp:7:4: error: ‘vector’ was not declared in this scope
    vector<int> v;
    ^
tutorial2.cpp:7:4: note: suggested alternative:
In file included from /usr/include/c++/4.9/vector:64:0,
                 from tutorial2.cpp:3:
/usr/include/c++/4.9/bits/stl_vector.h:214:11: note:   ‘std::vector’
     class vector : protected _Vector_base<_Tp, _Alloc>
           ^
tutorial2.cpp:7:11: error: expected primary-expression before ‘int’
    vector<int> v;
           ^
tutorial2.cpp:12:5: error: ‘v’ was not declared in this scope
     v.push_back(a);
     ^
tutorial2.cpp:14:8: error: ‘v’ was not declared in this scope
   sort(v.rbegin(),v.rend());
        ^
tutorial2.cpp:14:27: error: ‘sort’ was not declared in this scope
   sort(v.rbegin(),v.rend());
                           ^
tutorial2.cpp:14:27: note: suggested alternative:
In file included from /usr/include/c++/4.9/algorithm:62:0,
                 from tutorial2.cpp:2:
/usr/include/c++/4.9/bits/stl_algo.h:4705:5: note:   ‘std::sort’
     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
     ^
tutorial2.cpp:8:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&n);
                  ^
tutorial2.cpp:11:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&a);
                   ^