问题描述:

解题思路:

看完题就觉得很ez……不就是找出每一列最大的数吗??

解题代码:

#include<cstdio>
#include<iostream>

using namespace std;

int main()
{
    int a[3][5]={50,47,36,-30,-23,17,-19,-34,-43,-8,-42,-3,-43,34,-45};
    int i,j;
    int sum=0;
    int maxm=0;
    for(i=0;i<5;i++)
    {
        maxm=-999;
        for(j=0;j<3;j++)
        {
            if(a[j][i]>maxm)
                maxm=a[j][i];
        }
        sum+=maxm;
        cout<<maxm<<" ";
    }
    cout<<"\nsum="<<sum<<endl;
    return 0;
}

测试结果:

50 47 36 34 -8

sum=159

 

Process returned 0 (0x0)   execution time : 0.030 s

Press any key to continue.