日期:2014-05-17 浏览次数:20786 次
int[]a = new int[]{1,3,4,5,6,7,10} ; for(int i=0;i<a.length-1;i++){ for(int j=a[i]+1;j<a[i+1];j++){ System.out.print(j+" "); } }
------解决方案--------------------
public class test {
public static void main(String[] args) {
int[]a = new int[]{1,3,4,5,6,7,10} ;
for(int i=0;i<a.length;i++){
if(i<a.length-1){
if(a[i]<a[i+1]-1){
for (int j = a[i]+1; j < a[i+1]; j++) {
System.out.println(j);
}
}
}
}
}
}