We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5800d23 commit a808e00Copy full SHA for a808e00
Patterns/HollowDiamondPattern.cpp
@@ -0,0 +1,60 @@
1
+#include <iostream>
2
+using namespace std;
3
+
4
+int main()
5
+{
6
7
+ int n = 4;
8
9
+ // top
10
+ for (int i = 0; i < n; i++)
11
+ {
12
+ // spaces
13
+ for (int j = 0; j < n - i - 1; j++)
14
15
+ cout << " ";
16
+ }
17
18
+ cout << "*";
19
20
+ if (i != 0)
21
22
23
+ for (int j = 0; j < 2 * i - 1; j++)
24
25
26
27
28
29
30
31
+ cout << endl;
32
33
34
+ // bottom
35
+ for (int i = 0; i < n - 1; i++)
36
37
38
+ for (int j = 0; j < i + 1; j++)
39
40
41
42
43
44
45
+ if (i != n - 2)
46
47
48
+ for (int j = 0; j < 2 * (n - i) - 5; j++)
49
50
51
52
53
54
55
56
57
58
59
+ return 0;
60
+}
Patterns/HollowDiamondPattern.exe
44 KB
0 commit comments