Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _123
- {
- class Program
- {
- static int[] keys = null;
- static string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- static void Main(string[] args)
- {
- EnterKey();
- string str = null;
- str = Console.ReadLine();
- string[] words = str.Split(' ');
- StringBuilder result = new StringBuilder();
- foreach (string s in words)
- result.Append(MyShifr(new StringBuilder(s)).Append(" "));
- Console.WriteLine(result);
- Console.Read();
- }
- static StringBuilder MyShifr(StringBuilder s)
- {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < s.Length; i++)
- {
- sb.Append(alphabet[(alphabet.IndexOf(s[i]) + keys[i % keys.Length]) % alphabet.Length]);
- }
- return sb;
- }
- static void EnterKey()
- {
- string str = null;
- str = Console.ReadLine();
- try
- {
- string[] strkey = str.Split(' ');
- keys = new int[strkey.Length];
- for (int i = 0; i < strkey.Length; i++)
- {
- keys[i] = Convert.ToInt32(strkey[i]) % 10;
- }
- }
- catch (Exception e)
- {
- Console.Write(e.Message);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement