코딩 테스트/백준
[백준 2024/01/30] 4999번 아!
미뿌감
2024. 1. 31. 00:14
728x90
https://www.acmicpc.net/problem/4999
4999번: 아!
입력은 두 줄로 이루어져 있다. 첫째 줄은 재환이가 가장 길게 낼 수 있는 "aaah"이다. 둘째 줄은 의사가 듣기를 원하는 "aah"이다. 두 문자열은 모두 a와 h로만 이루어져 있다. a의 개수는 0보다 크거
www.acmicpc.net
1. 접근 방법
이번 문제는 첫 번째로 input을 받은 값과 두 번째로 input을 받은 값을 비교한 후
길이 비교에 따라 no 또는 go를 출력하도록 만들었다.
2. 코드
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class b4999 {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String doctor = reader.readLine();
String patient = reader.readLine();
if(doctor.length() < patient.length()){
System.out.println("no");
}
else{
System.out.println("go");
}
}
}
728x90