首页 > 试题广场 >

矩阵最大值

[编程题]矩阵最大值
  • 热度指数:9379 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
编写一个程序输入一个mXn的矩阵存储并输出,并且求出每行的最大值和每行的总和。 要求把每行总和放入每行最大值的位置,如果有多个最大值,取下标值最小的那一个作为最大值。 最后将结果矩阵输出。

输入描述:
输入的第一行包括两个整数m和n(1<=m,n<=100),分别代表矩阵的行和列的维数。
接下来的m行每行有n个数,代表矩阵的元素。


输出描述:
可能有多组测试数据,对于每组数据,输出按题目要求执行后的矩阵。
示例1

输入

3 3
1 1 1
1 1 1
1 1 1
3 3
3 2 3
2 3 2
3 2 3

输出

3 1 1
3 1 1
3 1 1
8 2 3
2 7 2
8 2 3

头像 KDDA十三尧十三
发表于 2021-03-21 17:22:04
#include #include using namespace std; //此题关键在于存储每行第一个最大数的行列值 typedef struct Matrix { int line;//行 int row;//列 int value;//值 }; int main(v 展开全文
头像 小朱666
发表于 2023-09-22 19:51:31
#include<stdio.h> const int M = 1000; const int N = 1000; int a[M][N]; int main() { int m, n; while(scanf("%d%d", &m, & 展开全文
头像 happyfox
发表于 2022-07-10 19:48:38
#include<iostream> using namespace std; int main() { int m,n; while(cin >>m >>n ) { int&n 展开全文
头像 在考古的小鱼干很有气魄
发表于 2023-03-07 10:16:45
#include <bits/stdc++.h> #define MAX 100 using namespace std; int main() { int n, m, i, j, k, max, sum; int data[MAX][MAX]; while ( 展开全文
头像 木何
发表于 2023-03-04 21:23:36
#include<iostream> using namespace std; int main() { int m, n; cin >> m >> n; int** a = new int* [m]; for (int i = 展开全文
头像 憨活一生
发表于 2024-02-05 13:49:28
#include <stdio.h> #include <stdlib.h> int main() { int m, n; while (scanf("%d %d", &m, &n) != EOF) { 展开全文
头像 给我就亿下
发表于 2023-03-28 14:24:46
#include <iostream> using namespace std; const int MAXN = 100 + 10; int matrix[MAXN][MAXN]; int main () { int m, n; while (cin >> m 展开全文
头像 小朱666
发表于 2023-09-22 19:51:01
#include<stdio.h> const int M = 1000; const int N = 1000; int a[M][N]; int main() { int m, n; while(scanf("%d%d", &m, & 展开全文
头像 软件2001-20206821-傅子文
发表于 2024-03-20 20:11:40
#include <stdio.h> int main() { int a, b; while (scanf("%d %d", &a, &b) != EOF) { // 注意 while 处理多个 case // 64 展开全文
头像 小黑狼1号
发表于 2024-03-26 16:22:39
#include <iostream> using namespace std; int main() { int m,n; while (cin >> m>>n) { // 注意 while 处理多个 case int num[ 展开全文