-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray64.cpp
39 lines (37 loc) · 914 Bytes
/
array64.cpp
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 <iostream>
using namespace std;
int main(){
int n;
int a[3][3];
int flag=0;
cin>>n;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
cin>>a[i][j];
}
}
for(int i=0;i<3;i++){
if(a[i][0]==n && a[i][1]==n && a[i][2]==n){
cout<<"All "<<n<<"'s on row "<<i<<endl;
flag=1;
}
}
for(int i=0;i<3;i++){
if(a[0][i]==n && a[1][i]==n && a[2][i]==n){
cout<<"All "<<n<<"'s on column "<<i<<endl;
flag=1;
}
}
if(a[0][0]==n && a[1][1]==n && a[2][2]==n){
cout<<"All "<<n<<"'s on diagonal"<<endl;
flag=1;
}
if(a[2][0]==n && a[1][1]==n && a[0][2]==n){
cout<<"All "<<n<<"'s on subdiagonal"<<endl;
flag=1;
}
if(flag==0){
cout<<"There is no line with all "<<n<<endl;
}
return 0;
}