水题不解释,思路是用map记录一下出现次数,数据也很水
#include <cstdio>
#include <map>
using namespace std;
int main()
{
int n;
map<int,int> present;
while( scanf("%d", &n) && n)
{
present.clear();
int m;
while(n--)
{
scanf("%d", &m);
if(!present.count(m))
present[m] = 1;
else
present[m]++;
}
for( map<int, int>::iterator i = present.begin(); i != present.end(); ++i)
if(i->second % 2)
{
printf("%d\n",i->first);
break;
}
}
return 0;
}