2024_2
gorazd
c_cpp
a year ago
739 B
5
Indexable
2kolok_SP
#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++;
}
}
Editor is loading...
Leave a Comment