Algorithm/CodeUp
[CodeUp_Java] Q1735 : hello
Plitche
2022. 12. 14. 09:48
반응형

안녕하세요! Plitche(플리체)입니다.
이번 포스팅의 주제는 Q1735 : hello (자바, JAVA)입니다.
Intro
Question
문제 설명

입력
입력으로 정수 n이 입력된다.(1<=n<=100)
출력
hello를 n줄에 걸쳐서 출력한다.
예시
- 입력 : 5
- 출력 :
hello
hello
hello
hello
hello
Solution (풀이)
- 풀이 : 메모리 11180, 시간 : 65
public class Answer1 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int count = Integer.parseInt(br.readLine()); // 반복할 횟수
for (int i=0; i<count; i++) {
sb.append("hello").append("\n"); // 반복할 때마다 hello 출력 후 줄바꿈
}
System.out.println(sb);
}
}
Ranking(순위)

반응형