am003507   7년 전

C 로 작성된 코드를

같은 로직으로 JAVA로 다시 짜서 제출 했는데

틀렸다고 나오네요 

이유가 뭘까요....?

아래의 코드는 C 로 작성된 코드입니다.


#include <stdio.h>

#define CARDS10000000

int c[CARDS *2 /32 +1];

int main()

{

    int n, r, m;

    scanf("%d", &n);

    while(n-->0){

        scanf("%d", &r);

        r += CARDS;

        c[r/32] |= 1<<r%32;

    }

    scanf("%d", &m);

    while(m-->0){

        scanf("%d", &r);

        r += CARDS;

        printf((c[r/32] & 1<<r%32)?"1 ":"0 ");

    }

}

am003507   7년 전

 result.append((c[r / 32] & 1 << r % 32) > 0 ? "1 " : "0 "); 

이부분 논리 연산 순서 때문인가 해서 수정 해봤지만 안되네요 하하

댓글을 작성하려면 로그인해야 합니다.