导航

练习找出数组中最大的一个数

Posted on 2011-03-29 00:19  beeone  阅读(602)  评论(1编辑  收藏  举报
/*目的:练习找出数组中最大的一个数
*知识点:函数
*作者:beeone
*日期:2011-02-19
*/

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] ArryText = { 12,1, 5, 2, 9, 15, 98, 44, 100, 33, 654,0 ,-1};
Console.WriteLine(
"最大的数是:"+GetMaxNum(ArryText));
Console.ReadKey();

}
static int GetMaxNum(int[] Myarry)
{
int NUM = Myarry[0];
for (int i = 0; i < Myarry.Length; i++)
{
if (Myarry[i] >NUM)
{
NUM
= Myarry[i];
}
}
return NUM;
}


}
}