제니노트

[기초-비교연산] 1049-1052 [자바] 본문

코딩테스트/코드업

[기초-비교연산] 1049-1052 [자바]

yangjennie 2023. 1. 17. 21:12
반응형

1049

두 정수(a, b)를 입력받아

a가 b보다 크면 1을, a가 b보다 작거나 같으면 0을 출력하는 프로그램을 작성해보자.

 

 

import java.io.*;
import java.util.*;

//1049
public class Main{ 
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine()," ");
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        if(a>b)
            System.out.println("1");
        else
            System.out.println("0");



    }
}

 

 

1050

두 정수(a, b)를 입력받아
a와 b가 같으면 1을, 같지 않으면 0을 출력하는 프로그램을 작성해보자.

 

 

import java.io.*;
import java.util.*;

//1050
public class Main{ 
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine()," ");
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        if(a==b)
            System.out.println("1");
        else
            System.out.println("0");



    }
}

 

 

1051

두 정수(a, b)를 입력받아
b가 a보다 크거나 같으면 1을, 그렇지 않으면 0을 출력하는 프로그램을 작성해보자.

 

 

import java.io.*;
import java.util.*;

//1051
public class Main{ 
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine()," ");
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        if(a<=b)
            System.out.println("1");
        else
            System.out.println("0");



    }
}

 

 

1052

두 정수(a, b)를 입력받아
a와 b가 서로 다르면 1을, 그렇지 않으면 0을 출력하는 프로그램을 작성해보자.



import java.io.*;
import java.util.*;

//1052
public class Main{ 
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine()," ");
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        if(a!=b)
            System.out.println("1");
        else
            System.out.println("0");



    }
}

 

 

반응형
Comments