close
// 題目:找出數值陣列中最大值與最小值
int[] intArray = { 10, 99, 15, 2, 58, 28, 94 };
int intMax = intArray[0];
int intMin = intArray[0];
for (int ii = 0; ii < intArray.Length; ii++)
{
if (intMax < intArray[ii])
{
intMax = intArray[ii];
}
if (intMin > intArray[ii])
{
intMin = intArray[ii];
}
}
Response.Write("最大值:" + intMax.ToString());
Response.Write("<br />");
Response.Write("最小值:" + intMin.ToString());
來源: http://goodlucky.pixnet.net/blog/post/47751894
全站熱搜
留言列表