Deep_Dev

 

https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AYLnMQT6vPADFATf 

 

SW Expert Academy

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

swexpertacademy.com

 

 

 


์ˆœ์„œ๊ฐ€ a๋ถ€ํ„ฐ ์ˆœ์„œ๋Œ€๋กœ ์ผ์น˜ํ•˜๋Š” ์•ŒํŒŒ๋ฒณ์˜ ๊ฐœ์ˆ˜๋กœ ์ง€์ •ํ•ด์คฌ๊ธฐ๋•Œ๋ฌธ์—

์–ด๋ ต์ง€์•Š์•˜์Œ.

 

 

 

import java.util.Scanner;
import java.io.FileInputStream;

class Solution{
    public static void main(String args[]) throws Exception{
     Scanner kb=new Scanner(System.in);
        int n=kb.nextInt();
        String[] arr=new String[n];
        for(int i=0; i<arr.length; i++){
            arr[i]=kb.next();
        }
 
        int[] answer=new int[n];
        int cnt=0;
        String s="abcdefghijklmnopqrstuvwxyz";
        for(int i=0; i<n; i++){
            cnt=0;
            for(int j=0; j<arr[i].length(); j++){
                if(arr[i].charAt(j)==s.charAt(j))
                    cnt++;
                else
                    break;
            }
            answer[i]=cnt;
        }
        for(int i=0; i<n; i++){
            System.out.println("#"+(i+1)+" "+answer[i]);
        }
    }
}