UVa 11727 - Cost Cutting

Contents

  1. 1. Problem
  2. 2. Solution
  3. 3. Code

Problem

中文網址

Solution

恩三種。

if 
else if 
else if

Code

UVa 11727
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include<cstdio>

int main()
{
int Case;
scanf("%d", &Case);
for (int c = 1; c <= Case; c++)
{
int x, y, z;
scanf("%d%d%d", &x, &y, &z);
printf("Case %d: ", c);
if ((x >= y&&x <= z) || (x >= z&&x <= y))
printf("%d\n", x);
else if ((y >= x&&y <= z) || (y >= z&&y <= x))
printf("%d\n", y);
else if ((z >= y&&z <= x) || (z >= x&&z <= y))
printf("%d\n", z);
}

return 0;
}