.NET 4.x 1337(Leet) переводчик - C#
Формулировка задачи:
Всем доброго времени суток
вот на досуге решил сделать leet переводчик, я использовал исходник от азбуки Морзе.
собственно программа шифрует текст без проблем, но при расшифровке возникает ошибка, помогите разобраться, заранее благодарю))
вот сам код проги:
если кому надо, то скину и саму прогу.
namespace MorseCode
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
char[] OneText = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'А', 'Б', 'В', 'Г', 'Д', 'Е', 'Ж', 'З', 'И','Й',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'К', 'Л', 'М', 'Н', 'О', 'П', 'Р', 'С', 'Т','У', 'Ф',
'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Х', 'Ц', 'Ч', 'Ш', 'Щ', 'Ы', 'Ь','Э', 'Ю', 'Я',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',};
string[] Translate = new string[] { "4", "|8", "(", "|)", "3", "|=", "9", "|-|", "!", "/-", "6", "|8", "r", "|)", "#", "}|{", "3", "|/|", "|/|",
"_/", "|<", "1", "|\\/|", "|\\|", "0", "|*", "()_", "2", "|<", "/", "|\\/|", "|\\|", "0", "n", "P", "(", "']['", "`/", "qp",
"5", "7", "(_)", "\\/", "\\/\\/", "><", "`/", "%", "><", "|_|,", "4", "|_|_|", "|_|_|,", "b|", "b", "-)", "|-0", "9I",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
private void button1_Click(object sender, EventArgs e)
{
string input = textBox1.Text;
input = input.ToUpper();
string output = "";
int index;
foreach(char c in input)
{
if (c == ' ')
output += " ";
else
{
index = Array.IndexOf(OneText, c);
output += Translate[index] + "";
}
}
textBox2.Text = output;
}
private void button2_Click(object sender, EventArgs e)
{
string input = textBox3.Text;
string[] split = input.Split(' ');
string output = "";
int index;
foreach (string s in split)
{
index = Array.IndexOf(Translate, s);
output += OneText[index] + "";
}
textBox4.Text = output;
}
}
}Решение задачи: «.NET 4.x 1337(Leet) переводчик»
textual
Листинг программы
if(index >= 0) output += Translate[index] + "";