这是我的代码的一小部分,我正在打印在数组中找到的重复项。问题是它多次打印每个重复的事件。前任。数组 {1,2,3,4,5,6,7,8,9,0,2,2) 打印
value 2 at position 1 is also at position 10 value 2 at position 1 is also at position 11 value 2 at position 10 is also at position 11
而不仅仅是
value 2 at position 1 is also at position 10 value 2 at position 1 is also at position 11
for(i = 0; i < num_count; ++i){
for (j = i + 1; j < num_count; j++) {
if (num[i] == num[j]){
printf("\nvalue %d at position %d is also at position %d", num[i], i, j);
}
}
}