답안 #19197

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

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

	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 GetMax(int, int*)’:
tutorial2.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
/tmp/ccqJ56pd.o: In function `main':
tutorial2.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccFB7Ig6.o:grader.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status