# Problem 25

### 18 comments on “Problem 25”

• samba

import java.util.Scanner;
class zerolast
{
public static void main(String[] args)
{
int a[]={1, 6, 7, 4, 0, 3, 0, 2, 7, 0, 6, 0, 9};
int n=a.length;
for(int i=0;i<n;i++)
{
if(a[i]==0)
{
for(int j=i;j<n-2;j++)
{
a[j]=a[j+1];
}
a[n-1]=0;
}

}
for(int i=0;i<a.length;i++)
System.out.println(a[i]);
}
}

• Pallipattu

n=list(map(int,input().split()))
a=[]
for i in n:
if i ==0:
a.append(i)
n.remove(i)
print(n+a)

• Kritika

l1=[1,3,6,0,3,54,76,0,3,5,0]

l2=[]

for i in l1:
if i == 0:
l2.append(i)
l1.remove(i)

for item in l2:
l1.append(item)

print(l1)

• shushank

#Python
l=list(map(int,input().split(” “)))
c=0
l1=[]
for i in range(len(l)):
if l[i]==0:
c+=1
else:
l1.append(l[i])
for i in range(c):
l1.append(0)
print(*l1)

• amit

int main()
{
int arr[20];
int arr2[20];
int bound,k=0;
scanf(“%d”,&bound);
for(int i=0;i<bound;i++)
scanf("%d",&arr[i]);
for(int j=0;j<bound;j++){
if(arr[j]!=0){
printf("%d",arr[j]);
k++;
}
}
for(int i=0;i<bound-k;i++)
printf("%d",0);
}