题解 | #矩阵最大值#

矩阵最大值

https://www.nowcoder.com/practice/9c550b6fe85d48bcad5a6025c6dc447d

#include <iostream>
using namespace std;

int main() {
    int m,n;
    while(cin>>m>>n)
    {
        int nums[m][n];
        int pos;
        int max;
        int sum;
        for(int i=0;i<m;i++)
        {
            sum=0;
            max=0;
            for(int j=0;j<n;j++)
            {
                cin>>nums[i][j];
                if(nums[i][j]>max)
                {
                    pos=j;
                    max=nums[i][j];
                }
                sum+=nums[i][j];
            }
            nums[i][pos]=sum;
            for(int j=0;j<n;j++)
            {
                cout<<nums[i][j]<<" ";
            }
            cout<<endl;
        }

    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

没hc还海面!呜呜,避雷
回收旧报纸:没有海面吧,我做完笔试有一个多月了,还没消息
点赞 评论 收藏
分享
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务