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.
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.
The name of the lost sock.
#include<iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int a[8][156];int main(){ int n,i,j; char s[8]; while(~scanf("%d",&n)) { memset(a,0,sizeof(a)); for(i=0;i<(2*n)-1;i++) { scanf("%s",s); for(j=0;j<7;j++) { a[j][s[j]]++;//j代表第几位,a[i][j]表示的是第几位的字符出现次数 } } for(i=0;i<7;i++) { for(j=0;j<156;j++) { if(a[i][j]%2==1)//遍历输出就可以了 { PRintf("%c",j); break; } } } printf("/n"); } return 0;}
新闻热点
疑难解答