2024_2
#include <iostream> #include <cctype> #include <cstring> #include <iomanip> using namespace std; int main() { int m,n; cin>>m>>n; int arr[m][n]; //input array for(int i=0;i<m;i++) { for(int j=0;j<n;j++) { cin>>arr[i][j]; } } int k = 2; while(k<=m and k<=n) { int sum=0; for(int i = 0; i<k; i++) { for(int j=0;j<k;j++) { if(i==0 and j < k-1) sum+=arr[i][j]; if(i == k-1 and j > 0) sum+=arr[i][j]; if(i+j == k-1) sum+=arr[i][j]; } } cout<<sum<<endl; k++; } }
Leave a Comment