您现在的位置是:首页
>
删除数组中重复的数字 Java 删除数组中重复的元素
Java 删除数组中重复的元素 我是将数组封装为类的 其中方法说明 getmax(){ //计算数据个数 getData(i t i dex)得到i dex的元素 etData(i t i dex
Java 删除数组中重复的元素
我是将数组封装为类的 其中方法说明 getmax(){ //计算数据个数 getData(int index)得到index的元素 setData(int index int b)设置索引为index的元素值为b
public void noDup(){
//循环嵌套将重复的设为 int max = this getmax()
for(int i = i < max i ++){ for(int j = i +
j < max j ++ ){ if (this getData(i) == this getData(j)) { this setData(i ) }
}
//删除value为x的所有项public void dele(int x){ int i = int max = this getmax()

while(!(this getData(i) == )){ if (this getData(i) == x) { for(int j = i
j < max j ++){ this setData(j this getData(j + ))
}
lishixinzhi/Article/program/Java/hx/201311/26961 很赞哦! (1027)