2018-12-19

2018-12-19  本文已影响0人  鲸落_79f1

namespace ConsoleApplication1

{

class Program { static void Main(string[] args)

{

//某百货商场当日消费积分最高的8名顾客,

//他们的积分分别是18、25、7、36、13、2、89、63.编写程序找出最低的积分及它在数组中的原始位置。

try

{

Console.WriteLine("某百货商场当日消费积分最高的8名顾客");

Console.WriteLine("他们的积分分别是18、25、7、36、13、2、89、63.编写程序找出最低的积分及它在数组中的原始位置");

int[] points = { 18, 25, 7, 36, 13, 2, 89, 63 };

int index = 0; int min = points[0];

for (int i = 0; i < points.Length - 1; i++)

{

if (min > points[i])

{ min = points[i]; index = i ;

}

}

Console.WriteLine("")

; Console.WriteLine("最低积分是:"+min+"原始位置是:"+index);

}

catch

{

Console.WriteLine("你输入的格式有误");

}

Console.ReadKey();

}

}

}

2018-12-19
上一篇下一篇

猜你喜欢

热点阅读