Sohila_Elshiref

Search In Matrix

Aug 3rd, 2021
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <iomanip>
  4. #include <cstdlib>
  5. #include <cmath>
  6. #include <string>
  7.  
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12.      //cout<<fixed<<setprecision(x);
  13.      int n,m,x;
  14.      bool check=false;
  15.      cin>>n>>m;
  16.      int arr[n][m];
  17.      for (int i=0;i<n;i++)
  18.      {
  19.          for (int j=0;j<m;j++)
  20.          {
  21.              cin>>arr[i][j];
  22.          }
  23.      }
  24.      cin>>x;
  25.      for (int k=n-1;k<n;k++)
  26.      {
  27.          for (int t=0;t<m;t++)
  28.          {
  29.              if (x==arr[k][t])
  30.              {
  31.                  check=true;
  32.              }
  33.          }
  34.      }
  35.      if (check==true)
  36.          {
  37.              cout<<"will not take number";
  38.          }
  39.     else
  40.     {
  41.         cout<<"will take number";
  42.     }
  43.  
  44.      return 0;
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment