패스트터틀

(Baekjoon) etc.. - (1) 이진수 연산 본문

Algorithm/baekjoon

(Baekjoon) etc.. - (1) 이진수 연산

SudekY 2019. 11. 21. 15:52

https://www.acmicpc.net/problem/12813

 

12813번: 이진수 연산

총 100,000 비트로 이루어진 이진수 A와 B가 주어진다. 이때, A & B, A | B, A ^ B, ~A, ~B를 한 값을 출력하는 프로그램을 작성하시오.

www.acmicpc.net

bitmask 문제에 앞서서 손풀기

 

package etc;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.Buffer;

public class _12813{

    public static void main(String args[]) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String A[] = br.readLine().split("");
        String B[] = br.readLine().split("");

        for (int i = 0; i < A.length; i++) {
            System.out.print(Integer.parseInt(A[i]) & Integer.parseInt(B[i]));
        }
        System.out.println();
        for (int i = 0; i < A.length; i++) {
            System.out.print(Integer.parseInt(A[i]) | Integer.parseInt(B[i]));
        }
        System.out.println();
        
        for (int i = 0; i < A.length; i++) {
            System.out.print(Integer.parseInt(A[i]) ^ Integer.parseInt(B[i]));
        }
        System.out.println();
        
        for (int i = 0; i < A.length; i++) {
            System.out.print(Integer.parseInt(A[i]) ^ 1);
        }
        System.out.println();
        
        for (int i = 0; i < A.length; i++) {
            System.out.print(Integer.parseInt(B[i]) ^ 1);
        }

    }
}

 

 

 

 

 

 

 

백준문제풀이Github : 

https://github.com/sdk0213/baekjoon-study

 

sdk0213/baekjoon-study

solve a baekjoon question. Contribute to sdk0213/baekjoon-study development by creating an account on GitHub.

github.com

 

Comments