http://acm.hdu.edu.cn/showproblem.php?pid=1563

找只出现一次的数,排个序处理下就行

View Code
#include <iostream>
#include <algorithm>
using namespace std ;
int main()
{
    int n;
    while(scanf("%d",&n),n)
    {
        int a[201];
        a[1]=a[n+1]=-1;
        for(int i=1;i<=n;i++)
            scanf("%d",&a[i]);
        sort(a+1,a+1+n);
        for(int i=1;i<=n;i++)
            if(a[i]!=a[i-1]&&a[i]!=a[i+1])
            {
                printf("%d\n",a[i]);
                break;
            }
    }
    return 0;
} 

 

相关文章:

  • 2021-07-02
  • 2022-12-23
  • 2021-05-05
  • 2021-07-02
  • 2021-09-08
  • 2022-12-23
  • 2021-11-01
  • 2021-08-16
猜你喜欢
  • 2022-12-23
  • 2022-01-09
  • 2021-06-29
  • 2021-10-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案