您的位置:首页 > 其它

zoj 3432 与运算运用

2015-01-29 11:37 363 查看
/****************************************************

该题充分运用与运算的特点,成对消除,单的最后留下

****************************************************/


#include <stdio.h>

#include <string.h>

#include <algorithm>

using namespace std;


int main()

{

char str1[10], str2[10];

int n;

while(~scanf("%d", &n) )

{

getchar();


gets(str1);

for(int i=0; i<2*n-2; i++)

	{

gets(str2);

for(int j=0; j<7; j++)

str1[j] = str1[j] ^ str2[j];				//两个字符串各自与运算,可以判定最后剩下的不成对的一个

}

printf("%s\n", str1);

}

}


/*

Description

Alice bought a lot of pairs of socks yesterday. But when she went home, she found that she has lost one of them. Each sock has a name which contains exactly 7 charaters.



Alice wants to know which sock she has lost. Maybe you can help her.


Input

There are multiple cases. The first line containing an integer n (1 <= n <= 1000000) indicates that Alice bought n pairs of socks. For the following 2*n-1 lines, each line is a string with 7 charaters indicating the name of the socks that Alice took back.


Output

The name of the lost sock.


Sample Input

2

aabcdef

bzyxwvu

bzyxwvu

4

aqwerty

eas fgh

aqwerty

easdfgh

easdfgh

aqwerty

aqwerty

2

0x0abcd

0ABCDEF

0x0abcd

Sample Output

aabcdef

eas fgh

0ABCDEF

*/

[/code]

来自为知笔记(Wiz)

附件列表

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: