今天群里以朋友问了我一道题,是南航的OJ,AC了顺便放上来。 题目地址: http://acm.njupt.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=1184 #include <stdio.h> long stamp[1000000]; long x; int main() { long n; int i; long max_x = 0; scanf("%ld", &n); for(i = 0; i < n-2; i++) { scanf("%ld", &x); if(max_x < x) max_x = x; if(stamp[x] == 0) stamp[x] = 1; else stamp[x] = 0; } int cnt = 0; for(i = 0; i <= max_x; i++) { if(stamp[i] && cnt == 0) { printf("%d ", i); cnt++; } else if(stamp[i] && cnt == 1) //第二个数后面还不能有空格,否则“描述错误” { printf("%d/n", i); cnt++; } if(cnt == 2) break; } return 0; }