제출 #18910

#제출 시각아이디문제언어결과실행 시간메모리
18910dltldls95최댓값 (tutorial2)C++98
컴파일 에러
0 ms0 KiB
#include <algorithm> int main() { int num; std::cin >> num; for (int i = 0; i < num; i++) { std::cin >> arr[i]; } std::cout<<GetMax(num, arr)<<std::endl; } int GetMax(int n, int *a) { return *max_element(a, a + n); }

컴파일 시 표준 에러 (stderr) 메시지

tutorial2.cpp: In function ‘int main()’:
tutorial2.cpp:6:3: error: ‘cin’ is not a member of ‘std’
   std::cin >> num;
   ^
tutorial2.cpp:9:4: error: ‘cin’ is not a member of ‘std’
    std::cin >> arr[i];
    ^
tutorial2.cpp:9:16: error: ‘arr’ was not declared in this scope
    std::cin >> arr[i];
                ^
tutorial2.cpp:11:3: error: ‘cout’ is not a member of ‘std’
   std::cout<<GetMax(num, arr)<<std::endl;
   ^
tutorial2.cpp:11:26: error: ‘arr’ was not declared in this scope
   std::cout<<GetMax(num, arr)<<std::endl;
                          ^
tutorial2.cpp:11:29: error: ‘GetMax’ was not declared in this scope
   std::cout<<GetMax(num, arr)<<std::endl;
                             ^
tutorial2.cpp:11:32: error: ‘endl’ is not a member of ‘std’
   std::cout<<GetMax(num, arr)<<std::endl;
                                ^
tutorial2.cpp: In function ‘int GetMax(int, int*)’:
tutorial2.cpp:16:31: error: ‘max_element’ was not declared in this scope
   return *max_element(a, a + n);
                               ^
tutorial2.cpp:16:31: note: suggested alternative:
In file included from /usr/include/c++/4.9/algorithm:62:0,
                 from tutorial2.cpp:1:
/usr/include/c++/4.9/bits/stl_algo.h:5510:5: note:   ‘std::max_element’
     max_element(_ForwardIterator __first, _ForwardIterator __last,
     ^
tutorial2.cpp:18:2: warning: control reaches end of non-void function [-Wreturn-type]
  }
  ^