3-10 盒子 UVa1587

#include 
#include 
#include 
using namespace std;

struct box{
	int x, y;
	bool operator==(const box& rhs) // 操作运算符重载
	{
		return(x == rhs.x) && (y == rhs.y);
	}
}a[6];
int main()
{
	for (int i = 0; i < 6; i++)
	{
		cin >> a[i].x >> a[i].y;
		if (a[i].x < a[i].y)
			swap(a[i].x, a[i].y);
	}
	for (int i = 0; i < 6; i++)
	{
		for (int j = 0; j < 5 - i; j++)
			if (a[j].x < a[j + 1].x)
				swap(a[j], a[j + 1]);
			else
			{
				if (a[j].x == a[j + 1].x&&a[j].y < a[j + 1].y)
					swap(a[j], a[j + 1]);
			}
	}
	bool s = 0;
	if (a[0] == a[1] && a[2] == a[3] && a[4] == a[5])
	{
		if (a[0].x == a[2].x && a[2].y == a[4].y && a[0].y == a[4].x)
			s = 1;
	}
	cout << s << endl;

	return 0;
}

你可能感兴趣的:(C++,算法竞赛入门第三章习题)