作業(yè)要求
編寫(xiě)程序找出最低的積分及它在數(shù)組中的原始位置。
代碼
...
int[] points = { 18, 25, 7, 36, 13, 2, 89, 63 };
int index = 0;
int min= points[0];
Console.WriteLine("請(qǐng)輸入8位顧客的當(dāng)日消費(fèi)積分");
Console.WriteLine("他們的積分分別是:18, 25, 7, 36, 13, 2, 89, 63 ");
Console.WriteLine("");
for (int i = 0; i < points.Length; i++)
{
if (min> points[i])
{
min = points[i];
index=i+1;
}
}
Console.WriteLine("最低積分"+min+"原始位置"+index);
Console.ReadKey();
...
效果

圖片發(fā)自簡(jiǎn)書(shū)App