zoj 3432 Find the Lost Sock

/*
zoj_3432
为异或量身定做的题。
异或满足结合律和交换律,则有A^B^A = A^(B^A) = A^A^B = B
所以所有字符串异或的结果就是答案了。
*/
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;

int main()
{
    int i,j,n;
    string a,b;
    while( cin>>n )
    {
        cin.get();
        getline(cin,a);
        for( i=1;i<2*n-1;i++ )
        {
            getline(cin,b);
            for( j=0;j<7;j++ )
                a[j]=a[j]^b[j];
        }
        cout<<a<<endl;
    }
    return 0;
}

你可能感兴趣的:(zoj 3432 Find the Lost Sock)