Find the integer points ( x , y ) with Manhattan distance atleast N | C ++ code to Find the integer points ( x , y ) with Manhattan distance atleast N ; C ++ function to find all possible point ; Find all 4 corners of the square whose side length is n ; If n is even then the middle point of the square will be an integer , so we will take that point ; Driver Code ; Printing all possible points
#include <bits/stdc++.h> NEW_LINE using namespace std ; vector < pair < int , int > > FindPoints ( int n ) { vector < pair < int , int > > v ; v . push_back ( { 0 , 0 } ) ; v . push_back ( { 0 , n } ) ; v . push_back ( { n , 0 } ) ; v . push_back ( { n , n } ) ; if ( n % 2 == 0 ) v . push_back ( { n / 2 , n / 2 } ) ; return v ; } int main ( ) { int N = 8 ; vector < pair < int , int > > v = FindPoints ( N ) ; for ( auto i : v ) { cout << " ( " << i . first << " , ▁ " << i . second << " ) ▁ " ; } return 0 ; }