U E D R , A S I H C RSS

The Trip/허아영

No older revisions available

No older revisions available



~cpp
//TheTrip 10137
#include <iostream>
using namespace std;
#include <math.h>

double rounding(double num)
{
	
	return num;
}
int main()
{
	int n;
	int i;
	double *cost, sum, gap, avg;
	while(cin >> n)
	{	
		if(n == 0)
			break;
		cost = new double[n];
		
		sum = 0.0;
		gap = 0.0;
		avg = 0.0;
		for(i = 0; i < n; i++)
			cin >> cost[i];
		
		for(i = 0; i < n; i++)
		{
			sum += cost[i];
		}
		//평균 구하기
		avg = sum/(double)n;
		avg = ceil(avg);
		for(i = 0; i < n; i++)
		{	
			if(avg > cost[i])
				gap = gap + (avg - cost[i]);
			else
				gap = gap + (cost[i] - avg);
		}
		
		cout << "$" << (double)gap/2.00 << endl;
	}
	
	
	return 0;
}
- 미완성
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2009-05-27 07:09:19
Processing time 0.0122 sec