您的位置:首页 > 其它

二维数组中每行最大值

2015-09-26 16:21 281 查看
[code]#include<iostream>
#include<vector>
#include<list>
#include<set>
#include<algorithm>
using namespace std;
int main()
{
    int max;
    int  a[3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            cout << a[i][j] << "\t";
        }
        cout << endl;
    }
    for (int i = 0; i < 3; i++)
    {
        max = a[i][0];
        for (int j = 0; j < 4; j++)
        {
            if (max < a[i][j]);
            max = a[i][j];
        }
        cout << max << endl;
    }
    system("pause");
    return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: