문제
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
입력
The first line of the input contains an integer T, the number of test sets (1 ≤ T ≤ 90).
The first line of each test case contains N (10 ≤ N ≤ 99).
3 29 72 91 |
출력
For each test case, print “#T”(test case number), and if 9 is contained in the decimal notation of N, "Yes", if not, "No".
#1 Yes #2 No #3 Yes |
코드
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import java.util.Scanner; class Solution { public static void main(String args[]) throws Exception { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i=0; i<t; i++){ int num = sc.nextInt(); boolean check = checkNine(num); System.out.printf("#%d %s\n",i+1,(check)?"Yes":"No"); } } private static boolean checkNine(int num){ while(num>0){ if(num%10==9) return true; num/=10; } return false; } } | cs |
'SW expert Academy > D2' 카테고리의 다른 글
[SW Expert Academy] 2369번 Theater (1) | 2023.05.17 |
---|---|
[SW Expert Academy] 1204번 최빈수 구하기 (0) | 2023.05.17 |
[SW Expert Academy] 1284번 수도 요금 경쟁 (0) | 2023.05.17 |
[SW Expert Academy] 1288번 새로운 불면증 치료법 (0) | 2023.05.17 |
[SW Expert Academy] 1928번 Base64 Decoder 변형 문제 (0) | 2023.05.17 |