こんにちは、たとえばシーザー暗号について新しい質問があります
キー: 3
無地: ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ
暗号: DEFGĞHIİJKLMNOÖPRSŞTUÜVYZABCD
これらはトルコ文字 " ç ,ı ,ğ, ö ş , ü , Ç, İ , Ğ, Ö, Ş, Ü "
暗号化と復号化を行う必要があり、プログラムで大文字と小文字を区別する必要はありません。s=S, ç=Ç のようになるはずです
以下に私のプログラムを見ることができますが、いくつか問題があります
1)テキスト(プレーン)とキーはユーザーが入力する必要がありますが、できませんでした。
2) char text[] = "DEF"; この入力は(復号化のために)「CÇD」を与えるはずですが、「CÇD」を与えます
通常、「Ã」ではなく「Ç」を指定する必要があります。
私は助けが必要です :(
# include <iostream>
# include <cstring>
const char alphabet[] ={'A', 'B', 'C', 'Ç', 'D', 'E', 'F', 'G', 'Ğ', 'H', 'I',
'İ', 'J', 'K', 'L', 'M', 'N', 'O', 'Ö', 'P', 'R', 'S',
'Ş', 'T', 'U', 'Ü', 'V', 'Y', 'Z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '.', ',', ':', ';', ' '};
const int char_num =44;
void cipher(char word[], int count, int key)
{
int i = 0;
while(i < count) {
int ind = -1;
while(alphabet[++ind] != word[i]) ;
ind += key;
if(ind >= char_num)
ind -= char_num;
word[i] = alphabet[ind];
++i;
}
}
void decipher(char word[], int count, int key)
{
int i = 0;
while(i < count) {
int ind = -1;
while(alphabet[++ind] != word[i]) ;
ind -= key;
if(ind < 0)
ind += char_num;
word[i] = alphabet[ind];
++i;
}
}
int main()
{
char text[] = "ABC";
int len = strlen(text);
std::cout << text << std::endl;
cipher(text, len, 2);
std::cout << text << std::endl;
decipher(text, len, 2);
std::cout << text << std::endl;
system("pause");
return 0;
}