djelad1

Untitled

Dec 11th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. const int SIZE = 3;
  4. bool equalMatrix(int matrix[SIZE][SIZE]);
  5. void main()
  6. {
  7. int matrix[SIZE][SIZE], i = 0, j = 0, result = 0;
  8. bool isEqualMatrix = true;
  9. cout << "please enter " << SIZE << " * " << SIZE << endl;
  10. for (i = 0; i < SIZE; i++)
  11. {
  12. for (j = 0; j < SIZE; j++)
  13. cin >> matrix[i][j];
  14. }
  15. result = equalMatrix(matrix);
  16. cout << "your matrix is " << result << endl;
  17.  
  18. system("pause");
  19. }
  20.  
  21. bool equalMatrix(int matrix[][SIZE])
  22. {
  23. int i = 0, j = 0, sum = 0;
  24.  
  25. for (i = 0; i < SIZE; i++)
  26. {
  27. sum = 0;
  28. for (j = 0; j < SIZE; j++)
  29. {
  30. sum += matrix[i][j];
  31. }
  32.  
  33. for (j = 0; j < SIZE; i++)
  34. {
  35. sum -= matrix[j][i];
  36. }
  37.  
  38. if (sum != 0)
  39. return false;
  40. }
  41. return true;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment