Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- const int SIZE = 3;
- int equalMatrix(int matrix[SIZE][SIZE]);
- void main()
- {
- int matrix[SIZE][SIZE], i = 0, j = 0, result = 0;
- bool isEqualMatrix = true;
- cout << "please enter " << SIZE << " * " << SIZE << endl;
- for (i = 0; i < SIZE; i++)
- {
- for (j = 0; j < SIZE; j++)
- cin >> matrix[i][j];
- }
- result = equalMatrix(matrix);
- cout << "your matrix is " << result << endl;
- system("pause");
- }
- int equalMatrix(int matrix[SIZE][SIZE])
- {
- bool isEqualMatrix = true, i = 0, j = 0, sum1 = 0, sum2 = 0;
- for (i = 0; i < SIZE && isEqualMatrix; i++, j++, sum1 = 0, sum2 = 0)
- {
- for (j = 0; j < SIZE; j++)
- {
- sum1 += matrix[i][j];
- }
- for (j = 0; j < SIZE; i++)
- {
- sum2 += matrix[j][i];
- }
- if (sum1 != sum2)
- isEqualMatrix = false;
- }
- return isEqualMatrix;
- }
Advertisement
Add Comment
Please, Sign In to add comment