Help me fix the errors. Problem: For a given 8 by 8 matrix, find k such that the k-th row of the matrix coincides with the k-th column. Find the sum of the elements in those lines that contain at least one negative element. Help me fix errors

#include <iostream> #include <conio.h> #include <ctime> #include <stdlib.h> #include <iomanip> using namespace std; int main() { srand(time(0)); int A[8][8],k,i,j,S=0,z; for (i=0;i<8;i++) { for ( j=0;j<8;j++) { A[i][j]=rand()%20-5; } } for (i=0;i<8;i++) for (j=0;j<8;j++) { cout<<setw(8) <<A[i][j]<<" "; } for (i=0;i<k;i++) { k=0; for (j=0;j<k;j++) if(A[i][j]==A[j][i]) k++; if(k==3) cout<<"k="<<i; } for (i=0;i<8;i++) { for (j=0;j<8;j++) { if(A[i][j]<0) { S+=A[i][j]; } } cout<<"\nSuma elementov v "<<i+1<<" = "<<S<<endl; S=0; } getch (); return 0; } 
  • what is the specific problem, give your attempt to solve the problem. - pavel
  • "find k such that the k-th row of the matrix is ​​the same as the k-th column" - I can not understand what is being asked of me - noob
  • Apparently write the source code of the program. Submit your solution. We'll see. - Yaroslav
  • well formally: print K | A x: m [k] [x] = m [x] [k] - pavel
  • @Yaroslav Added by - noob

1 answer 1

The task was a person who can not work as a teacher. This means that the sequence of elements that make up a column (from top to bottom) coincides with the sequence of elements that make up a row (from left to right). So, if the first row in a similar way coincides with the first column, then k=1 . If the second with the second, then k=2 , etc. Find all such values ​​of k .

It is assumed that the matrix is ​​numeric, perhaps even from integers.

Example

 1 2 3 4 5 6 7 8 2 3 4 5 6 7 8 9 3 4 0 4 5 3 3 1 4 5 3 4 6 4 3 2 5 6 3 6 5 7 6 2 6 7 2 5 6 6 5 3 7 8 3 4 1 6 2 1 8 9 1 2 2 3 1 5 

k = 1, 2, 8 (if the count goes from 1, not from zero).

The answer to the second question is zero.

  • But the matrix may contain negative numbers, then the second question is to look for the amount in the row - MaximK
  • The second question is a separate item, the author simply blinded them into one and did not understand a bit) - wirtwelt