// UVa 11470 - Square Sums
#include <iostream>
using namespace std;
int main() {
int n, c = 0;
while (cin >> n && n) {
c++;
int t[10][10];
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
cin >> t[i][j];
int mid = (n & 1) ? (n >> 1) : ((n >> 1) - 1);
cout << "Case " << c << ":";
for (int a = 0; a <= mid; a++) {
int b = n - a - 1;
int sum = 0;
for (int j = a; j <= b; j++)
sum += t[a][j] + t[b][j];
if (a == b)
sum -= t[a][b];
for (int i = a + 1; i <= b - 1; i++)
sum += t[i][a] + t[i][b];
cout << " " << sum;
}
cout << endl;
}
return 0;
}
Wednesday, December 30, 2015
UVa 11470 - Square Sums
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment