Monday, March 21, 2016

UVa 11727 - Cost Cutting

// UVa 11727 - Cost Cutting

#include <iostream>
using namespace std;

#define between(a,b,c) ((a <= b && b <= c) || (c<=b && b<=a))

int main() {
	int cases;
	cin >> cases;
	for (int i = 1; i <= cases; i++) {
		int a, b, c;
		cout << "Case " << i << ": ";
		cin >> a >> b >> c;
		if (between(a, b, c))
			cout << b;
		else if (between(a, c, b))
			cout << c;
		else
			cout << a;
		cout << endl;
	}
	return 0;
}

No comments:

Post a Comment