#include<iostream>
#include<iomanip>
using namespace std;
void main()
{
int a[3][4] = { {1,2,3,8},{4,5,6},{-10,2,9} };
int max = a[0][0];
int row=0, colum=0;
for (int i = 0;i < 3;i++)
{
for (int j = 0;j < 4;j++)
{
std::cout << setw(4) << a[i][j] << " ";
if (a[i][j] > max)
{
max = a[i][j];
row = i;
colum = j;
}
}
std::cout << std::endl;
}
std::cout << "max= " << max << " ; " << " row= " << row << " colum= " << colum << std::endl;
std::cin.get();
}
本文介绍了一个C++程序,用于在不规则填充的二维数组中查找最大值及其所在行和列的位置。通过双重循环遍历数组,比较每个元素以确定最大值,并记录其坐标。
1627

被折叠的 条评论
为什么被折叠?



