//这题只是让你求给出的数的平均数即可!再通过续一比较,不够平均数的就从多于平均数中补上!
#include <iostream>
using namespace std;
int num[55];
int main()
{
int n, i, tc = 0, sum, avg, ans;
while (cin >> n)
{
if (n == 0) break;
tc++;
sum = ans = 0;
for (i = 0; i < n; i++)
{
cin >> num[i];
sum += num[i];
}
avg = sum / n;
for (i = 0; i < n; i++)
{
if (num[i] > avg)
ans += num[i] - avg;
}
cout << "Set #" << tc << endl << "The minimum number of moves is " << ans << "." << endl << endl;
}
system("pause");
}
poj 1477 Box of Bricks
最新推荐文章于 2016-06-01 23:14:38 发布