admin@onlinelearningcenter.in (+91) 7 999 01 02 03

Alternate positive and negative numbers

Kopal Jaiswal
392 Posts

WAP to rearrange and array with positive and negative numbers in an alternate way.

Example 1:

Input:

arr[]={-3,-5,-9,1,2,6,7,-9,45,-65}

 Output:

{-3,1,-5,2,-9,6,-9,7,45,-65}

 Example 2:

Input:

arr[]={-3,-5,-9,1,2,6,7,9,45,65}

 Output:

{1,-3,2,-5,6,-9,7,9,45,65}

 

Example 3:

Input:

arr[]={3,5,9,1,-2,-6,-7,-9,-45,-65}

 Output:

{3,-2,5,-6,9,-7,1,-9,-45,-65}

 

 

 

 

 

Published By : Kopal Jaiswal
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Comments

Jquery Comments Plugin