-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwaveform.cpp
More file actions
64 lines (54 loc) · 1.12 KB
/
waveform.cpp
File metadata and controls
64 lines (54 loc) · 1.12 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
int rows;
int columns;
cout<<"enter no. of rows:";
cin>>rows;
cout<<"enter no. of columns:";
cin>>columns;
int a[rows][columns];
int val = 1;
cout<<"Actual array:"<<endl;
for(int row=0;row<rows;row++)
{
for(int column=0;column<columns;column++)
{
a[row][column]=val;
val+=1;
cout<<a[row][column]<<" ";
}
cout<<endl;
}
cout<<"-------------------------------"<<endl;
cout<<"Wave form:"<<endl;
int row=0;
int column=0;
while(column<columns)
{
if(column%2==0)
{
row=0;
while(row<rows)
{
cout<<a[row][column]<<" ";
row++;
}
cout<<endl;
}
else
{
row = rows-1;
while(row>=0)
{
cout<<a[row][column]<<" ";
row--;
}
cout<<endl;
}
column+=1;
}
return 0;
}