djelad1

Untitled

Dec 11th, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. const int SIZE = 3;
  4. int equalMatrix(int matrix[SIZE][SIZE],int 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.  
  16. int equalMatrix(int matrix[SIZE][SIZE], int size);
  17. cout << "your matrix is " << isEqualMatrix << endl;
  18.  
  19. system("pause");
  20. }
  21.  
  22. int equalMatrix(int matrix[SIZE][SIZE], int size)
  23. {
  24. bool isEqualMatrix = true, i = 0, j = 0, sum1 = 0, sum2 = 0;
  25.  
  26. for (i = 0; i < SIZE && isEqualMatrix; i++,j++, sum1 = 0, sum2 = 0)
  27. {
  28. for (j = 0; j < SIZE; j++)
  29. {
  30. sum1 += matrix[i][j];
  31. }
  32. for (j = 0; j < SIZE; i++)
  33. {
  34. sum2 += matrix[i][j];
  35. }
  36.  
  37. if (sum1 != sum2)
  38. isEqualMatrix = false;
  39. }
  40. return isEqualMatrix;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment