# 1088 : 수 나열하기(등차)

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int d = sc.nextInt();
        int n = sc.nextInt();
        int result = a + (d*(n-1));
        System.out.println(result);
        sc.close();
    }
}

 

# 1090 : 수 나열하기(등비)

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int r = sc.nextInt();
        int n = sc.nextInt();
        long result = a * (long)(Math.pow(r, n-1));
        System.out.println(result);
        sc.close();
    }
}

// long 타입으로 해야 됨

 

# 1091 : 수 나열하기

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int m = sc.nextInt();
        int d = sc.nextInt();
        int n = sc.nextInt();
        long num = a;
        for(int i=1; i<n; i++) {
            num = num * m + d;
        }
        System.out.println(num);
        sc.close();
    }
}

// long 타입으로 해야 됨

 

# 1092 : 함께 문제 푸는 날(최소 공배수)

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int day = 1;
        while(day%a!=0 || day%b!=0 || day%c!=0) {
            day++;
        }
        System.out.println(day);
        sc.close();
    }
}

 

# 1093 : 이상한 출석 번호 부르기

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[23];
        for(int i=0; i<n; i++) {
            arr[sc.nextInt()-1]++;
        }
        for(int i=0; i<arr.length; i++) {
            System.out.print(arr[i]+" ");
        }
        sc.close();
    }
}

 

# 1094 : 이상한 출석 번호 부르기

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n];
        for(int i=0; i<n; i++) {
            arr[i] = sc.nextInt();
        }
        for(int i=n-1; i>=0; i--) {
            System.out.print(arr[i]+" ");
        }
        sc.close();
    }
}

 

# 1095 : 이상한 출석 번호 부르기

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n];
        for(int i=0; i<n; i++) {
            arr[i] = sc.nextInt();
        }
        int min = arr[0];
        for(int i=0; i<n; i++) {
            if (min>arr[i]) {
                min = arr[i];
            }
        }
        System.out.println(min);
        sc.close();
    }
}

 

# 1096 : 바둑판에 흰 돌 놓기

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[][] = new int[20][20];
        for(int i=1; i<=n; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            arr[x][y] = 1;
        }
        for(int i=1; i<=19; i++) {
            for(int j=1; j<=19; j++) {
                System.out.printf("%d ", arr[i][j]);
            }
            System.out.println("");
        }
        sc.close();
    }
}

 

# 1097 : 바둑알 십자 뒤집기(이건 좀)

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int arr[][] = new int[20][20];
         for(int i=1; i<=19; i++) {
            for(int j=1; j<=19; j++) {
                arr[i][j] = sc.nextInt();
            }
        }
        int n = sc.nextInt();
        for(int k=1; k<=n; k++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            for(int i=1; i<=19; i++) {
                if(arr[x][i]==0) {
                    arr[x][i] = 1;
                }
                else {
                    arr[x][i] = 0;
                }
            }
            for(int j=1; j<=19; j++) {
                if(arr[j][y]==0) {
                    arr[j][y] = 1;
                }
                else {
                    arr[j][y] = 0;
                }
            }
        }
        for(int i=1; i<=19; i++) {
            for(int j=1; j<=19; j++) {
                System.out.print(arr[i][j]+" ");
            }
            System.out.println("");
        }
        sc.close();
    }
}

 

# 1098 : 설탕 과자 뽑기 

 

#1099 : 성실한 개미 

 

https://codeup.kr/index.php

 

CodeUp

☆ 파이썬 다운로드 : 파이썬3 ☆ 무료 C언어 IDE : Code::blocks       DEV C++ ☆ 추천 온라인 IDE : C   C++11   Python3   Java ☆ 채점 가능 언어 : C, C++, JAVA, Python 3.5 ★ C++로 제출시 void main()을 사용하면

codeup.kr

'CodeUp > Java' 카테고리의 다른 글

[CodeUp] 1078-1088 (Java)  (0) 2022.11.05
[CodeUp] 1071-1077 (Java)  (0) 2022.11.04
[CodeUp] 1065-1070 (Java)  (0) 2022.11.03
[CodeUp] 1063-1064 (Java)  (0) 2022.11.02
[CodeUp] 1059-1062 (Java)  (0) 2022.11.01

