N Queen Problem C++ program Code check if attack or not attack .
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#include<bits/stdc++.h> using namespace std; int main() { int a[100][100]; int x1,y1,x2,y2; cout<<"Enter Queen pos: "; cin>>x1>>y1; cout<<"Enter new Queen pos: "; cin>>x2>>y2; if(x1==x2||y1==y2||(x1+y1)==(x2+y2)||(x1-y1)==(x2-y2) ) cout<<"Attack the other queen"<<endl; else cout<<"Does not attack"<<endl; return 0; } |