fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6. int a,arr[50], t = 0;
  7. while (cin >> a && a != 0){
  8.  
  9. int avr = 0;
  10. for (int i = 0; i < a ; i++){
  11.  
  12. cin >> arr[i];
  13. avr += arr[i];
  14. }
  15. avr /= a;
  16. int ans = 0;
  17. for (int i = 0; i < a; i++){
  18.  
  19. if (arr[i] > avr){
  20. ans += (arr[i] - avr);
  21. }
  22. }
  23. cout << "Set #" << ++t << "\n";
  24. cout << "the minimum number of moves is "<< ans << "." << "\n";
  25. cout << "\n";
  26. }
  27.  
  28.  
  29. }
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
Success #stdin #stdout 0s 5284KB
stdin
6
5 2 4 1 7 5
0
stdout
Set #1
the minimum number of moves is 5.