# 1078 : 짝수 합 구하기

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int sum = 0;
        for(int i=1; i<=num; i++) {
            if(i%2==0) {
                sum += i;
            }
        }
        System.out.println(sum);
        sc.close();
    }
}

 

# 1079 : 원하는 문자가 입력될 때까지 반복 출력

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            char ch = sc.next().charAt(0);
            if(ch=='q') {
                System.out.println(ch); // 'q'까지 출력
                break;
            }
            System.out.println(ch);
        }
        sc.close();
    }
}

 

# 1080 : 언제가지 더해야 할까?

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int hap = sc.nextInt();
        int sum = 0;
        int i = 1;
        while(true) {
            sum += i;
            if (sum>=hap) {
                System.out.println(i);
                break;
            }
            i++;
        }
        sc.close();
    }
}

 

# 1081 : 주사위를 2개 던지면?

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        for(int i=1; i<=n; i++) {
            for(int j=1; j<=m; j++) {
                System.out.println(i+ " "+j);
            }
        }
        sc.close();
    }
}

 

# 1082 : 16진수 구구단?

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(16);
        for(int i=1; i<16; i++) {
            System.out.printf("%X*%X=%X\n", n, i, n*i);
        }
        sc.close();
    }
}

// int n = sc.nextInt(16) : 16진수로 입력 받기

// %x : 16진수 소문자로 출력, %X : 16진수 대문자로 출력

 

# 1083 : 3 6 9 게임의 왕이 되자!

import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i=1; i<=n; i++) {
            if(i%3==0) {
                System.out.print("X ");
            }
            else {
                System.out.print(i+" ");
            }
        }
        sc.close();
    }
}

 

# 1084 : 빛 섞어 색 만들기 (시간초과)

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();
        int count = 0;
        for(int i=0; i<r; i++) {
            for(int j=0; j<g; j++) {
                for(int k=0; k<b; k++) {
                    System.out.println(i+" "+j+" "+k);
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}

// Scanner는 공란과 줄바꿈을 모두 입력값의 경계로 인식하기 때문에 좀 더 쉽게 데이터를 입력 받을 수 있지만, 데이터를 입력 받을 경우 즉시 사용자에게 전송하기에 이 부분에서 많은 시간이 소요된다.

또한, 내부에서 입력 데이터를 처리할 때 정규식을 많이 사용하기 때문에 상당한 시간이 소요된다.

 

★ 시간 초과 해결 방법 → BufferedReader

 

// BufferedReader는 큰 버퍼 사이즈를 가지고 있고, 일정한 크기의 데이터를 한번에 읽어 버퍼에 보관한 후, 사용자의 요청이 있을 때 버퍼에서 데이터를 읽어오는 방식이다. 속도가 빠르고, 시간 부하가 적다.

그럼에도 Scanner가 있는 이유는, BufferedReader는 모든 입력 데이터를 String으로 인식해서 형변환을 해줘야 하는 불편함이 있기 때문이다.

 

# 1084 : 빛 섞어 색 만들기

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        String[] s = br.readLine().split(" ");
        
        int count = 0;
        for(int i=0; i<Integer.valueOf(s[0]); i++) {
            for(int j=0; j<Integer.valueOf(s[1]); j++) {
                for(int k=0; k<Integer.valueOf(s[2]); k++) {
                    bw.write(i+" "+j+" "+k+"\n");
                    count++;
                }
            }
        }
        bw.write(String.valueOf(count));
        bw.flush();
    }
}

 

# 1085 : 소리 파일 저장 용량 계산

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double h = sc.nextDouble();
        double b = sc.nextDouble();
        double c = sc.nextDouble();
        double s = sc.nextDouble();
        
        double result = (h*b*c*s) / 8 / 1024 / 1024;
        System.out.printf("%.1f MB", result);
        sc.close();
    }
}

 

# 1086 : 그림 파일 저장 용량 계산

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double w = sc.nextDouble();
        double h = sc.nextDouble();
        double b = sc.nextDouble();
        
        double result = (w*h*b) / 8 / 1024 / 1024;
        System.out.printf("%.2f MB", result);
        sc.close();
    }
}

 

# 1087 : 여기까지! 이제 그만~

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        for(int i=1; ; i++) {
            sum += i;
            if (sum>=n) {
                 System.out.println(sum);
                 break;
            }
        }
        sc.close();
    }
}

 

