hdu 1259

http://acm.hdu.edu.cn/showproblem.php?pid=1259

无语了。。这题刚开始wa了一次,当时把每次变动之后J的位置都默认为2了,太2了。

代码如下:

#include"stdio.h"

int main( )
{
    int t,m,x,y,p;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&m);
        p=2;
        while(m--)
        {
            scanf("%d%d",&x,&y);
            if(x==p)//刚开始把p写成2了;
                p=y;
            else if(y==p)
                p=x;
        }
        printf("%d\n",p);
    }
    return 0;
}

 

posted @ 2012-05-14 04:08  朝圣の路  阅读(217)  评论(0编辑  收藏  举报