Delete array zero element
/**
* Read n integers from the keyboard into the array, write the CompactIntegers function, and delete all the elements whose values are 0 in the array.
* Output the number of elements in the deleted array and output the array elements in sequence.
*/
Import java. util .*;
Import java. io .*;
Public class deletes array zero elements {
Public static int Sum (int arr [], int n ){
Int sum = 0;
For (int I = 0; I <arr. length; I ++ ){
If (arr [I]! = 0)
Sum ++;
}
Return sum;
}
Public static void main (String [] args ){
Vertex in = new vertex (new BufferedInputStream (System. in ));
Int n = in. nextInt ();
Int [] arr = new int [n];
For (int I = 0; I <arr. length; I ++ ){
Arr [I] = in. nextInt ();
}
Int m = Sum (arr, n );
System. out. println (m );
Int [] arr1 = new int [n];
For (int I = 0; I <arr. length; I ++ ){
If (arr [I]! = 0 ){
Arr1 [I] = arr [I];
}
}
For (int I = 0; I <n; I ++ ){
If (arr1 [I]! = 0)
System. out. print (arr1 [I] + "");
}
System. out. println ();
}
}