最佳浏览路线问题

问题描述:

最佳浏览路线问题_第1张图片

解题思路:

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

解题代码:

#include
#include

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<50 47 36 34 -8

sum=159

 

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

Press any key to continue.

你可能感兴趣的:(算法)