forked from dharmanshu1921/Daa-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2D_array.cpp
More file actions
46 lines (36 loc) · 828 Bytes
/
2D_array.cpp
File metadata and controls
46 lines (36 loc) · 828 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
40
41
42
43
44
45
46
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m;
cin>>n>>m;
int arr[n][m];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>arr[i][j];
}
}
cout<<"matrix is: \n";
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cout<<arr[i][j]<<" ";
}
}cout<<endl;
int x;
cin>>x;
bool flag=false;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(arr[i][j]==x){
cout<<i<<" "<<j<<endl;
flag = true;
}
if(flag){
cout<<"element is found"<<endl;
}
else{
cout<<"element is not found "<<endl;
}
}
}
return 0;
}