您的位置:首页 > 编程语言

下午写的一个代码,还没调试

2006-10-09 17:08 246 查看
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{

class Program
{

static int MaxValue(int[] intArray)
{
int maxVal = intArray[0];
for (int i = 1; i < intArray.Length; i++)
{
if (intArray[i] > maxVal)
maxVal = intArray[i];
}
return maxVal;
}

static void Main(string[] args)
{
//int[] myArray = {1,23,45,34,53,52,64,111};
//int maxVal = MaxValue(myArray);
//Console.Write("数组中的最大值是:{0}",maxVal);
//Console.ReadKey();

int[] myArray ={0,0,0,0,0 };
int i=0;

do
{
Console.Write("请输入N个数据,用逗号隔开!");
myArray[i] = Convert.ToInt32(Console.ReadLine());
i++;
}while(Console.ReadLine().ToString() != "e");

int max =MaxValue(myArray);

// max(a,b);
Console.WriteLine("你输入的最大值是:{0}", max);
Console.ReadKey();
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