scanf("%d", &m); //输入id for (int i = 0; i < m; ++i) { scanf("%d", id + i); }
//id按升序排 qsort(id, m, sizeof(int), cmp);
for (int i = 0; i < m; ++i) { //id未出现在pair中或未找到其伴侣 if (pair[id[i]] == NOT_FOUND || binarySearch(id, 0, m - 1, pair[id[i]]) == NOT_FOUND) { result[resultSize++] = id[i]; } }
//打印结果 printf("%d\n", resultSize); for (int i = 0; i < resultSize; ++i) { if (i) { printf(" "); } printf("%.5d", result[i]); } //resultSize为0时不打印换行,否则会有测试点过不去 if (resultSize) { printf("\n"); }