Find the vertex diagonally opposite to the vertex M from an N | C ++ program for the above approach ; Function to return the required vertex ; Case 1 : ; Case 2 : ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int getPosition ( int N , int M ) { if ( M > ( N / 2 ) ) { return ( M - ( N / 2 ) ) ; } return ( M + ( N / 2 ) ) ; } int main ( ) { int N = 8 , M = 5 ; cout << getPosition ( N , M ) ; return 0 ; }