Guest User

Untitled

a guest
Aug 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. public class testing {
  2.  
  3. public static void main(String[] args) {
  4.  
  5. String unsorted = "cab";
  6. char min = unsorted.charAt(0), max = min, middle = min, at;
  7. for (int i = 0; i < unsorted.length(); i++) {
  8. at = unsorted.charAt(i);
  9. if (at > max) {
  10. middle = max;
  11. max = at;
  12. }
  13. else if (at < min) {
  14. middle = min;
  15. min = at;
  16. }
  17. else middle = at;
  18. }
  19. System.out.println(""+min+middle+max);
  20. }
  21. }
Add Comment
Please, Sign In to add comment