可以参考一下以下代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace erweishuzu
{
class Program
{
static void Main(string[] args)
{
int t1=0, t2=0;
int[,] a = new int[2, 3] {{ 3, 4, 5},{7, 8, 9 } };
for (int i = 0; i < 2; i++)
{
int max = a[i, 0];
for (int j = 0; j < 3; j++)
if (a[i, j] > max)
{
max = a[i, j];
t1 = i;
t2 = j;
}
Console.WriteLine("请输入这几行的最大值和下标:{0},{1},{2}", max,t1,t2);
Console.ReadLine();
}
}
}
}
|