제출 #13691

#제출 시각아이디문제언어결과실행 시간메모리
13691taehoon1018최댓값 (tutorial2)C++98
컴파일 에러
0 ms0 KiB
#include <stdio.h> GetMax(int* p) { int i,max; max = *p for(i=0;i<n;i++) { if(*(p+i)>*p) max = *(p+i); } return max; } int main() { int A[10]; int i; int n, max; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d", A+i); } max = GetMax(A); printf("%d", max); return 0; }

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

tutorial2.cpp:3:14: error: ISO C++ forbids declaration of ‘GetMax’ with no type [-fpermissive]
 GetMax(int* p)
              ^
tutorial2.cpp: In function ‘int GetMax(int*)’:
tutorial2.cpp:9:4: error: expected ‘;’ before ‘for’
    for(i=0;i<n;i++)
    ^
tutorial2.cpp:9:14: error: ‘n’ was not declared in this scope
    for(i=0;i<n;i++)
              ^
tutorial2.cpp:9:19: error: expected ‘;’ before ‘)’ token
    for(i=0;i<n;i++)
                   ^
tutorial2.cpp: In function ‘int main()’:
tutorial2.cpp:24:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&n);
                 ^
tutorial2.cpp:28:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", A+i);
                     ^