Шифр Цезаря - C# (188826)
Формулировка задачи:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace cezar
{
class Program
{
static void Main(string[] args)
{
int n = 1, key = 1;
Console.WriteLine("Введите слово,которое нужно зашифровать:");
string s = Console.ReadLine();
Console.WriteLine("Введите ключ:");
key = Convert.ToInt32(Console.ReadLine());
string s1 = "";
string alfphabet = "абвгдеёжзийклмнопрстуфхцчшщъыьэюя";
int m = alfphabet.Length;
for (int i = 0; i < s.Length; i++)
{
for (int j = 0; j < alfphabet.Length; j++)
{
if (s[i] == alfphabet[j])
{
int temp = j * n + key;
while (temp >= m)
temp -= m;
s1 = s1 + alfphabet[temp];
}
}
}
Console.WriteLine("Зашифрованное слово:" + s1);
Console.ReadLine();
}
}
}
Помогите добавить дешифрование
Решение задачи: «Шифр Цезаря»
textual
Листинг программы
int n = 1, key = 1;