Uva 10370 Solution

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int n, i, j, s, m;
    double b, c, x, y, e;
    cout << showpoint;
    cout << fixed;
    cout << setprecision(3);
    while(cin >> n)
    {
        for(i=1;i<=n;i++)
        {
            cin >> m;
            e = m;
            int a[m];
            s = x = y = 0;
            for(j=0;j<m;j++)
            {
                cin >> a[j];
                s = s + a[j];
            }
            c = s/e;
            for(j=0;j<m;j++)
            {
                if(c<a[j])
                {
                    x++;
                }
            }
            b = 100/e;
            y = x * b;
            cout << y << "%" << endl;
        }
    }

    return 0;
}

Comments