Mishakis

SpellCaster

Nov 28th, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.91 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.List;
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.  
  10.         String sentence = scanner.nextLine();
  11.  
  12.         String[] words = sentence.split(" ");
  13.         String newWord = "";
  14.         boolean isTrue = true;
  15.         int freeWords = 0;
  16.  
  17.  
  18.         while (isTrue) {
  19.             for (int w = 0; w < words.length; w++) {
  20.  
  21.                 if (!(words[w].isEmpty())) {
  22.                     newWord += words[w].charAt(words[w].length() - 1);
  23.                     words[w] = words[w].substring(0, words[w].length() - 1);
  24.  
  25.  
  26.                 } else {
  27.                     freeWords++;
  28.                 }
  29.                 if (freeWords == words.length) {
  30.                     isTrue = false;
  31.                 }
  32.             }
  33.  
  34.  
  35.         }
  36.         System.out.println(newWord);
  37.         int ascii = 0;
  38.         int newIndex = 0;
  39. //        List<Character> newSeq = new ArrayList<Character>(100);
  40. //        System.out.println(newSeq.size());
  41. //        for (int i = 0; i <newWord.length() ; i++) {
  42. //            newSeq.add(i, newWord.charAt(i)) ;
  43. //        }
  44.  
  45.         for (int i = 0; i <newWord.length() ; i++) {
  46.             char letter = newWord.charAt(i);
  47.             ascii  = (int) letter;
  48.             if (ascii >= 97) {
  49.                 ascii -= 96;
  50.             } else {
  51.                 ascii -= 64;
  52.             }
  53.  
  54.             newIndex = ascii + i ;
  55.  
  56.             while (newIndex > newWord.length() - 1) {
  57.                 newIndex -= newWord.length();
  58.             }
  59.             newWord = newWord.substring(0, newIndex) + newWord.charAt(i) + newWord.substring(newIndex);
  60.         }
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67. //        for (int i = 0; i <newWord.length() ; i++) {
  68. //            newSeq.set(newIndex, newWord.charAt(i));
  69. //        }
  70.         System.out.println(newWord);
  71.         }
  72.  
  73.     }
  74.  
  75.  
  76.  
  77.  
  78.  
  79. v
Advertisement
Add Comment
Please, Sign In to add comment