forked from Midway91/HactoberFest2023
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Print_Like_Wave
48 lines (42 loc) · 962 Bytes
/
Print_Like_Wave
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include<iostream>
using namespace std;
void print_like_Wave(int arr[][3], int nrow, int ncol)
{
for (int col = 0; col < ncol; col++)
{
if ((col/2)*2 == col)
{
// [Even colum number] :: print Top to Bottom:-----
int row = 0;
while (row<nrow)
{
cout<<arr[row++][col]<<" ";
}
cout<<endl;
}
else
{
// [Odd colum number] :: Print Bottom to Top:-----
int row = nrow - 1;
while (row >= 0)
{
cout<<arr[row--][col]<<" ";
}
cout<<endl;
}
}
}
int main()
{
int arr[3][3];
cout<<"ENter the array Elements "<<endl;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
cin>>arr[i][j];
}
}
print_like_Wave(arr,3,3);
return 0;
}