Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Fundamentals.O_Ex_TextProcesing;
- import java.io.Console;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Scanner;
- public class Ex_7_BombExpolosition {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String name = scanner.nextLine();
- List<Character> field = new ArrayList<>();
- for (int i = 0; i < name.length(); i++) {
- field.add(name.charAt(i));
- }
- int bomb = 0;
- for (int i = 0; i < field.size() - 1; i++) {
- char feldI = field.get(i);
- char feldIPlus = field.get(i + 1);
- if (bomb > 0 && feldI != '>') {
- field.remove(i);
- bomb--;
- i--;
- }
- else if (feldI == '>' && feldIPlus != '>' ) {
- if (Character.isDigit(feldIPlus)) {
- String test = "" + feldIPlus;
- int temp = Integer.parseInt(test);
- bomb += temp;
- }
- }
- }
- for (int i = 0; i < field.size() ; i++) {
- System.out.print(field.get(i));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement