Thursday, 10 May 2012

UVa 11727 Cost Cutting Solution


#include<stdio.h>
int main()
{
int a,b,c,d,ans,j;
while(scanf("%d",&d)==1)
{
for(j=1;j<=d;j++)
{
scanf("%d%d%d",&a,&b,&c);
if(a>b && b>c || a<b && b<c)
ans=b;
if(a>c && c>b || a<c && c<b)
ans=c;
if(b>a && a>c || b<a && a<c)
ans=a;
printf("Case %d: %d\n",j,ans);
}
}
return 0;
}

2 comments:

  1. http://uvasolutionseam.blogspot.com/2016/08/uva-424-integer-inquiry.html

    ReplyDelete
  2. #include
    int main()
    {
    int T,i,a,b,c;
    scanf("%d",&T);
    for(i=1;i<=T;i++)
    {

    scanf("%d %d %d",&a,&b,&c);
    printf("Case %d: ",i);
    if(a>b&&a>c)
    {
    if(b>c)
    printf("%d\n",b);
    else
    printf("%d\n",c);
    }
    else if(b>c&&b>a)
    {
    if(c>a)
    printf("%d\n",c);
    else
    printf("%d\n",
    a);

    }
    else
    {
    if(a>b)
    printf("%d\n",a);
    else
    printf("%d\n",b);
    }
    }
    return 0;
    }

    ReplyDelete