-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWavePattern.cpp
79 lines (68 loc) · 1.43 KB
/
WavePattern.cpp
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Implemented by Kritagya Kumra
#include <iostream>
#include <string>
using namespace std;
void evenTurn(int arr[][4], int index, int rowCount)
{
int j = 0;
while (j < rowCount)
{
cout << arr[j][index] << " ";
j++;
}
}
void oddTurn(int arr[][4], int index, int rowCount)
{
int j = rowCount - 1;
while (j >= 0)
{
cout << arr[j][index] << " ";
j--;
}
}
int main()
{
int arr[3][4] = {3, 4, 5, 6, 7, 9, 1, 2, 3, 11, 8, 6};
// Input the elements
// cout << "Enter elements of the array are " << endl;
// for (int row = 0; row < 3; row++)
// {
// for (int col = 0; col < 4; col++)
// {
// cin >> arr[row][col];
// }
// }
// Printing the elements
cout << "The elements of the array are " << endl;
for (int row = 0; row < 3; row++)
{
for (int col = 0; col < 4; col++)
{
cout << arr[row][col] << " ";
}
cout << endl;
}
cout << endl;
int i = 0, j = 0;
int n = 4;
while (n > 0)
{
if (n % 2 == 0)
{
evenTurn(arr, i, 3);
}
else
{
oddTurn(arr, i, 3);
}
i++;
n--;
}
// Row wise sum Printing
// RowWiseSum(arr, 3, 4);
// Column wise sum Printing
// ColWiseSum(arr[][4], 3, 4)
// Largest Row Sum Printing
return 0;
}
// Implemented by Kritagya Kumra