D
D
Deckers2022-02-24 17:48:49
C++ / C#
Deckers, 2022-02-24 17:48:49

Sum and product algorithms in diagrams, why is it always 0?

121.jpg
122.jpg

Am I missing something or what? Why is always 0 this is the 3rd similar task.

#include

int main()
{
int n = 4, A[n][n];

A[0][0] = 6;
A[0][1] = 0;
A[0][2] = 8;
A[0][3] = 9;

A[1][0] = 1;
A[1][1] = -1;
A[1][2] = 7;
A[1][3] = 6;

A[2][0] = 10;
A[2][1] = 2;
A[2][2] = -5;
A[2][3] = 7;

A[3][0] = -2;
A[3][1] = 4;
A[3][2] = -10;
A[3][3] = -4;

for (int i = 1; i < n; i++){
for (int j = 1; j < n; j++){
A[i][j];}}
int q = 0;
for (int i = 1; i < n - 1; i++){
for (int j = i + 1; j < n; j++){
if (A[i][j] < 0)
q = q + 1;}}

printf("Problem 6 - %d", q);
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question