a= [1, 2, 2, 2, 3, 3, 4, 4, 5, 6];
b= [];
for(x=0;x<a.length;x++){
s=0;
for(y=0;y<b.length;y++){
if(a[x]==b[y]){
s=1;
}
}
if(s==0){
b.push(a[x]);
}
}
for(z in b){
document.write(b[z])
}
a=[2,5,8,9,6,3,4,7,1];
for(x=0;x<a.length;x++){
for(y=x+1;y<a.length;y++){
if(a[x]>a[y]){
s=a[x];
a[x]=a[y];
a[y]=s;
}
}
} for(z in a){
document.write(a[z]);
}
轉載于:https://www.cnblogs.com/m110/p/7593552.html