编程练习出现的问题,请大家帮解决一下!谢谢!
发表在C#图书答疑
2014-04-22
是否精华
是
否
版块置顶:
是
否
namespace 数组_练习1
{
class Program
{
static void Main(string[] args)
{
int[] numbers = new int[] { 23, 89, 98, 12, 34, 56 };
int max = numbers[0];
for (int i = 1; i < numbers.Length; i++)
{
if (numbers[i] > max)
{
max = numbers[i];
}
Console.WriteLine("max=" + max);
Console.ReadKey();
}
}
}
}
输出显示为什么是89,而不是98呢?正常应该是98呀!
{
class Program
{
static void Main(string[] args)
{
int[] numbers = new int[] { 23, 89, 98, 12, 34, 56 };
int max = numbers[0];
for (int i = 1; i < numbers.Length; i++)
{
if (numbers[i] > max)
{
max = numbers[i];
}
Console.WriteLine("max=" + max);
Console.ReadKey();
}
}
}
}
输出显示为什么是89,而不是98呢?正常应该是98呀!