Last active
December 27, 2015 12:29
-
-
Save stfbee/7326175 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* User: Vlad | |
* Date: 29.10.13 | |
* Time: 20:10 | |
*/ | |
public class lab01 { | |
//Алфавит шифра | |
static final String ALPHABET = "abcdefghijklmnopqrstuvwxyzабвгдежзийклмнопрстуфхцчшщьыъэюяABCDEFGHIJKLMNOPQRSTUVWXYZАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЬЫЪЭЮЯ0123456789.,<>/?!@#$%^&*()_+-=:\"|\\'; {}`~№"; | |
//Количество символов для прокрутки | |
static final int ROT = 79; | |
//Входящее сообщение | |
static char[] MESSAGE = "Сообщение для алгоритма".toCharArray(); | |
public static void main(String[] args) { | |
//Ввод данных из коммандной строки: java lab01 "Сообщение" | |
if (args.length > 0) { | |
MESSAGE = args[0].toCharArray(); | |
} | |
//Цикл для каждого символа в MESSAGE | |
for (int i = 0; i < MESSAGE.length; i++) { | |
MESSAGE[i] = ALPHABET.charAt((ALPHABET.indexOf(MESSAGE[i]) + ROT) % (ROT * 2)); | |
} | |
//Вывод сообщения | |
System.out.println(new String(MESSAGE)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment