标签:can ret http algo div == highlight present algorithm
问题描述:
源码:
#include"iostream" #include"algorithm" using namespace std; bool cmp(int a, int b) { return a < b; } int main() { int n, result; int *p; while(true) { scanf("%d", &n); if(n == 0)break; p = new int[n]; for(int i = 0; i < n; i++) { scanf("%d", p+i); } sort(p, p+n, cmp); result = p[0]; if(n > 1) { // if(p[0] != p[1]) // { // result = p[0]; // } for(int i = 1; i < n - 1; i++) { if(p[i - 1] != p[i] && p[i] != p[i+1]) { result = p[i]; break; } } if(p[n - 2] != p[n - 1]) { result = p[n - 1]; } } cout<<result<<endl; } return 0; }
HD-ACM算法专攻系列(14)——find your present (2)
标签:can ret http algo div == highlight present algorithm
原文地址:http://www.cnblogs.com/forcheng/p/7634890.html