-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWavePrint.cpp
More file actions
48 lines (44 loc) · 802 Bytes
/
WavePrint.cpp
File metadata and controls
48 lines (44 loc) · 802 Bytes
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
// Wave Print
#include<iostream>
using namespace std;
void readmatrix(int arr[][10], int row, int col){
for(int i=0;i<row;i++){
for(int j=0;j<col;j++){
cin>>arr[i][j];
}
}
}
void PrintMatrix(int arr[][10], int row, int col){
for(int i=0;i<row;i++){
for(int j=0;j<col;j++){
cout<<arr[i][j]<<" ";
}
cout<<endl;
}
}
// Wave Print
void WavePrint(int arr[][10], int row, int col){
for(int j=0;j<col;j++){
if(j&1){
// Odd column
for(int i=row-1;i>=0;i--){
cout<<arr[i][j]<<" ";
}
}
else{
for(int i=0;i<row;i++){
cout<<arr[i][j]<<" ";
}
}
}
}
int main(){
int arr[10][10];
int row, col;
cout<<"Enter the Number of rows and columns\n";
cin>>row>>col;
readmatrix(arr, row, col);
PrintMatrix(arr, row, col);
WavePrint(arr, row, col);
return 0;
}