Untitled
unknown
c_cpp
5 years ago
837 B
6
Indexable
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int mat[n][n];
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
cin >> mat[i][j];
}
}
int zbir = 0;
for(int i = 0; i < n; i++) {
for(int j = n - i; j < n; j++) {
zbir += mat[i][j];
}
}
int proizvod = 1;
for(int i = 0; i < n; i++) {
for(int j = i + 1; j < n; j++) {
proizvod *= mat[i][j];
}
}
int nova_matrica[n][n];
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
nova_matrica[i][j] = zbir - proizvod;
}
}
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
cout << nova_matrica[i][j] << " ";
}
cout << endl;
}
return 0;
}
Editor is loading...