杭电acm1029
#include <stdio.h> #include <string.h> int main() { int n, i, temp, max, flag, id; int book[1000000]; while(~scanf("%d", &n)) { memset(book, 0, sizeof(book)); max = -1; flag = 0; id = -1; for(i=0; i<n; i++) { scanf("%d", &temp); book[temp] ++; if(id<temp) id = temp; } for(i=0; i<=id; i++) { if(max<book[i]) { max = book[i]; flag = i; } } printf("%d\n", flag); } return 0; }