답안 #953126

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
953126 2024-03-25T14:29:45 Z Pacybwoah 양말 찾기 (KPI13_socks) C++17
컴파일 오류
0 ms 0 KB
#include<cstdio>
using namespace std;
int arr[32][2];
int main(){
    int n;
    scanf("%d",n);
    int x,i;
    for(i=0;i<32;i++) arr[i][0]=0,arr[i][1]=0;
    int j;
    for(i=0;i<n;i++){
        scanf("%d",x);
        x+=1000000001;
        for(j=31;j>=0;j--){
            if(x&(1<<j)) arr[j][1]^=x;
            else arr[j][0]^=x;
        }
    }
    for(i=0;i<32;i++){
        if(arr[i][0]>0&&arr[i][1]>0){
            arr[i][0]-=1000000001;
            arr[i][1]-=1000000001;
            printf((arr[i][0]<arr[i][1]?arr[i][0]:arr[i][1])<<" "<<(arr[i][1]>arr[i][0]?arr[i][1]:arr[i][0]));
            return 0;
        }
    }
}

Compilation message

socks.cpp: In function 'int main()':
socks.cpp:6:13: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'int' [-Wformat=]
    6 |     scanf("%d",n);
      |            ~^  ~
      |             |  |
      |             |  int
      |             int*
socks.cpp:11:17: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'int' [-Wformat=]
   11 |         scanf("%d",x);
      |                ~^  ~
      |                 |  |
      |                 |  int
      |                 int*
socks.cpp:22:61: error: invalid operands of types 'int' and 'const char [2]' to binary 'operator<<'
   22 |             printf((arr[i][0]<arr[i][1]?arr[i][0]:arr[i][1])<<" "<<(arr[i][1]>arr[i][0]?arr[i][1]:arr[i][0]));
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
      |                                        |                      |
      |                                        int                    const char [2]
socks.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |     scanf("%d",n);
      |     ~~~~~^~~~~~~~
socks.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         scanf("%d",x);
      |         ~~~~~^~~~~~~~