//Google Code Jam Qualification Round Africa 2010 B Reverse Words
import java.io.*;
import java.io.ObjectInputStream.GetField;
import java.math.*;
import java.text.*;
import java.util.*;
//Google Code Jam
public class GoogleCode1 {
private static MyScanner in;
private static PrintStream out;
private static void solve() throws IOException
{
int C = in.nextInt();
in.nextLine();
for (int i = 0; i < C; i++) {
out.print("Case #" + (i + 1) + ": ");
solveCase();
}
}
private static void solveCase() throws IOException {
// TODO Auto-generated method stub
String s = in.nextLine();
String[] ss = s.split(" ");
for (int i = ss.length - 1; i > 0; i--) {
out.print(ss[i] + " ");
}
out.println(ss[0]);
}
public static void main(String[] args) throws IOException {
// helpers for input/output
boolean usingFileForIO = true;
if (usingFileForIO) {
// using input.txt and output.txt as I/O
in = new MyScanner("E:\\zin.txt");
out = new PrintStream("E:\\zout.txt");
}
else {
in = new MyScanner();
out = System.out;
}
solve();
}
// =====================================
static class MyScanner {
Scanner inp = null;
public MyScanner() throws IOException
{
inp = new Scanner(System.in);
}
public MyScanner(String inputFile) throws IOException {
inp = new Scanner(new FileInputStream(inputFile));
}
public int nextInt() throws IOException {
return inp.nextInt();
}
public long nextLong() throws IOException {
return inp.nextLong();
}
public double nextDouble() throws IOException {
return inp.nextDouble();
}
public String nextString() throws IOException {
return inp.next();
}
public String nextLine() throws IOException {
return inp.nextLine();
}
}
}
No comments:
Post a Comment