文章
43
粉丝
180
获赞
21
访问
195.1k
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[11][11], res[30];
int main()
{
int n; cin >> n;
for (int i = 1; i <= n; i ++ )
for (int j = 1; j <= n; j ++ )
cin >> a[i][j];
int cnt = 0;
for (int i = 1; i <= n; i ++ )
{
for (int j = 1; j <= n; j ++ ) res[cnt] += a[i][j];
cnt ++;
}
for (int i = 1; i <= n; i ++ )
{
for (int j = 1; j <= n; j ++ ) res[cnt] += a[j][i];
cnt ++;
}
for (int i = 1; i <= n; i ++ ) res[cnt] += a[i][i];
cnt ++;
for (int i = 1; i <= n; i ++ ) res[cnt] += a[i][n - i + 1];
cnt ++;
sort(res, res + cnt);
for (int i = 0; i < cnt; i ++ ) cout << res[cnt - i - 1] << ' ';
return 0;
}
登录后发布评论
暂无评论,来抢沙发