text: Find the player to be able to replace the last element that can be replaced by its divisors | C ++ program for the above approach ; Function to find the winner of the game played based on given conditions ; A wins if size of array is odd ; Otherwise , B wins ; Driver Code ; Input array ; Size of the array
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; void winner ( int arr [ ] , int N ) { if ( N % 2 == 1 ) { cout << " A " ; } else { cout << " B " ; } } int main ( ) { int arr [ ] = { 24 , 45 , 45 , 24 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; winner ( arr , N ) ; }