|
发表于 2012-12-17 14:31:55
|
显示全部楼层
四川省巴中市
static void Main(string[] args)
{
Console.WriteLine("请输入10个数,以“,”隔开:");
string allNumber= Console.ReadLine().Trim();
string[] number = allNumber.Split(',');
double [] num=new double[number.Length];
for (int i = 0; i < number.Length; i++)
{
num[i] = Convert.ToDouble(number[i]);
}
double min = num[1];
double max = num[1];
for (int i = 0; i < num.Length; i++)
{
if (num[i] < min)
{
min = num[i];
}
else if (num[i] > max)
{
max = num[i];
}
}
Console.WriteLine("最大数是{0},最小数是{1}",max ,min );
Console.ReadLine();
}
|
|