
21.11.2008, 18:57
|
|
Banned
Регистрация: 22.12.2007
Сообщений: 660
Провел на форуме: 3885269
Репутация:
1158
|
|
Смотри, на выводе у меня получается какая то хня. C# с KOI8-R не могу заставить работать....
Enter the key:
10
Enter the text:
Майкрософтпростосцуко
10101010101010101010
Майкрософтпростосцуко????Ў? ??Ў????Ў????
Для продолжения нажмите любую клавишу . . .
т.е. вот результат кодирования:
????Ў?Ў??Ў????Ў????
Сейчас немного переписал:
Код:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int f = 0 ;
string key, text, longkey, result;
char[] text2, longkey2;
char toto;
longkey = result = "";
Console.WriteLine("Enter the key: ");
key = Console.ReadLine();
Console.WriteLine("Enter the text: ");
text = Console.ReadLine();
key = "Mahkqopousnqopsopwrko";
for (int i = 0; i < (text.Length / key.Length); i++)
longkey += key;
longkey2 = longkey.ToCharArray();
text2 = text.ToCharArray();
for (int i = 1; i < (text.Length - 1); i++)
{
f += (int)text2[i] ^ (int)longkey2[i];
toto = Convert.ToChar((int)text2[i] ^ (int)longkey2[i]);
result += Convert.ToString(toto);
}
Console.WriteLine(result);
Console.WriteLine(f);
}
}
}
Получилось:
Enter the key:
ыва
Enter the text:
Майкрософтпростосцуко
ёёёбёбёббёбёббёбббё
20675
Для продолжения нажмите любую клавишу . . .
20675 Об этом числе шла речь в первом примере?
Последний раз редактировалось procedure; 21.11.2008 в 19:06..
|
|
|