去除数组中重复项的步骤

去除数组中重复项的步骤

下面是三种实现的方式!
//c#代码
private void RemoveRepeat()
{
int x=0;
int label;
int[] b = new int[15];
int[] a =new int[15]{1,0,3,3,0,5,5,6,4,8,9,2,9,5,1};
for (int i=0;i<a.Length;i++)
{
label=0;//标记是否有相同项
for(int j=0;j<x;j++)
{
if(b[j]==a[i])
label=1;
 
}
if(label==0)
{
b[x]=a[i];
x++;
}
}
for(int k=0;k<x;k++)
{
Response.Write(b[k]);//输出数组b[]
if(k!=x-1)
Response.Write(",");
}
}
//第一种字符型javascript代码
function RemoveRepeat()
{
var tmp = new Array()
var a =new Array("AAAA","B","A","A","B","F","D","C","A","B","A","A","B","C","t")
tmp=a
for (var i=0;i<a.length;i++)
{
for(j=i+1;j<a.length;j++)
{
if(a[i]==a[j]) tmp[i]=null
}
}
var m = 0,ok = new Array()
for(k=0;k<tmp.length;k++)
{
if(tmp[k])
ok[m++] = tmp[k]
}
alert(ok)
}
//第二种数字型javascript代码
function ddd()
{
oldArray = [1,2,1,3,3,4,5,5,6,7,2,2,9,8,9]
var str = oldArray.join(" ");
var reg = /([^ ]+)(.*) /1/g; //利用正则表达式
while(str.match(reg))str=str.replace(reg,"$1$2")
alert(str.split(" "));
}