1121:计算矩阵边缘元素之和

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    int a[100][100]={};
    for(int x=1;x<=n;x++){
        for(int y=1;y<=m;y++){
            cin>>a[x][y];
        }
    }
    int s=0;
    for(int x=1;x<=n;x++){
        for(int y=1;y<=m;y++){
            if(x==1||x==n||y==1||y==m) s+=a[x][y];
        }
    }
    cout<<s;
    return 0;
}