Advertisement
gasaichan

NameDecipher

Dec 24th, 2018
621
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. package deciphername;
  2. public class DecipherName {
  3.     public static void main(String[] args) {
  4.         String number = "86232316280027192";
  5.         int MagicNumber = Integer.parseInt(number.substring(0, 1));
  6.         StringBuilder sb = new StringBuilder(number);
  7.         sb.replace(0, 1, "");
  8.         sb.reverse();
  9.         System.out.println(sb.toString());
  10.         String alphabet = "абвгдеёжзийклмнопрстуфхцчшщъыьэюя";
  11.         StringBuilder output = new StringBuilder();
  12.         String CurrentSym = "";
  13.         while (!sb.toString().equals("")) {
  14.             if (sb.length() != 1) {
  15.                 CurrentSym = sb.substring(0, 2);
  16.                 sb.replace(0, 2, "");
  17.                 System.out.println(sb.toString() + " " + sb.length());
  18.                
  19.             } else {
  20.                 CurrentSym = sb.substring(0, 1);
  21.                 sb.replace(0, 1, "");
  22.             }
  23.             int CurrentIndex = Integer.parseInt(CurrentSym) - MagicNumber;
  24.             char ElementChar = alphabet.charAt(CurrentIndex);
  25.             output.append(ElementChar);
  26.            
  27.         }
  28.        
  29.         System.out.println(output.toString());
  30.     }
  31.    
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement