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