还漏了一个判断条件:
public void noDup(){
int i;
int j;
for (i = 0; i < nElems; i++)
for (j = 0; j < nElems; j++){
if (i == j){
continue;
}
else if (a[i] == a[j]){
if (i == (nElems - 1)){
nElems--;
}
a[j] = a[--nElems];
}
}
}
这样缩进应该容易看一点:
public void noDup() {
int i,j;
for (i = 0; i < nElems; i++)
for (j = 0; j < nElems; j++) {
if (i == j) {
continue;
} else if (a[i] == a[j]) {
a[j] = a[--nElems];
}
}
}