HDU 1259(ZJUTACM)

基础题。

#include <iostream>
using namespace std;

int main()
{
	int N;
	cin >> N;
	int M;
	int x, y; //交换的位置
	int pos; //字母J的位置
	while (N--)
	{
		pos = 2;
		cin >> M;
		for (int i = 0; i < M; i++)
		{
			cin >> x >> y;
			if (x == pos)
				pos = y;
			else if (y == pos)
				pos = x;
		}
		cout << pos << endl;
	}
	return 0;
}

继续加油。

发布了206 篇原创文章 · 获赞 1 · 访问量 9004

猜你喜欢

转载自blog.csdn.net/Intelligence1028/article/details/104780575
hdu