我正在尝试显示一个本身没有问题的数组。但是,我想添加一个If statement
,以便如果score[]
正在显示的数组的当前迭代等于 300,那么它将在其后放置一个*
。就像是300*
此外,阵列需要从最高到最低显示,我正在通过在阵列中将显示反转为最低到最高来执行此操作。我正在考虑使用交换来反转顺序,但如果我不需要,那么我想以这种方式解决它。
到目前为止,我得到
400
332
300*
300
或者以我尝试的另一种方式,我得到了
0
0
300*
300
250
221
我只是在显示和输出方面遇到问题。
static void Output(int iteration, int[] score, string[] player, double average)
{ //opening output
Console.WriteLine("\n\t****** OUTPUT ******");
Console.WriteLine("\nScores for this game.\n");
if (score[iteration - 1] == 300)
{
Console.WriteLine("{0} score was {1}*", player[iteration - 1], score[iteration - 1]);
}
for (int i = iteration; i <= MAX_SIZE_ARRAY; i--)
{
//iterates through the loop to display all the players name then score
Console.WriteLine("{0} score was {1}", player[i], score[i]);
}
//displays high, low, and average score
Console.WriteLine("\nThe high score was {0} with {1} points", player[iteration - 1], score[iteration - 1]);
Console.WriteLine("The low score was {0} with {1} points", player[0], score[0]);
Console.WriteLine("The team average score was {0}", average);
}
}
}