https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AYLnMQT6vPADFATf
์์๊ฐ 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]);
}
}
}
'๐ ์ฝ๋ฉํ ์คํธ > ๋ฐฑ์ค & ํ๋ก๊ทธ๋๋จธ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค][JAVA]Level 0 : ์ต๋น๊ฐ ๊ตฌํ๊ธฐ (0) | 2022.11.02 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค][JAVA]Level 1 : ์ผ์ด์ฌ (0) | 2022.11.02 |
[ํ๋ก๊ทธ๋๋จธ์ค][JAVA]Level 1 : ๋ชจ์๊ณ ์ฌ (์์ ํ์) (0) | 2022.11.01 |
[ํ๋ก๊ทธ๋๋จธ์ค][JAVA]Level 0 : ์์ธ์๋ถํด ( *์์ธ์๋ถํด ) (0) | 2022.11.01 |
[ํ๋ก๊ทธ๋๋จธ์ค][JAVA]Level 0 : ์๋ผ์ ๋ฐฐ์ด๋ก ์ ์ฅํ๊ธฐ (0) | 2022.10.31 |