Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 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. PriorityQueue<Character> cola = new PriorityQueue<Character>();
  17.  
  18. for (int j = 0; j < a.length; j++) {
  19.  
  20. String oracion = a[j];
  21.  
  22. for (int i = 0; i < oracion.length(); i++){
  23. char c = oracion.charAt(i);
  24.  
  25. if (Character.isLetter(c)) {
  26. cola.add(c);
  27. }
  28.  
  29. else if (c == '*') {
  30.  
  31. System.out.print(cola.poll());
  32.  
  33. }
  34.  
  35. else{
  36. System.out.print(' ');
  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