📝문제

📝알고리즘
//전체 케이스 개수인 N을 입력받음
//각 케이스마다
//단어들을 입력받아 스페이스를 기준으로 나눠서 words에 저장함
//입력된 단어 순서대로 스택에 넣음
//스택이 빌 때까지 pop함
📝구현
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner scanner=new Scanner(System.in);
Stack<String> stack=new Stack<>();
int N=scanner.nextInt();
scanner.nextLine();
for(int i=0;i<N;i++){
String text=scanner.nextLine();
String[] words=text.split(" ");
for(String word: words){
stack.push(word);
}
System.out.print("Case #"+(i+1)+": ");
while(!stack.isEmpty()){
System.out.print(stack.pop()+" ");
}
System.out.println();
}
}
}