Advertisement
Spocoman

02. Positions Of

Jan 27th, 2024
938
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int row, col, num;
  8.     cin >> row >> col;
  9.  
  10.     vector<vector<int>> matrix;
  11.  
  12.     for (int i = 0; i < row; i++) {
  13.         vector<int> currentRow;
  14.         for (int j = 0; j < col; j++) {
  15.             cin >> num;
  16.             currentRow.push_back(num);
  17.         }
  18.         matrix.push_back(currentRow);
  19.     }
  20.  
  21.     cin >> num;
  22.     bool isfound = false;
  23.  
  24.     for (int i = 0; i < row; i++) {
  25.         for (int j = 0; j < col; j++) {
  26.             if (matrix[i][j] == num) {
  27.                 cout << i << ' ' << j << endl;
  28.                 isfound = true;
  29.             }
  30.         }
  31.     }
  32.  
  33.     if (!isfound) {
  34.         cout << "not found" << endl;
  35.     }
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement