Submission #717848

# Submission time Handle Problem Language Result Execution time Memory
717848 2023-04-02T16:13:32 Z EntityPlantt 최댓값 (tutorial2) C++14
Compilation error
0 ms 0 KB
#include <cstdio>
#include <algorithm>
int main() {
  int n, i = 0;
  scanf("%d", &n);
  int a[n];
  while (i < n) {
    scanf("%d", a + i++);
  }
  printf("%d", std::max_element(a, a + n));
  return 0;
}

Compilation message

tutorial2.cpp: In function 'int main()':
tutorial2.cpp:10:12: warning: format '%d' expects argument of type 'int', but argument 2 has type 'int*' [-Wformat=]
   10 |   printf("%d", std::max_element(a, a + n));
      |           ~^   ~~~~~~~~~~~~~~~~~~~~~~~~~~
      |            |                   |
      |            int                 int*
      |           %n
tutorial2.cpp:5:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
tutorial2.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%d", a + i++);
      |     ~~~~~^~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccDaR44z.o: in function `main':
tutorial2.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccKGSvGy.o:grader.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccKGSvGy.o: in function `main':
grader.cpp:(.text.startup+0xaa): undefined reference to `GetMax(int, int*)'
collect2: error: ld returned 1 exit status