You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
499 B
25 lines
499 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
int main() {
|
|
int m, n;
|
|
cin >> m >> n;
|
|
int a[100][100] = {0};
|
|
for (int i = 0; i < m; ++i) {
|
|
for (int j = 0; j < n; ++j) {
|
|
cin >> a[i][j];
|
|
}
|
|
}
|
|
int sum = 0;
|
|
for (int i = 0; i < m; ++i) {
|
|
sum += a[i][0] + a[i][n - 1]; //左+右
|
|
}
|
|
|
|
for (int i = 1; i < n - 1; ++i) {
|
|
sum += a[0][i] + a[m - 1][i];//上+下
|
|
}
|
|
cout << sum << endl;
|
|
return 0;
|
|
}
|