Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. import java.util.Comparator;
  2. import java.util.PriorityQueue;
  3. import java.util.Stack;
  4. import java.util.Scanner;
  5.  
  6.  
  7. public class acertijo{
  8.  
  9. public static void main(String[] args) {
  10.  
  11. System.out.println("Inserte el codigo");
  12.  
  13. Scanner input = new Scanner(System.in);
  14. String[] a = input.nextLine().split(" ");
  15.  
  16. for (int j = 0; j < a.length; j++) {
  17.  
  18. String oracion = a[j];
  19. PriorityQueue<Character> cola = new PriorityQueue<Character>();
  20.  
  21. for (int i = 0; i < oracion.length(); i++){
  22. char c = oracion.charAt(i);
  23.  
  24. if (Character.isLetter(c)) {
  25. cola.add(c);
  26. }
  27.  
  28. else if (c == '*') {
  29.  
  30. System.out.print(cola.poll());
  31.  
  32. }
  33.  
  34. else{
  35. System.out.print(' ');
  36. cola.clear();
  37. }
  38.  
  39.  
  40. }
  41.  
  42. System.out.print(' ');
  43.  
  44. }
  45.  
  46. }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement