首页 > 试题广场 >

Problem B

[编程题]Problem B
  • 热度指数:5075 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32M,其他语言64M
  • 算法知识视频讲解
请写一个程序,对于一个m行m列的(1<m<10)的方阵,求其每一行,每一列及主副对角线元素之和,最后按照从大到小的顺序依次输出。

输入描述:
共一组数据,输入的第一行为一个正整数,表示m,接下来的m行,每行m个整数表示方阵元素。


输出描述:
从大到小排列的一行整数,每个整数后跟一个空格,最后换行。
示例1

输入

4
15 8 -2 6
31 24 18 71
-3 -9 27 13
17 21 38 69

输出

159 145 144 135 81 60 44 32 28 27
头像 whoway
发表于 2020-12-27 16:16:03
一、某ASCII码方式输出 炫技??可读性极差printf("%d%c",arr[len],len? 32 :10 );其实等价于,我注释掉的 #include<bits/stdc++.h> using namespace std; int n; static const int ma 展开全文
头像 bigbigcake
发表于 2024-03-12 20:52:04
#include <bits/stdc++.h> using namespace std; int main() { int n; while(cin>>n){ vector<int>v; int arr[n][n 展开全文
头像 路人萌Miranda
发表于 2022-03-13 17:48:08
#include <cstdio> #include <algorithm> #include <cstring> using namespace std; int main() { int m; while (cin >> m) { in 展开全文
头像 rainman_
发表于 2023-03-22 08:34:29
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <stack> #include <map> #incl 展开全文
头像 无聊的马来熊在学习
发表于 2023-03-15 23:02:30
#include <stdio.h> //注意还有主副对角线的和,测试用例是多组输入 int main() { int m = 0; while(scanf("%d", &m)!=EOF){ int arr[10][10] = { 0 }; for (in 展开全文
头像 buxingyebufangqi
发表于 2022-08-24 13:01:35
memset()放在循环里也只会初始化数组一次,这是为什么呀?大佬求解答

问题信息

上传者:小小
难度:
29条回答 3280浏览

热门推荐

通过挑战的用户

查看代码