Submission #18911

# Submission time Handle Problem Language Result Execution time Memory
18911 2016-02-16T12:32:17 Z dltldls95 최댓값 (tutorial2) C++
Compilation error
0 ms 0 KB
#include <algorithm>
#include <iostream>
	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);

	}

Compilation message

tutorial2.cpp: In function ‘int main()’:
tutorial2.cpp:9:16: error: ‘arr’ was not declared in this scope
    std::cin >> arr[i];
                ^
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: 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]
  }
  ^