Answer to Question #264583 in Python for swsq

Question #264583
  1. Write a program to place even numbers first and next odd numbers program
1
Expert's answer
2021-11-15T00:19:51-0500
def rearrangeFunc(array, n) :
    j = -1
 
    for i in range(0, n) :
        if (array[i] % 2 == 0) :
            j = j + 1
 
            temp = array[i]
            array[i] = array[j]
            array[j] = temp

array = [ 12, 11, 1, 45, 17, 1, 10, 45, 14, 25, 8 ]
n = len(array)
rearrangeFunc(array, n)
 
for i in range(0,n) :
    print( array[i] ,end= " ")


12 10 14 8 17 1 11 45 1 25 45 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS