Explore
ProGrad Programs
About Us

Edit
Reply




Edit

Array into Zigzag Fashion | Convert the given array into zigzag pattern

Published on 09 Mar 2020

Printing an array into Zigzag fashion is discussed here. Suppose you were given an array of integers, and you are told to sort the integers in a zig-zag pattern. In general, in a zig-zag pattern, the first integer is less than the second integer, which is greater than the third integer, which is less than the fourth integer, and so on. Hence, the converted array should be in the form of e1 < e2 > e3 < e4 > e5 < e6.


Test cases:


Input 1:

7

4 3 7 8 6 2 1


Output 1:

3 7 4 8 2 6 1


Input 2:

4

1 4 3 2


Output 2:

1 4 2 3


Array into zigzag pattern


Asked in Directi


C
C++
Java
Python 3

Output
Input- Enter the number of elements:7 Input the array elements: 1 2 3 4 5 6 7 Output- zigzag pattern of the array: 1 3 2 5 4 7 6


Recommended Programs






If you have any feedback about this article and want to improve this, please write to enquiry@faceprep.in
Explore 'c'
Articles