package www.zhoushuiping02.com; |
public class DiErTi { |
public static void main(String[] args) { |
int a[] = { 1 , 1 , 3 , 3 , 5 , 6 , 7 , 7 }; |
for ( int i= 0 ;i<a.length;i++) { |
for ( int j= 0 ;j<a.length;j++) { |
if (a[j]==a[i]&&j!=i) { |
a[j]= 0 ; |
} |
} |
} |
int count = 0 ; |
for ( int i= 0 ;i<a.length;i++) { |
if (a[i]!= 0 ) { |
count++; |
} |
} |
int b[] = new int [count]; |
int j= 0 ; |
for ( int i= 0 ;i<a.length;i++) { |
if (a[i]!= 0 ) { |
while (j<b.length) { |
b[j] = a[i]; |
break ; |
} |
j++; |
} |
} |
System.out.println( "去重结果为:" ); |
for ( int i= 0 ;i<b.length;i++) { |
System.out.print(b[i]+ " " ); |
} |
} |
} |
初级程序员
by: 云代码会员 发表于:2018-11-30 14:22:29 顶(0) | 踩(0) 回复
这个循环是干嘛用的
回复评论