# 1088 : 3의 배수는 통과?

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i=1; i<=n; i++) {
            if(i%3==0) {
                continue;
            }
            System.out.print(i+" ");
        }
        sc.close();
    }
}

 

https://codeup.kr/index.php

 

CodeUp

☆ 파이썬 다운로드 : 파이썬3 ☆ 무료 C언어 IDE : Code::blocks       DEV C++ ☆ 추천 온라인 IDE : C   C++11   Python3   Java ☆ 채점 가능 언어 : C, C++, JAVA, Python 3.5 ★ C++로 제출시 void main()을 사용하면

codeup.kr

'CodeUp > Java' 카테고리의 다른 글

[CodeUp] 1089-1097 (Java)  (0) 2022.11.06
[CodeUp] 1071-1077 (Java)  (0) 2022.11.04
[CodeUp] 1065-1070 (Java)  (0) 2022.11.03
[CodeUp] 1063-1064 (Java)  (0) 2022.11.02
[CodeUp] 1059-1062 (Java)  (0) 2022.11.01

# 1071 : 0 입력될 때까지 무한 출력

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int num = sc.nextInt();
            if(num!=0) {
                System.out.println(num);
            }
            else {
                break;
            }
        }
        sc.close();
    }
}

 

# 1072 : 정수 입력 받아 계속 출력

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n]; // 배열 선언, 크기 할당
        for(int i=0; i<n; i++) {
            arr[i] = sc.nextInt();
            System.out.println(arr[i]);
        }
        sc.close();
    }
}

 

# 1073 : 0 입력될 때까지 무한 출력

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int num = sc.nextInt();
            if (num==0) {
                break;
            }
            System.out.println(num);
        }
        sc.close();
    }
}

 

# 1074 : 정수 1개 입력 받아 카운트다운 출력

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        for(int i=num; i>0; i--) {
            System.out.println(i);
        }
        sc.close();
    }
}

 

# 1075 : 정수 1개 입력 받아 카운트다운 출력하기

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        while (num>0) {
            num--;
            System.out.println(num);
        }
        sc.close();
    }
}

 

# 1076 : 문자 1개 입력 받아 알파벳으로 출력

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char ch = sc.next().charAt(0);
        int num = (int)ch;
        for(int i=97; i<=num; i++) {
            System.out.println((char)i);
        }
        sc.close();
    }
}

// 아스키코드 : A = 65, a = 97

 

# 1077 : 정수 1개 입력 받아 그 수까지 출력

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        for(int i=0; i<=num; i++) {
            System.out.println(i);
        }
        sc.close();
    }
}

 

https://codeup.kr/index.php

 

CodeUp

☆ 파이썬 다운로드 : 파이썬3 ☆ 무료 C언어 IDE : Code::blocks       DEV C++ ☆ 추천 온라인 IDE : C   C++11   Python3   Java ☆ 채점 가능 언어 : C, C++, JAVA, Python 3.5 ★ C++로 제출시 void main()을 사용하면

codeup.kr

'CodeUp > Java' 카테고리의 다른 글

[CodeUp] 1089-1097 (Java)  (0) 2022.11.06
[CodeUp] 1078-1088 (Java)  (0) 2022.11.05
[CodeUp] 1065-1070 (Java)  (0) 2022.11.03
[CodeUp] 1063-1064 (Java)  (0) 2022.11.02
[CodeUp] 1059-1062 (Java)  (0) 2022.11.01

# 1065 : 정수 3개 입력 받아 짝수만 출력

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a%2==0) {
            System.out.println(a);
        }
        if (b%2==0) {
            System.out.println(b);
        }
        if (c%2==0) {
            System.out.println(c);
        }
        sc.close();
    }
}

 

# 1066 : 정수 3개 입력 받아 짝/홀 출력

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a%2==0) {
            System.out.println("even");
        }
        else {
            System.out.println("odd");
        }
       if (b%2==0) {
            System.out.println("even");
        }
        else {
            System.out.println("odd");
        }
        if (c%2==0) {
            System.out.println("even");
        }
        else {
            System.out.println("odd");
        }
        sc.close();
    }
}

 

# 1067 : 정수 1개 입력 받아 분석

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        if (num<0) {
            System.out.println("minus");
        }
        else {
            System.out.println("plus");
        }
        if (num%2==0) {
            System.out.println("even");
        }
        else {
            System.out.println("odd");
        }
        sc.close();
    }
}

 

