HDU2095

作者: Amosasas | 来源:发表于2017-09-20 14:09 被阅读0次

    水题不解释,思路是用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;
    } 
    

    相关文章

      网友评论

          本文标题:HDU2095

          本文链接:https://www.haomeiwen.com/subject/clhosxtx.html