-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday3_array_searchIn2dMatrix.cpp
More file actions
39 lines (33 loc) · 949 Bytes
/
day3_array_searchIn2dMatrix.cpp
File metadata and controls
39 lines (33 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <bits/stdc++.h>
#include <vector>
using namespace std;
bool findTargetInMatrix(vector < vector < int >> & mat, int m, int n, int target) {
// Write your code here.
// int n = matrix.size(), m = matrix[0].size();
for (int i = 0; i <m; i++)
{
for (int j = 0; j <n; j++)
{
if(mat [i][j]==target) return true;
}
}
return false;
}
int main(){
int t;cin>>t;while(t--){
int n, m , target;
cin>>n>>m>>target;
vector<vector<int>> v(n, vector<int>(m));
for(int i =0; i<n;i++){
for(int j = 0 ; j<m;j++){
cin>> v[i][j];
}
cout<<endl;
}
vector<vector<int>> *vect;
vect = &v;
bool answer = findTargetInMatrix(*vect, n, m,target);
cout<< answer<<endl;
}
return 0;
}