답안 #19191

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
19191 2016-02-20T03:13:42 Z anrhks1212 최댓값 (tutorial2) C++
컴파일 오류
0 ms 0 KB
#include <iostream>
using namespace std;
int GetMax();
int main()
{
	int N;
	cin >> N;
	int *A = new int[N - 1];
	cout<<GetMax(N, A);

    return 0;
}
int GetMax(int N, int *A)
{
	int i, size = 0, max;

	for (i = 0; i<N; i++)
	{
		cin >> A[i];
	}

	max = A[0];
	for (i = 0; i < N - 1; i++)
	{
		if (max < A[i + 1])
		{
			max = A[i + 1];
		}
	}
	return max;
}

Compilation message

tutorial2.cpp: In function ‘int main()’:
tutorial2.cpp:9:19: error: too many arguments to function ‘int GetMax()’
  cout<<GetMax(N, A);
                   ^
tutorial2.cpp:3:5: note: declared here
 int GetMax();
     ^
tutorial2.cpp: In function ‘int GetMax(int, int*)’:
tutorial2.cpp:15:9: warning: unused variable ‘size’ [-Wunused-variable]
  int i, size = 0, max;
         ^