daily pastebin goal
30%
SHARE
TWEET

String Expolosion

a guest Mar 24th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class StringExplosion {
  4.     public static void main(String[] args) {
  5.         Scanner scanner=new Scanner(System.in);
  6.  
  7.         String text=scanner.nextLine();
  8. String result="";
  9.         int strength=0;
  10.  
  11.         for (int i=0;i<text.length() ;i++) {
  12.  
  13.             result+=text.charAt(i);
  14.  
  15.             if(text.charAt(i)=='>') {
  16.                 strength +=
  17.                         Integer.parseInt(String.valueOf(text.charAt(i+1)));
  18.             }
  19.                 while (strength>0){
  20.                     strength--;
  21.                     i++;
  22.  
  23.                     if (i+1>=text.length()||text.charAt(i+1) == '>') {
  24.  
  25.                         break;
  26.                     }
  27.  
  28.                 }
  29.                 ;
  30.  
  31.             }
  32.         System.out.println(result);
  33.         }
  34.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top