int a[] = {2, 3, 5, 6, 6, 6, 5, 2};
int t = 0;
for (int i = 0; i < 8 - 1; i++) {
for (int j = i+1; j < 8; j++) {
if (a[i] != -1) {
if (a[i] == a[j]) {
t++;
a[j] = -1;
}
}
}
if (t > 0) {
printf("%d ",a[i]);
t = 0;
a[i] = -1;
}
}
转载于:https://my.oschina.net/zhangjie9142/blog/496432