Deep_Dev

https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=3&contestProbId=AW2y6n3qPXQDFATy&categoryId=AW2y6n3qPXQDFATy&categoryType=CODE&problemTitle=&orderBy=PASS_RATE&selectCodeLang=ALL&select-1=3&pageSize=10&pageIndex=4 

 

SW Expert Academy

SW ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์—ญ๋Ÿ‰ ๊ฐ•ํ™”์— ๋„์›€์ด ๋˜๋Š” ๋‹ค์–‘ํ•œ ํ•™์Šต ์ปจํ…์ธ ๋ฅผ ํ™•์ธํ•˜์„ธ์š”!

swexpertacademy.com

 

 


split์„ ์ด์šฉํ•ด์„œ ๊ณต๋ฐฑ๊ธฐ์ค€์œผ๋กœ ๋‚˜๋ˆ ์„œ ๊ฐ ๋ฐฐ์—ด์˜ ์ฒซ ๋ฌธ์ž๋ฅผ ๋Œ€๋ฌธ์žํ™”ํ•˜์—ฌ ๋‹ด์œผ๋ฉด ๋๋Š”๋ฐ,

์ด์ƒํ•˜๊ฒŒ int t๋ฅผ ์ž…๋ ฅ๋ฐ›์ž๋งˆ์ž string index out of range ์˜ค๋ฅ˜๊ฐ€ ๋‚ฌ๋‹ค.

 

์ด์œ ๊ฐ€ nextInt()๋ฅผ ๋ฐ›๊ณ , ๊ฐœํ–‰๋ฌธ์ž ์ฒ˜๋ฆฌ๋ฅผ ์•ˆํ–ˆ๋Š”๋ฐ ๋ฐ”๋กœ stringํ˜•์„ ์ž…๋ ฅ๋ฐ›์œผ๋ ค๊ณ ํ•˜๋‹ˆ ์ƒ๊ธด ์—๋Ÿฌ๋‹ค.

๊ทธ๋ž˜์„œ nextInt()์ดํ›„ kb.nextLine()์œผ๋กœ ๊ฐœํ–‰๋ฌธ์ž ์ฒ˜๋ฆฌ๋ฅผ ํ•œ๋’ค์— ์ž…๋ ฅ๋ฐ›๊ฒŒ ํ•˜์˜€๋‹ค.

 

 

import java.util.Scanner;
class Solution{
    public static void main(String args[]) throws Exception{
     
        Scanner kb = new Scanner(System.in);
        int t = kb.nextInt();
        kb.nextLine(); // ๊ฐœํ–‰๋ฌธ์ž ์ฒ˜๋ฆฌ
        for (int test_case = 1; test_case <= t; test_case++) {
            String s=kb.nextLine();
            String[] arr=s.split(" ");
            String temp="";
            for(int i=0; i< arr.length; i++){
                temp+=Character.toUpperCase(arr[i].charAt(0));
            }
            System.out.println("#"+test_case+" "+temp);
        }
    }
}