HDU1259

在这里插入图片描述

嘿嘿嘿,每日水题我是水题怪qwq
这道题哈哈哈哈我是模拟做的,
开一个判断用的bool值数组,
J所在的位置就是true,其余均为false
然后捏,
就是根据题目意思来啦
直接康代码吧!

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
	bool st[8];
	int n,m,x,y;
	scanf("%d",&n);
	while(n--)
	{	
		memset(st,false,sizeof(st));
		st[2]=true;
		scanf("%d",&m);
		for(int i=0;i<m;i++)
		{
			scanf("%d%d",&x,&y);
			if(st[x])
			{
				st[x]=false;
				st[y]=true;
			}
			else if(st[y])
			{
				st[y]=false;
				st[x]=true;
			}
			else
				continue;
		}
		int flag=0;
		for(int i=1;i<=7;i++)
		{
			if(st[i])
			{
				flag=i;
				break;
			}
		}
		printf("%d\n",flag);
	}
	return 0;
}

这题做的舒服

发布了54 篇原创文章 · 获赞 4 · 访问量 898

猜你喜欢

转载自blog.csdn.net/weixin_45460987/article/details/103301300