題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=4593
題目很長,但有用的就那兩行,很水的有一道題目;
代碼如下:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n; int a[1001];
while(scanf("%d",&n)!=EOF)
{
memset(a,0,sizeof(a));
int x;
for(int i=0; i<n+1; i++)
{
scanf("%d",&x);
a[x]++;
}
for(int i=0; i<=n; i++)
{
if(a[i]==2)
printf("%d\n",i);
}
}
}