SWEA - 8741. 두문자어 :: 매운코딩
728x90
300x250

https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AW2y6n3qPXQDFATy&categoryId=AW2y6n3qPXQDFATy&categoryType=CODE

 

knuth morris pratt 라는 문자가 들어오면 KMP로 약어를 만들어주는 것

 

import java.io.*;
import java.util.*;

public class Solution {

	public static int N;
	public static void main(String[] args) {
        
		Scanner sc = new Scanner(System.in);
		
		N = sc.nextInt();
		sc.nextLine();
		for (int i = 0; i < N; i++) {
			String str = sc.nextLine();
			String ans = "";
			//System.out.println(str);
			String[] sp = str.split(" ");
			
			for (int j = 0; j < sp.length; j++) {
				ans += sp[j].charAt(0);
			}
			
			
			System.out.println("#"+(i+1)+" "+ans.toUpperCase());
		}

	}

}
728x90

+ Recent posts