Computer Science, asked by veerasaimattapalli, 2 months ago

Write a program to shift all the zero present in the array in the alternative order, For example.

Input array: -

1 208 5006

Output array: -

10280506​

Answers

Answered by nikhilkumarsaha27
5

Answer:

  • int A[] = { 6, 0, 8, 2, 3, 0, 4, 0, 1 };
  • int n = sizeof(A) / sizeof(A[0]);
  • reorder(A, n);
  • for (int i = 0; i < n; i++) {
  • printf("%d ", A[i]);
  • }
  • return 0;
  • }
Answered by vishakasaxenasl
0

Answer:

Below Python program will shift all the  zero present in the array in the alternative order. Just copy and paste the code in any Python IDLE and see the output.

Explanation:

arr = list(map(int,input().split(",')) #Enter comma-seperated input

n = len(arr)

for i in range(n):

 if(arr[i]==0):

    arr[i], arr[i-1] = arr[i-1] , arr[i]

print(arr)

OUTPUT:

Input array: -

1 208 5006

Output array: -

10280506​

#SPJ3

Similar questions