반응형
https://www.acmicpc.net/problem/9093
9093번: 단어 뒤집기
첫째 줄에 테스트 케이스의 개수 T가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있으며, 문장이 하나 주어진다. 단어의 길이는 최대 20, 문장의 길이는 최대 1000이다. 단어와 단어 사이에는
www.acmicpc.net

import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = Integer.parseInt(sc.nextLine());
for(int i = 0; i < a; i++) {
String str = sc.nextLine();
String[] arr = str.split(" ");
for(int j = 0; j < arr.length; j++) {
System.out.print(new StringBuffer(arr[j]).reverse()
.toString() + " ");
}
System.out.println();
}
}
}
반응형
'Algorithm > [알고리즘]BACKJOON - Java&Kotlin' 카테고리의 다른 글
백준 Java 1026번 : 보물 (0) | 2022.02.07 |
---|---|
백준 Java 9012번 : 괄호 (0) | 2022.02.07 |
백준 Java 10707번 : 수도요금 (0) | 2022.02.06 |
백준 Java 2455번 : 지능형 기차 (0) | 2022.02.06 |
백준 Java 4673번 : 셀프 넘버 (0) | 2022.02.06 |
반응형
https://www.acmicpc.net/problem/9093
9093번: 단어 뒤집기
첫째 줄에 테스트 케이스의 개수 T가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있으며, 문장이 하나 주어진다. 단어의 길이는 최대 20, 문장의 길이는 최대 1000이다. 단어와 단어 사이에는
www.acmicpc.net

import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = Integer.parseInt(sc.nextLine());
for(int i = 0; i < a; i++) {
String str = sc.nextLine();
String[] arr = str.split(" ");
for(int j = 0; j < arr.length; j++) {
System.out.print(new StringBuffer(arr[j]).reverse()
.toString() + " ");
}
System.out.println();
}
}
}
반응형
'Algorithm > [알고리즘]BACKJOON - Java&Kotlin' 카테고리의 다른 글
백준 Java 1026번 : 보물 (0) | 2022.02.07 |
---|---|
백준 Java 9012번 : 괄호 (0) | 2022.02.07 |
백준 Java 10707번 : 수도요금 (0) | 2022.02.06 |
백준 Java 2455번 : 지능형 기차 (0) | 2022.02.06 |
백준 Java 4673번 : 셀프 넘버 (0) | 2022.02.06 |