Problem 25

14 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]);
    }
    }