본문 바로가기

프로그래밍언어/알고리즘

백준 9086 문자열_JAVA

https://www.acmicpc.net/problem/9086

 

9086번: 문자열

입력의 첫 줄에는 테스트 케이스의 개수 T(1 ≤ T ≤ 10)가 주어진다. 각 테스트 케이스는 한 줄에 하나의 문자열이 주어진다. 문자열은 알파벳 A~Z 대문자로 이루어지며 알파벳 사이에 공백은 없으

www.acmicpc.net

 

 

문자열이 한개일때 조심!

 


import java.util.Scanner;

public class Main{
   public static void main(String[] args)  {
	   
	   Scanner sc = new Scanner(System.in);
	   
	   int T = sc.nextInt();
	   
	  

	   for(int i = 0 ; i < T ; i++) {
		   String text = sc.next();
		   
		   System.out.print(text.charAt(0));
		   System.out.println(text.charAt(text.length() -1));
	   }
		
	   
	
	   sc.close();
    }
    
}