主题:帮忙
using System;
class ddr
{
static int maxvalue(int[] intarray, out int maxindex)
{
int maxval = intarray[0];
maxindex = 0;
for (int i = 1; i < intarray.Length; i++)
{
if (intarray[i] > maxval)
{
maxval = intarray[i];
maxindex = i;
}
}
return maxval;
}
static void Main()
{
int[] myarray ={ 2, 22, 3, 34, 12 };
int maxindex;
Console.WriteLine("the max number is {0}", maxvalue(myarray, out maxindex));
Console.WriteLine("the first number is {0}", maxindex + 1);
}
}
这里的第二个输出为什么是4呀
class ddr
{
static int maxvalue(int[] intarray, out int maxindex)
{
int maxval = intarray[0];
maxindex = 0;
for (int i = 1; i < intarray.Length; i++)
{
if (intarray[i] > maxval)
{
maxval = intarray[i];
maxindex = i;
}
}
return maxval;
}
static void Main()
{
int[] myarray ={ 2, 22, 3, 34, 12 };
int maxindex;
Console.WriteLine("the max number is {0}", maxvalue(myarray, out maxindex));
Console.WriteLine("the first number is {0}", maxindex + 1);
}
}
这里的第二个输出为什么是4呀