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