Guest User

Untitled

a guest
Jan 11th, 2020
629
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Upr {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6.  
  7. String input = scan.nextLine();
  8.  
  9. String[] texts = input.split(">");
  10. int strength = 0;
  11. int strengthLeft = 0;
  12.  
  13. for (int i = 0; i < texts.length; i++) {
  14. if (Character.isDigit(texts[i].charAt(0))) {
  15. strength = Character.getNumericValue(texts[i].charAt(0)) + strengthLeft;
  16.  
  17. if (texts[i].length() >= strength) {
  18. texts[i] = texts[i].substring(strength);
  19. } else {
  20. strengthLeft = strength - texts[i].length();
  21. texts[i] = "";
  22. }
  23. }
  24.  
  25. if (i == texts.length - 1) {
  26. System.out.print(texts[i]);
  27. } else {
  28. System.out.print(texts[i] + ">");
  29. }
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment