Created
October 4, 2016 15:48
-
-
Save bahriddin/4d15b86004af33c2bbc1445b5044e2da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.company; | |
import java.io.BufferedReader; | |
import java.io.FileReader; | |
import java.io.IOException; | |
import java.io.PrintWriter; | |
public class Main { | |
public static void main(String[] args) throws IOException { | |
// write your code here | |
String pt = "A-small-practice"; | |
BufferedReader in = new BufferedReader(new FileReader(pt + ".in")); | |
PrintWriter out = new PrintWriter(pt + ".out"); | |
int t = Integer.parseInt(in.readLine()); | |
String w, nw; | |
for (int i = 1; i <= t; i++) { | |
w = in.readLine(); | |
nw = ""; | |
for (int j = 0; j < w.length(); j++) { | |
if (j == 0 || w.charAt(j) >= nw.charAt(0)) | |
nw = w.charAt(j) + nw; | |
else | |
nw = nw + w.charAt(j); | |
} | |
out.println("Case #" + i + ": " + nw); | |
} | |
out.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment