Advertisement
John_IV

Untitled

Nov 18th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. package Programming_Fundamentals.L9_Text_Processing.Text_Processing_Exercises;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class E07StringExplosion {
  6.     public static void main(String[] args) {
  7.         Scanner sc = new Scanner(System.in);
  8.  
  9.         String word = sc.nextLine();
  10.         StringBuilder result = new StringBuilder();
  11.         int skip = 0;
  12.  
  13.         for (int i = 0; i < word.length(); i++) {
  14.             char ch = word.charAt(i);
  15.  
  16.             if (ch == 62) {
  17.                 result.append(ch);
  18.                 skip += Character.getNumericValue(word.charAt(i + 1));
  19.  
  20.             } else if (skip == 0) {
  21.                 result.append(ch);
  22.  
  23.             } else {
  24.                 skip--;
  25.             }
  26.         }
  27.  
  28.         System.out.println(result.toString());
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement