我有一个练习,我需要找到最远和最接近某个数字(平均值)的数字。有人可以帮助我吗?这是我的代码:
Console.WriteLine("Geef 10 gehele positieve getallen.");
Console.WriteLine("Getal 1:");
int g1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Getal 2:");
int g2 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Getal 3:");
int g3 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Getal 4:");
int g4 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Getal 5:");
int g5 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Getal 6:");
int g6 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Getal 7:");
int g7 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Getal 8:");
int g8 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Getal 9:");
int g9 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Getal 10:");
int g10 = Convert.ToInt32(Console.ReadLine());
int gemiddelde = (g1 + g2 + g3 + g4 + g5 + g6 + g7 + g8 + g9 + g10)/10;
int[] array = new int[10] {g1,g2,g3,g4,g5,g6,g7,g8,g9,g10};
jeck猫
相关分类