Computer Science, asked by Shubhangee6176, 11 months ago

Python program to reverse an array in groups of given size?

Answers

Answered by Ringku
0

what is the meaning of the question? not getting the meaning ....

Answered by sushiladevi4418
0

Answer:

Python program to reverse an array in groups of a given size.

Explanation:

#reverse of an array in groups of given size

def arrayreverse(A, n, p):

  i = 0  

  while(i<n):

     L = i  

     R = min(i + p - 1, n - 1)  

     while (L < R):

        A[L], A[R] = A[R], A[L]

        L+= 1;

        R-+1

     i+= p

     

#Insert data in an array

A=list()

n=int(input("Enter the size of the array ::"))

print("Enter the number ::")

for i in range(int(n)):

  k=int(input(""))

  A.append(int(k))

   

p=int(input("Enter the size of the group ::"))

arrayreverse(A, n, p)  

for i in range(0, n):

  print(A[i], end =" ")  

Similar questions