Sunday, April 24, 2016

UVA 11727: Cost Cutting -Solution

Unknown
#include<stdio.h>
int main ()
{
    int t,n=1,a,b,c,i,max,min,s,x,y;
    scanf("%d",&t);
    while (t--)
    {
        scanf("%d%d%d",&a,&b,&c);
        s=a+b+c;
        max=0;
        min=0;
        i=2;
        x=a;
        y=b;
        while (i--)
        {
            if (x<y) max=y;
            else max=x;
            x=max;
            y=c;
        }
        i=2;
        x=a;
        y=b;
        while (i--)
        {
            if (x<y) min=x;
            else min=y;
            x=min;
            y=c;
        }
        s=s-max-min;
        printf("Case %d: %d\n",n++,s);
    }
    return 0;
}

Unknown

Studying at Shahjalal University of Science and Technology, Sylhet.

0 comments:

Post a Comment

Coprights @ 2016,