-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDay66.cpp
45 lines (45 loc) · 1.26 KB
/
Day66.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
public:
vector<string> pattern(int n){
int row, column, dashes = 0;
int i, j, dash_counter = 0;
int value = 1;
int k, l, decrementor = 0;
int column_decrementor = 0;
int support = n - 1;
int temp = ((n * n) + 1);
int temp1 = (n * 2) - 1;
int z = temp;
int tracker;
vector<string> res;
string s;
for (i = 1; i <= n; i++) {
s = "";
for(int it = 0;it < dash_counter;it++)
s += "-";
for (j = 1; j <= (2 * n) - dash_counter; j++) {
if (j % 2 == 0)
s += "*";
else {
s += to_string(value);
value++;
}
}
for (k = 1; k <= (temp1 - decrementor); k++) {
if (k % 2 == 0)
s += "*";
else {
if (k == 1)
tracker = temp;
s += to_string(temp);
temp++;
}
}
decrementor += 2;
temp = tracker - support;
support--;
dash_counter += 2;
res.push_back(s);
}
return res;
}
};