Make A , B and C equal by adding total value N to them | C ++ program to distribute integer N among A , B , C such that they become equal ; Find maximum among the three elements ; Summation of three elements ; Check if difference is divisible by 3 ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void distributeN ( int A , int B , int C , int n ) { int max1 = max ( A , B ) ; int max2 = max ( B , C ) ; int maximum = max ( max1 , max2 ) ; int sum = A + B + C ; int p = ( 3 * maximum ) - sum ; int diff = n - p ; if ( diff < 0 diff % 3 ) cout << " No " ; else cout << " Yes " ; } int main ( ) { int A = 10 , B = 20 ; int C = 15 , n = 14 ; distributeN ( A , B , C , n ) ; return 0 ; }