fork download
  1. import java.io.IOException;
  2. import java.io.PrintWriter;
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7. public static void main(String[] args) {
  8.  
  9. String line;
  10. Scanner scan = new Scanner(System.in);
  11.  
  12. while(scan.hasNextLine()) {
  13. line = scan.nextLine();
  14. createMaze(line);
  15. }
  16. }
  17.  
  18. public static void createMaze(String code) {
  19.  
  20. int tempNumberOfBlocks = 0;
  21. int numberOfBlocks = 0;
  22. String result = "";
  23.  
  24. for(int i = 0; i < code.length();i++) {
  25. if(Character.isDigit(code.charAt(i))) {
  26. numberOfBlocks = tempNumberOfBlocks + (int)(code.charAt(i)-48);
  27. tempNumberOfBlocks = (int)(code.charAt(i)-48);
  28. //System.out.println(numberOfBlocks);
  29. } else if (Character.isLetter(code.charAt(i))) {
  30. tempNumberOfBlocks = 0;
  31.  
  32. if((code.charAt(i))=='b') {
  33. for(int k = 0;k < numberOfBlocks;k++) {
  34. result += " ";
  35. }
  36.  
  37. } else {
  38. for(int k = 0;k < numberOfBlocks;k++) {
  39. result += code.charAt(i);
  40. }
  41. }
  42.  
  43. } else if (code.charAt(i)== '!') {
  44. result += "\n";
  45. tempNumberOfBlocks = 0;
  46. } else if (code.charAt(i) == '*') {
  47. result += "*";
  48. tempNumberOfBlocks = 0;
  49. }
  50. }
  51. System.out.println(result);
  52. }
  53. }
Success #stdin #stdout 0.06s 246080KB
stdin
123T
stdout
TTTTT