以下是代码。它只是从数组中删除一半的重复元素,而其他的则保留在那里。不知道是什么问题。需要帮助谢谢。删除数组中的重复项
int[] count_list = { 10, 20, 10, 30, 30, 40, 20, 50, 90, 60, 80, 70, 80, 90 };
int l = count_list.Length;
for (int i = 0; i < l; i++)
{
for (int j =i + 1; j < l;)
{
if(count_list[j] == count_list[i]){
for (int k = j; k < l; k++)
{
count_list[k] = count_list[k + 1] ;
l--;
}
}
else{
j++;
}
}
}
for (int i = 0; i < count_list.Length; i++)
{
Console.WriteLine(count_list[i]);
// Console.WriteLine("name");
}
可能重复(http://stackoverflow.com/questions/2055668/delete-duplicate-from-an-array) – atoMerz
这个问题没有显示出任何调试的证据努力。 –