我正在尝试制造一个谜机,除了第一个转子外,其他所有转子都无法正常工作。我没有得到正确的结果
static void Main(string[] args)
{
char[] Alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray();
char[] rout1 = "JGDQOXUSCAMIFRVTPNEWKBLZYH".ToCharArray();
char l1;
Console.Write("Enter a character -- ");
Char Letter = Convert.ToChar(Console.ReadLine());
Console.WriteLine(Letter);
int i;
for (i = 0; i < 26; i++)
{
if (Letter == rout1[i])
{
l1 = Alpha[i];
Console.WriteLine(l1);
Console.ReadLine();
}
}
}
A为J,B为G,C为D,D为Q。 但是A是J,B是V,C是I D是C,E IS S
答案 0 :(得分:1)
如果A等于J,B等于G,C等于D,D等于Q,则需要更改条件
public static void Main(string[] args)
{
char[] Alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray();
char[] rout1 = "JGDQOXUSCAMIFRVTPNEWKBLZYH".ToCharArray();
char l1;
Console.Write("Enter a character -- ");
Char Letter = Convert.ToChar(Console.ReadLine());
Console.WriteLine(Letter);
int i;
for (i = 0; i < 26; i++)
{
if (Letter == Alpha[i])
{
l1 = rout1[i];
Console.WriteLine(l1);
Console.ReadLine();
}
}
}
您需要检查Alpha
而不是rout1