快速查找数组中重复值
时间:2010-11-18 来源:emmy
public static void chaozaoxiantong()
{
int[] a = new int[] { 12, 23, 18, 15, 12 };
ArrayList al = new ArrayList();
// int n=0;
for (int i = 0; i < a.Length - 1; i++)
{
for (int p = 0; p < a.Length - 1 - i; p++)
{
if (a[i] != a[i + 1])
{
int num = a[i];
if (!al.Contains(num))
{
al.Add(a[i]);
}
// al[i]=a[i];
}
}
}
for (int y = 0; y < al.Count; y++)
{
Console.WriteLine("重复的数据:{0}", al[y]);
}
Console.WriteLine("数组大小:{0}", a.Length);
}
相关阅读 更多 +