我们正在尝试在控制台上编写 3 个数组
像这样;
DDDEEDUDE
教育
到期
随机选择给定的数组和字母代码运行得很好,但它只显示第一行。我想不出一个好主意。第一个数组运行完美,但其他数组不显示。
string[] A1 = new string[15];
string[] A2 = new string[15];
string[] A3 = new string[15];
Random rastgele = new Random();
int selected_array = 0;
int gamecount_for_a1 = 0;
int gamecount_for_a2=0;
int gamecount_for_a3=0;
string which_letter_str;
while (true)
{
int which_array = rastgele.Next(3);
if (which_array == 0)
{
selected_array = 0;//A1
}
else if (which_array == 1)
{
selected_array = 1;//A2
}
else
{
selected_array = 2;//A3
}
int which_letter_int= rastgele.Next(3);
if (which_letter_int == 0)
{
which_letter_str = "D";
}
else if (which_letter_int == 1)
{
which_letter_str = "E";
}
else
{
which_letter_str = "U";
}
if (selected_array ==0)
{
A1[gamecount_for_a1] = which_letter_str;
Console.SetCursorPosition(gamecount_for_a1, 0);
Console.Write(A1[gamecount_for_a1]);
gamecount_for_a1++;
}
else if (selected_array == 1)
{
A1[gamecount_for_a2] = which_letter_str;
Console.SetCursorPosition(gamecount_for_a2, 2);
Console.Write(A2[gamecount_for_a2]);
gamecount_for_a2++;
}
else
{
A1[gamecount_for_a3] = which_letter_str;
Console.SetCursorPosition(gamecount_for_a3, 4);
Console.Write(A3[gamecount_for_a3]);
gamecount_for_a3++;
}
Console.ReadLine();
if (gamecount_for_a1 == 15 || gamecount_for_a2 == 15 || gamecount_for_a3 == 15)
break;
}