제출 #580735

#제출 시각아이디문제언어결과실행 시간메모리
580735vladiliusArranging Shoes (IOI19_shoes)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

int count_swaps(int l[]){
    int n = sizeof(l) / sizeof(l[0]);
    if (n == 2){
        if (l[0] < l[1]){
            return 0;
        }
        else {
            return 1;
        }
    }
}

int main(){
    int n; cin>>n;
    int l[n]; 
    for (int i = 0; i < n; i++){
        cin>>l[i];
    }
    cout<<count_swaps(l);
}

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

shoes.cpp: In function 'int count_swaps(int*)':
shoes.cpp:5:20: warning: 'sizeof' on array function parameter 'l' will return size of 'int*' [-Wsizeof-array-argument]
    5 |     int n = sizeof(l) / sizeof(l[0]);
      |                   ~^~
shoes.cpp:4:21: note: declared here
    4 | int count_swaps(int l[]){
      |                 ~~~~^~~
shoes.cpp:14:1: warning: control reaches end of non-void function [-Wreturn-type]
   14 | }
      | ^
/usr/bin/ld: /tmp/cc0HJ3l4.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccQpPdb8.o:shoes.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc0HJ3l4.o: in function `main':
grader.cpp:(.text.startup+0x2a8): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status