Uva 11777 Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, i;
    double a[7], b, c, d, e, f;

    while(cin >> n)
    {
        for(i=1;i<=n;i++)
        {
            b = c = d = e = f = 0;

            cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5] >> a[6];

            b = a[4];
            d = a[5];
            e = a[6];

            if(b < d)
                swap(b, d);
            if(d < e)
                swap(d, e);

            f = (b+d)/2;

            c = a[0] + a[1] + a[2] + a[3] + f;

            cout << "Case " << i << ": ";

            if(c >= 90)
                cout << "A" << endl;
            else if(c>=80 && c < 90)
                cout << "B" << endl;
            else if(c>=70 && c < 80)
                cout << "C" << endl;
            else if(c>=60 && c< 70)
                cout << "D" << endl;
            else if(c<60)
                cout << "F" << endl;

        }

    }

    return 0;
}

Comments