안녕하세요. 맹꽁이입니다. 이번엔 백준 사이트 단계별 문제풀이의 조건문 풀어볼게요.
입출력 어려운 분들은 아래 1# 입출력과 사칙연산 참고하시길!
https://rb-cloud.tistory.com/4
#2557 - 두 수 비교하기

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.StringTokenizer;
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.print(">");
else if(a<b) System.out.print("<");
else System.out.print("==");
}
}
#9498 - 시험 성적

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
public class Main{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int a = Integer.parseInt(br.readLine());
String score = "F";
if(a>=90) score = "A";
else if(a>=80) score = "B";
else if(a>=70) score = "C";
else if(a>=60) score = "D";
System.out.print(score);
}
}
#2753 - 윤년

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
public class Main{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int a = Integer.parseInt(br.readLine());
if((a%4==0 && a%100!=0) || a%400==0) System.out.print("1");
else System.out.print("0");
}
}
#14681 - 사분면 고르기


이번에는 한 줄에 두 정수가 있는게 아니기 때문에 tokenizer 없이 readLine()할 것이다.
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
public class Main{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int a = Integer.parseInt(br.readLine());
int b = Integer.parseInt(br.readLine());
if(a>0) {
if(b>0) System.out.print("1");
else System.out.print("4");
}
else {
if(b>0) System.out.print("2");
else System.out.print("3");
}
}
}
#2884 - 알람 시계


import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.StringTokenizer;
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(b>=45) {
System.out.print(a+" "+(b-45));
}
else {
if(a==0) System.out.print("23 "+(60+b-45));
else System.out.print((a-1)+" "+(60+b-45));
}
}
}
#2525 - 오븐 시계


주의할 점은 B+C가 120분을 넘어갈 수 있다는 것! 나처럼 틀릴 수 있다!
그래서 B+C를 60으로 나눈 몫을 plus 변수로 두고, 변화된 시, 분에 적용했다.

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.StringTokenizer;
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());
int c = Integer.parseInt(br.readLine());
if(b+c<60) {
System.out.print(a+" "+(b+c));
}
else {
int plus = (b+c)/60;
if(a+plus>=24) System.out.print((a+plus-24)+" "+(b+c-60*plus));
else System.out.print((a+plus)+" "+(b+c-60*plus));
}
}
}
#2480 - 주사위 세개


import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.StringTokenizer;
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());
int c = Integer.parseInt(st.nextToken());
int prize;
if(a==b && b==c) prize = 10000 + a*1000;
else if(a==b || a==c) prize = 1000 + a*100;
else if(b==c) prize = 1000 + b*100;
else{
int max = a;
if(b>max) max = b;
if(c>max) max = c;
prize = max*100;
}
System.out.print(prize);
}
}