Maximum count of equal numbers in an array after performing given operations | CPP program to find the maximum number of equal numbers in an array ; Function to find the maximum number of equal numbers in an array ; to store sum of elements ; if sum of numbers is not divisible by n ; Driver Code ; size of an array
#include <bits/stdc++.h> NEW_LINE using namespace std ; int EqualNumbers ( int a [ ] , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += a [ i ] ; if ( sum % n ) return n - 1 ; return n ; } int main ( ) { int a [ ] = { 1 , 4 , 1 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << EqualNumbers ( a , n ) ; return 0 ; }