Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- int main()
- {
- using namespace std;
- int num_to_find;
- cin >> num_to_find;
- int row_number, col_number;
- cin >> row_number >> col_number;
- vector<vector<int>> matrix;
- for (int row = 0; row < row_number; ++row)
- {
- vector<int> matrix_row;
- for (int col = 0; col < col_number; ++col)
- {
- int n;
- cin >> n;
- matrix_row.push_back(n);
- }
- matrix.push_back(matrix_row);
- }
- bool found = false;
- for (int row = 0; row < row_number; ++row)
- for (int col = 0; col < col_number; ++col)
- if (matrix[row][col] == num_to_find)
- {
- cout << row << col << endl;
- found = true;
- }
- if (!found)
- cout << "Number not found\n";
- return 0;
- }
- //#include <iostream>
- //#include <vector>
- //int main()
- //{
- // using namespace std;
- //
- // int num_to_find;
- // cin >> num_to_find;
- //
- // int rows, cols;
- // cin >> rows >> cols;
- //
- // vector<int> matrix;
- // for (int i = 0; i < rows * cols; ++i)
- // {
- // int n;
- // cin >> n;
- // matrix.push_back(n);
- // }
- //
- // bool found = false;
- // for (int i = 0; i < matrix.size(); ++i)
- // if (matrix[i] == num_to_find)
- // {
- // int row = i / cols, col = i % cols;
- // cout << row << col << endl;
- // found = true;
- // }
- //
- // if (!found)
- // cout << "Number not found\n";
- //
- // return 0;
- //}
Advertisement
Add Comment
Please, Sign In to add comment