modify the array

write a program where an array of integers, e.g.{10203004567000} is given, you have to create a new array which will be like (12345670000000}, without using any other temporary array.

Comments

  1. int main()
    {
    int [] array = {0,0,2,0,3,0,0,4,5,6,7,0,0,8};

    int hole = 0;
    for (int j = 0; j < array.Length; j++)
    {
    if (array[j] != 0)
    {
    array[hole++] = array[j];
    array[j] = 0;
    }
    }
    }

    ReplyDelete

Post a Comment

Popular posts from this blog