public class Outzero {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] srcArray = {0,0,1,2,0,1,0,0,0,1,0,0,0,0,0,2,0,7,8,9,0,0,1,2,3,4};
int[] destArray = new int[50];
int i=0,j=0,count=0;
for(i=0;i<srcArray.length;){
count = 0;
if(srcArray[i]!=0){
destArray[j++] = srcArray[i];
i++;
}
else{
while(i<srcArray.length&&srcArray[i] == 0){
count++;
i++;
}
//就是凭计数
if(count<2)destArray[j++] = 0;
}
}
for(i=0;i<j;i++){
System.out.print(destArray[i]+" ");
}
}
}