Check if a Rook can reach the given destination in a single move | C ++ program to implement for the above approach ; Function to check if it is possible to reach destination in a single move by a rook ; Driver Code ; Given arrays
#include <bits/stdc++.h> NEW_LINE using namespace std ; string check ( int current_row , int current_col , int destination_row , int destination_col ) { if ( current_row == destination_row ) return " POSSIBLE " ; else if ( current_col == destination_col ) return " POSSIBLE " ; else return " NOT ▁ POSSIBLE " ; } int main ( ) { int current_row = 8 ; int current_col = 8 ; int destination_row = 8 ; int destination_col = 4 ; string output = check ( current_row , current_col , destination_row , destination_col ) ; cout << output ; return 0 ; }