Submission #13693

#TimeUsernameProblemLanguageResultExecution timeMemory
13693taehoon1018최댓값 (tutorial2)C++98
Compilation error
0 ms0 KiB
#include <stdio.h> int GetMax(int n, 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,n); printf("%d", max); return 0; }

Compilation message (stderr)

tutorial2.cpp: In function ‘int main()’:
tutorial2.cpp:31:19: error: invalid conversion from ‘int*’ to ‘int’ [-fpermissive]
   max = GetMax(A,n);
                   ^
tutorial2.cpp:3:5: note: initializing argument 1 of ‘int GetMax(int, int*)’
 int GetMax(int n, int* p)
     ^
tutorial2.cpp:31:19: error: invalid conversion from ‘int’ to ‘int*’ [-fpermissive]
   max = GetMax(A,n);
                   ^
tutorial2.cpp:3:5: note: initializing argument 2 of ‘int GetMax(int, int*)’
 int GetMax(int n, int* p)
     ^
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);
                     ^