Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <string>
- #include <vector>
- using namespace std;
- int main() {
- int n, el;
- cin >> n;
- cin.ignore();
- string line;
- vector<vector<int>> matrix1;
- for (int i = 0; i < n; i++) {
- vector<int> row;
- getline(cin, line);
- istringstream ss(line);
- while (ss >> el) {
- row.push_back(el);
- }
- matrix1.push_back(row);
- }
- int n2, el2;
- cin >> n2;
- cin.ignore();
- string line2;
- vector<vector<int>> matrix2;
- for (int i = 0; i < n2; i++) {
- vector<int> row;
- getline(cin, line2);
- istringstream ss(line2);
- while (ss >> el2) {
- row.push_back(el2);
- }
- matrix2.push_back(row);
- }
- bool isequal = true;
- if (matrix1.size() != matrix2.size()) {
- isequal = false;
- }
- else {
- for (int i = 0; i < matrix1.size(); i++) {
- if (matrix1[i].size() != matrix2[i].size()) {
- isequal = false;
- }
- else {
- for (int j = 0; j < matrix1[i].size(); j++) {
- if (matrix1[i][j] != matrix2[i][j]) {
- isequal = false;
- break;
- }
- }
- }
- if (!isequal) {
- break;
- }
- }
- }
- cout << (isequal ? "equal" : "not equal") << endl;
- return 0;
- }
- Tarikat edition - don't do this at work:)
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- int main() {
- int n, n2;
- cin >> n;
- cin.ignore();
- string line;
- vector<string> matrix1;
- for (int i = 0; i < n; i++) {
- getline(cin, line);
- matrix1.push_back(line);
- }
- cin >> n2;
- cin.ignore();
- if (n != n2) {
- cout << "not ";
- }
- else {
- for (int i = 0; i < matrix1.size(); i++) {
- getline(cin, line);
- if (matrix1[i] != line) {
- cout << "not ";
- break;
- }
- }
- }
- cout << "equal" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement