我想显示一个数组本身没有问题。但是,我想添加一个If statement
,这样如果正在显示的score[]
阵列的当前迭代等于300,那么它将在其后面放置一个*
。就像300*
C#显示阵列的格式化内容
此外阵列需要显示从最高到最低,我正在通过颠倒显示在阵列中的最低点到最高点。我正在考虑使用交换来改变顺序,但如果我不必那么我想这样解决它。
到目前为止,我得到
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);
}
}
}
你只需要移动你的if语句中的for循环? – Greg 2012-07-15 23:35:08
我确实尝试过,但它也给出了不理想的结果 – Dan 2012-07-15 23:37:30
您能否提供一个数据样本?另外在你的for循环中它是否需要i> 0? – Greg 2012-07-15 23:44:47