Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class StringExplosion_07 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String input = scanner.nextLine();
- StringBuilder result = new StringBuilder();
- for (int i = 0; i < input.length(); i++) {
- char symbol = input.charAt(i);
- if (symbol == '>') {
- result.append(symbol);
- i++;
- int explosion = input.charAt(i) - '0';
- explosion--;
- while (explosion > 0 && i < input.length() - 1) {
- i++;
- symbol = input.charAt(i);
- if (symbol == '>') {
- result.append(symbol);
- i++;
- explosion += input.charAt(i) - '0';
- explosion--;
- continue;
- }
- explosion--;
- }
- } else {
- result.append(symbol);
- }
- }
- System.out.println(result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement