求大神帮下忙,这个错哪里了呀,怎么修改using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace hanshu2{ class Program { static void MaxValue(int[] intArray,ou
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 10:15:29
求大神帮下忙,这个错哪里了呀,怎么修改using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace hanshu2{ class Program { static void MaxValue(int[] intArray,ou
求大神帮下忙,这个错哪里了呀,怎么修改
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace hanshu2
{
class Program
{
static void MaxValue(int[] intArray,out int maxIndex)
{
int maxVal = intArray[0];
maxIndex = 0;
for (int i = 1; i <= intArray.Length; i++)
{
if (maxVal < intArray[i])
{
maxVal = intArray[i];
maxIndex = i;
}
}
return maxVal;
}
static void Main(string[] args)
{
int[] myString={1,3,4,9,5,2,6};
int maxIndex;
Console.WriteLine("{0}",MaxValue(myString,out maxIndex));
Console.WriteLine("{0}",maxIndex);
Console.ReadKey();
}
}
}
求大神帮下忙,这个错哪里了呀,怎么修改using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace hanshu2{ class Program { static void MaxValue(int[] intArray,ou
int[] myString={1,3,4,9,5,2,6};
int maxIndex;
MaxValue(myString,out maxIndex)
Console.WriteLine("{0}",maxIndex);
Console.ReadKey();
主函数体改成这个.
MaxValue()函数中删除"return maxVal;"这一句.