using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace searchmax
{
class fmax
{
public static void find(int[] AA)//非静态的字段、方法或属性“searchmax.fmax.find(int[])”要求对象引用
{
int i,k,max;
k = 0;
max = AA[0];
for (i = 0; i < 5; i++)
{
if (max < AA[i])
{
k = i;
max = AA[i];
}
}
Console.WriteLine("最大元素下标为{0}",k);
}
static void Main(string[] args)
{
int [] AA = {5,15,36,15,35};
find(AA);
}
}
}
|