Advertisement
roronoa

vigenere

Jun 17th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.*;
  3. import java.math.*;
  4.  
  5. class Solution {
  6.  
  7.     public static void main(String args[]) {
  8.         Scanner in = new Scanner(System.in);
  9.         String text = in.nextLine();
  10.         String code = in.next();
  11.         int i = 0;
  12.         for(char c : text.toCharArray())
  13.         {
  14.             if(Character.isLetter(c))
  15.             {
  16.                 int letter = c - 'a';
  17.                 int cod = code.charAt(i) - 'a';
  18.                 letter = (letter +26 - cod)%26 + 'a';
  19.                 System.out.print((char) letter);
  20.                 i = (i+1)%code.length();
  21.             }
  22.             else
  23.                 System.out.print(c);    
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement