#include<bits/stdc++.h>usingnamespace std;intmain(){int m, n, s =0;
cin >> n >> m;int a[n][m];//Look at me!
for(int i =1; i <= n; i++){for(int j =1; j <= m; j++){
cin >> a[i][j];if(i ==1|| i == n || j ==1|| j == m){
s = a[i][j]+ s;}}}
cout << s;return0;}
共 1 条回复
格式化代码:
其中注释有“look at me!“那一行不能用变量直接开数组,若要的的话可以用动态数组
当然如果你没学的话也可以用常量开
附上代码(用常量):