Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <string>
- #include <memory>
- using namespace std;
- unique_ptr<unique_ptr<int[]>[]> matrixFiller(const int& c) {
- int r;
- cin >> r;
- cin.ignore();
- unique_ptr<unique_ptr<int[]>[]> m = make_unique<unique_ptr<int[]>[]>(r);
- string line;
- for (int row = 0; row < r; row++) {
- m[row] = make_unique<int[]>(c);
- getline(cin, line);
- istringstream ss(line);
- int num;
- for (int col = 0; col < c; col++) {
- m[row][col] = ss >> num ? num : 0;
- }
- }
- return m;
- }
- bool areEqual(const unique_ptr<unique_ptr<int[]>[]>& a,
- const unique_ptr<unique_ptr<int[]>[]>& b, const int& c) {
- for (int row = 0; row < sizeof(a) / 4; row++) {
- for (int col = 0; col < c; col++) {
- if (a[row][col] != b[row][col]) {
- return false;
- }
- }
- }
- return true;
- }
- int main() {
- int c = 10;
- unique_ptr<unique_ptr<int[]>[]> matrix1 = matrixFiller(c), matrix2 = matrixFiller(c);
- cout << (areEqual(matrix1, matrix2, c) ? "equal" : "not equal") << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement