#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
int n;
while (scanf("%d", &n) != EOF) {
int rsum[n];
int csum[n];
int sum1 = 0;
int sum2 = 0;
memset(rsum, 0, sizeof(rsum));
memset(csum, 0, sizeof(csum));
//input
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
int temp;
scanf("%d", &temp);
if (i == j) sum1 += temp;
if (i + j == n - 1) sum2 += temp;
rsum[j] += temp;
csum[i] += temp;
}
}
vector<int> ans;
ans.push_back(sum1);
ans.push_back(sum2);
for (int k = 0; k < n; ++k) {
ans.push_back(rsum[k]);
ans.push_back(csum[k]);
}
sort(ans.begin(), ans.end(), [](const int &a, const int &b) {
return a - b > 0;
});
int x = ans.size();
for (int i = 0; i < x; i++) {
printf("%d", ans[i]);
if (i != x - 1) printf(" ");
}
printf("\n");
}
return 0;
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章