Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.31 KB | None | 0 0
  1. public class Main {
  2.     private static int getIndex(char[] t_arr, char t)
  3.     {
  4.         for (int i = 0; i < t_arr.length; i++)
  5.         {
  6.             if (t_arr[i] == t)
  7.                 return i;
  8.         }
  9.  
  10.         return -1;
  11.     }
  12.  
  13.     public static void main(String[] args)
  14.     {
  15.         String[] ascii0 = { " ### ", "#### ", "#####", "#### " };
  16.         String[] ascii1 = { "#   #", "#   #", "#    ", "#   #" };
  17.         String[] ascii2 = { "#####", "#### ", "#    ", "#   #" };
  18.         String[] ascii3 = { "#   #", "#   #", "#    ", "#   #" };
  19.         String[] ascii4 = { "#   #", "#### ", "#####", "#### " };
  20.  
  21.         char[] alphabet = { 'a', 'b', 'c', 'd' };
  22.  
  23.         String line = new Scanner(System.in).nextLine();
  24.         StringBuilder sb = new StringBuilder(25 * line.replaceAll(" ", "").length());
  25.  
  26.         for (int i = 0; i < line.length(); i++)
  27.         {
  28.             var index = getIndex(alphabet, line.charAt(i));
  29.  
  30.             if (index != -1)
  31.             {
  32.                 sb.append(ascii0[index]);
  33.                 sb.append(" ");
  34.             }
  35.         }
  36.  
  37.         sb.append("\n");
  38.  
  39.         for (int i = 0; i < line.length(); i++)
  40.         {
  41.             var index = getIndex(alphabet, line.charAt(i));
  42.  
  43.             if (index != -1)
  44.             {
  45.                 sb.append(ascii1[index]);
  46.                 sb.append(" ");
  47.             }
  48.         }
  49.  
  50.  
  51.         sb.append("\n");
  52.  
  53.         for (int i = 0; i < line.length(); i++)
  54.         {
  55.             var index = getIndex(alphabet, line.charAt(i));
  56.  
  57.             if (index != -1)
  58.             {
  59.                 sb.append(ascii2[index]);
  60.                 sb.append(" ");
  61.             }
  62.         }
  63.  
  64.  
  65.         sb.append("\n");
  66.  
  67.         for (int i = 0; i < line.length(); i++)
  68.         {
  69.             var index = getIndex(alphabet, line.charAt(i));
  70.  
  71.             if (index != -1)
  72.             {
  73.                 sb.append(ascii3[index]);
  74.                 sb.append(" ");
  75.             }
  76.         }
  77.  
  78.  
  79.         sb.append("\n");
  80.  
  81.         for (int i = 0; i < line.length(); i++)
  82.         {
  83.             var index = getIndex(alphabet, line.charAt(i));
  84.  
  85.             if (index != -1)
  86.             {
  87.                 sb.append(ascii4[index]);
  88.                 sb.append(" ");
  89.             }
  90.         }
  91.  
  92.         System.out.println(sb.toString());
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement