Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.IOException;
- import java.util.Scanner;
- public class ExpandCipher {
- public static void main(String[] args) throws IOException {
- Scanner scan = new Scanner(System.in);
- System.out.println("Input the encrypted string");
- String sInput = scan.nextLine();
- scan.close(); // Free scanner since we no longer need to get data
- String s[] = sInput.split("(?<=\\D)(?=\\d)|(?<=\\d)(?=\\D)");
- char cI = 0;
- for(String s1:s)
- {
- if(!Character.isDigit(s1.charAt(0)))
- cI = s1.charAt(0);
- else
- {
- int repeat = Integer.parseInt(s1);
- for(int i = 0; i < repeat; i++)
- System.out.print(cI);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment