반응형
문제 이해
아이디어
코드
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
for (int i = 1; i <= N; ++i) {
String tmp = String.valueOf(i);
int idx = 0, cnt = 0;
while (idx < tmp.length()) {
switch (tmp.charAt(idx++)) {
case '3':
case '6':
case '9':
cnt++;
break;
}
}
if (cnt > 0) {
for (int k = 0; k < cnt; ++k)
System.out.print("-");
System.out.print(" ");
} else System.out.print(i+" ");
}
}
}
집사는개발자가되고파
choppadontbiteme.tistory.com
반응형
'Algorithm > SWEA' 카테고리의 다른 글
[SWEA] 1873. 상호의 배틀 필드 D3 JAVA (0) | 2021.03.30 |
---|---|
[SWEA] 1859. 백만장자 프로젝트 D2 JAVA (0) | 2021.03.26 |
[SWEA] 2007. 패턴 마디의 길이 D2 JAVA (0) | 2021.03.26 |
[SWEA] 2005. 파스칼의 삼각형 D2 JAVA (0) | 2021.03.26 |
[SWEA] 1989.초심자의 회문 검사 D2 JAVA (0) | 2021.03.26 |