-
문제 20번 - 369 게임알고리즘/알고리즘 기초 100제 2020. 9. 21. 11:07
문제 : 369 게임 법칙에 맞게 짝을 출력하세요 ( 100번까지)
예) 1 2 짝 4 5 짝 7 8 짝
import java.util.*; public class Youtube20 { /* 369 GAME ~100 */ public static void main(String[] args){ for(int i=1; i<=100; i++) { String[] arr = String.valueOf(i).split(""); StringBuilder tempStr = new StringBuilder(); for(String checkStr : arr) { if(checkStr.contains("3") || checkStr.contains("6") || checkStr.contains("9")) { tempStr.append("ZZAK"); } } if(tempStr.toString().isEmpty()){ System.out.print(i + " "); }else{ System.out.print(tempStr.toString() + " "); } } } }
'알고리즘 > 알고리즘 기초 100제' 카테고리의 다른 글
문제 22번 - 팬린드롬 (0) 2020.09.21 문제 21번 - 중복된 수 제거 후 출력 (0) 2020.09.21 문제 19 - 거듭제곱 출력 (0) 2020.08.20 문제18 - 별출력 (0) 2020.08.20 문제 17 - 별출력2 (0) 2020.08.09