Submission #13691

#TimeUsernameProblemLanguageResultExecution timeMemory
13691taehoon1018최댓값 (tutorial2)C++98
Compilation error
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; }

Compilation message (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);
                     ^