# 1068 : 정수 1개 입력 받아 평가 출력

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int score = sc.nextInt();
        if (score >= 90) {
            System.out.println("A");
        }
        else if (score >= 70) {
            System.out.println("B");
        }
        else if (score >= 40) {
            System.out.println("C");
        }
        else {
            System.out.println("D");
        }
        sc.close();
    }
}

 

# 1069 : 평가 입력 받아 다르게 출력

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char ch = sc.next().charAt(0);
        switch(ch) {
            case 'A' :
                System.out.println("best!!!");
                break;
            case 'B' :
                System.out.println("good!!");
                break;
            case 'C' :
                System.out.println("run!");
                break;
            case 'D' :
                System.out.println("slowly~");
                break;
            default:
                System.out.println("what?");
        }
        sc.close();
    }
}

 

# 1070 : 월 입력 받아 계절 출력

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int month = sc.nextInt();
        sc.close();
        switch(month) {
            case 12: case 1: case 2:
                System.out.println("winter");
                break;
            case 3: case 4: case 5:
                System.out.println("spring");
                break;
            case 6: case 7: case 8:
                System.out.println("summer");
                break;
            case 9: case 10: case 11:
                System.out.println("fall");
                break;
        }
    }
}

 

https://codeup.kr/index.php

 

CodeUp

☆ 파이썬 다운로드 : 파이썬3 ☆ 무료 C언어 IDE : Code::blocks       DEV C++ ☆ 추천 온라인 IDE : C   C++11   Python3   Java ☆ 채점 가능 언어 : C, C++, JAVA, Python 3.5 ★ C++로 제출시 void main()을 사용하면

codeup.kr

'CodeUp > Java' 카테고리의 다른 글

[CodeUp] 1078-1088 (Java)  (0) 2022.11.05
[CodeUp] 1071-1077 (Java)  (0) 2022.11.04
[CodeUp] 1063-1064 (Java)  (0) 2022.11.02
[CodeUp] 1059-1062 (Java)  (0) 2022.11.01
[CodeUp] 1053-1058 (Java)  (0) 2022.10.31

# 1063 : 두 정수 입력 받아 큰 수 출력

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println((a>b) ? a : b);
        sc.close();
    }
}

 

# 1064 : 정수 3개 입력 받아 가장 작은 수 출력

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int min = (a>b) ? b : a;
        min = (min>c) ? c : min;
        System.out.println(min);
        sc.close();
    }
}

 

https://codeup.kr/index.php

 

CodeUp

☆ 파이썬 다운로드 : 파이썬3 ☆ 무료 C언어 IDE : Code::blocks       DEV C++ ☆ 추천 온라인 IDE : C   C++11   Python3   Java ☆ 채점 가능 언어 : C, C++, JAVA, Python 3.5 ★ C++로 제출시 void main()을 사용하면

codeup.kr

'CodeUp > Java' 카테고리의 다른 글

[CodeUp] 1071-1077 (Java)  (0) 2022.11.04
[CodeUp] 1065-1070 (Java)  (0) 2022.11.03
[CodeUp] 1059-1062 (Java)  (0) 2022.11.01
[CodeUp] 1053-1058 (Java)  (0) 2022.10.31
[CodeUp] 1049-1052 (Java)  (0) 2022.10.30

# 1059 : 비트 단위로 NOT 하여 출력

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        System.out.println(~num);
        sc.close();
    }
}

 

# 1060 : 비트 단위로 AND 하여 출력

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num1 = sc.nextInt();
        int num2 = sc.nextInt();
        System.out.println(num1&num2);
        sc.close();
    }
}

 

# 1061 : 비트 단위로 OR 하여 출력

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num1 = sc.nextInt();
        int num2 = sc.nextInt();
        System.out.println(num1|num2);
        sc.close();
    }
}

 

# 1062 : 비트 단위로 XOR 하여 출력

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num1 = sc.nextInt();
        int num2 = sc.nextInt();
        System.out.println(num1^num2);
        sc.close();
    }
}

 

https://codeup.kr/index.php

 

CodeUp

