HDU 4593 Robot

題目鏈接: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);
        }
    }

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章