728x90
https://swexpertacademy.com/main/solvingProblem/solvingProblem.do
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
import java.util.Scanner;
class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
sc.nextLine();
for (int tc = 1; tc <= t; tc++) {
String word[] = sc.nextLine().split(" ");
System.out.print("#" + tc + " ");
for (int i = 0; i < word.length; i++) {
System.out.print((word[i].charAt(0)+"").toUpperCase());
}
System.out.println();
}
}
}
+" " 을 사용하여 string으로 만들고 toUpperCase() 함수 사용
import java.util.Scanner;
class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
sc.nextLine();
for (int tc = 1; tc <= t; tc++) {
String word[] = sc.nextLine().split(" ");
System.out.print("#" + tc + " ");
for (int i = 0; i < word.length; i++) {
System.out.print((char)(word[i].charAt(0)-32));
//-('a'-'A')
//+('A'-'a')
}
System.out.println();
}
}
}
대문자가 소문자보다 작으니 대문자와 소문자의 차이만큼 뺀 다음 char형으로 변환하기
728x90
'SW Expert Academy > SWEA D3' 카테고리의 다른 글
| [SW Expert Academy] [S/W 문제해결 기본] 10일차 - 비밀번호 (D3) (0) | 2024.09.02 |
|---|---|
| [SW Expert Academy] 미니멀리즘 시계 (D3) (0) | 2024.09.02 |
| [SW Expert Academy] 문자열의 거울상 (D3) (0) | 2024.09.02 |
| [SW Expert Academy] 홀수일까 짝수일까 (D3) (0) | 2024.09.02 |
| [S/W 문제해결 기본] 8일차 - 암호문3 (D3) (4) | 2024.09.02 |