Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class testing {
- public static void main(String[] args) {
- String unsorted = "cab";
- char min = unsorted.charAt(0), max = min, middle = min, at;
- for (int i = 0; i < unsorted.length(); i++) {
- at = unsorted.charAt(i);
- if (at > max) {
- middle = max;
- max = at;
- }
- else if (at < min) {
- middle = min;
- min = at;
- }
- else middle = at;
- }
- System.out.println(""+min+middle+max);
- }
- }
Add Comment
Please, Sign In to add comment