אני עשיתי משהו כזה לא ממש היה לי כוח לבדוק אם זה שונה משלך (SIXFORLIFE)
אבל זה נראה לי קצת יותר קצר, יכול להיות שזה אותו דבר, יכול להיות שזה גם יותר ארוך ופחות יעיל אבל בלי בירבורים:
קוד:
int goal, goal2, goal3, avg, temp = 0, temp1 = 0;
for (int i = 1; i <= 20; i++)
{
Console.Write("Enter the goals of the first game: ");
goal = int.Parse(Console.ReadLine());
Console.Write("Enter the goals of the second game: ");
goal2 = int.Parse(Console.ReadLine());
Console.Write("Enter the goals of the third game: ");
goal3 = int.Parse(Console.ReadLine());
avg = goal + goal2 + goal3;
Console.WriteLine("The avg of the {0} player is: {1}", i, avg / 3);
if (avg == 0)
{
Console.WriteLine("The player wasn't scored any goal.");
}
elseif (avg >= 5)
{
Console.WriteLine("The player was very good.");
}
if (avg > temp)
{
temp = avg;
temp1 = i;
}
Console.WriteLine("Click enter to continue.");
Console.ReadLine();
Console.Clear();
}
Console.Write("The best player is: {0} with {1} goals.", temp1, temp);