Position of a person diametrically opposite on a circle | C ++ implementation of the approach ; Function to return the required position ; 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 ; }