☆ 파이썬 다운로드 : 파이썬3 ☆ 무료 C언어 IDE : Code::blocks       DEV C++ ☆ 추천 온라인 IDE : C   C++11   Python3   Java ☆ 채점 가능 언어 : C, C++, JAVA, Python 3.5 ★ C++로 제출시 void main()을 사용하면

codeup.kr

'CodeUp > Java' 카테고리의 다른 글

[CodeUp] 1065-1070 (Java)  (0) 2022.11.03
[CodeUp] 1063-1064 (Java)  (0) 2022.11.02
[CodeUp] 1053-1058 (Java)  (0) 2022.10.31
[CodeUp] 1049-1052 (Java)  (0) 2022.10.30
[CodeUp] 1047-1048 (Java)  (0) 2022.10.29

# 1053 : 참 거짓 바꾸기

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        if(a==1) {
            System.out.println("0");
        }
        else {
            System.out.println("1");
        }
        sc.close();
    }
}

 

# 1054 : 둘 다 참일 경우만 참 출력

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a*b==1) {
            System.out.println("1");
        }
        else {
            System.out.println("0");
        }
        sc.close();
    }
}

 

# 1055 : 하나라도 참이면 참 출력

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = a + b;
        if(c==0) {
            System.out.println("0");
        }
        else {
            System.out.println("1");
        }
        sc.close();
    }
}

 

# 1056 : 참/거짓이 서로 다를 때에만 참 출력

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a!=b) {
            System.out.println("1");
        }
        else {
            System.out.println("0");
        }
        sc.close();
    }
}

 

# 1057 : 참/거짓이 서로 같을 때에만 참 출력

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a==b) {
            System.out.println("1");
        }
        else {
            System.out.println("0");
        }
        sc.close();
    }
}

 

# 1058 : 둘 다 거짓일 경우만 참 출력

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = a + b;
        if(c==0) {
            System.out.println("1");
        }
        else {
            System.out.println("0");
        }
        sc.close();
    }
}

 

https://codeup.kr/index.php

 

CodeUp

☆ 파이썬 다운로드 : 파이썬3 ☆ 무료 C언어 IDE : Code::blocks       DEV C++ ☆ 추천 온라인 IDE : C   C++11   Python3   Java ☆ 채점 가능 언어 : C, C++, JAVA, Python 3.5 ★ C++로 제출시 void main()을 사용하면

codeup.kr

'CodeUp > Java' 카테고리의 다른 글

[CodeUp] 1063-1064 (Java)  (0) 2022.11.02
[CodeUp] 1059-1062 (Java)  (0) 2022.11.01
[CodeUp] 1049-1052 (Java)  (0) 2022.10.30
[CodeUp] 1047-1048 (Java)  (0) 2022.10.29
[CodeUp] 1038-1046 (Java)  (0) 2022.10.28

# 1049 : 두 정수 입력 받아 비교

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a>b) {
            System.out.println("1");
        }
        else {
            System.out.println("0");
        }
        sc.close();
    }
}

 

# 1050 : 두 정수 입력 받아 비교

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a==b) {
            System.out.println("1");
        }
        else {
            System.out.println("0");
        }
        sc.close();
    }
}

 

# 1051 : 두 정수 입력 받아 비교

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a<=b) {
            System.out.println("1");
        }
        else {
            System.out.println("0");
        }
        sc.close();
    }
}

 

# 1052 : 두 정수 입력 받아 비교

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a!=b) {
            System.out.println("1");
        }
        else {
            System.out.println("0");
        }
        sc.close();
    }
}

 

https://codeup.kr/index.php

 

CodeUp

☆ 파이썬 다운로드 : 파이썬3 ☆ 무료 C언어 IDE : Code::blocks       DEV C++ ☆ 추천 온라인 IDE : C   C++11   Python3   Java ☆ 채점 가능 언어 : C, C++, JAVA, Python 3.5 ★ C++로 제출시 void main()을 사용하면

codeup.kr

 

'CodeUp > Java' 카테고리의 다른 글

[CodeUp] 1059-1062 (Java)  (0) 2022.11.01
[CodeUp] 1053-1058 (Java)  (0) 2022.10.31
[CodeUp] 1047-1048 (Java)  (0) 2022.10.29
[CodeUp] 1038-1046 (Java)  (0) 2022.10.28
[CodeUp] 1031-1037 (Java)  (0) 2022.10.27

+ Recent posts