File tree 2 files changed +66
-0
lines changed
2 files changed +66
-0
lines changed Original file line number Diff line number Diff line change
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
+
13
+ for (int j = 0 ; j < i + 1 ; j++)
14
+ {
15
+ cout << " * " ;
16
+ }
17
+
18
+ // spaces
19
+ for (int j = 0 ; j < n - i - 1 ; j++)
20
+ {
21
+ cout << " " ;
22
+ }
23
+
24
+ // spaces
25
+ for (int j = 0 ; j < n - i - 1 ; j++)
26
+ {
27
+ cout << " " ;
28
+ }
29
+
30
+ for (int j = 0 ; j < i + 1 ; j++)
31
+ {
32
+ cout << " *" ;
33
+ }
34
+
35
+ cout << endl;
36
+ }
37
+
38
+ // bottom
39
+ for (int i = 0 ; i < n; i++)
40
+ {
41
+
42
+ for (int j = 0 ; j < n - i; j++)
43
+ {
44
+ cout << " * " ;
45
+ }
46
+
47
+ // spaces
48
+ for (int j = 0 ; j < i; j++)
49
+ {
50
+ cout << " " ;
51
+ }
52
+
53
+ // spaces
54
+ for (int j = 0 ; j < i; j++)
55
+ {
56
+ cout << " " ;
57
+ }
58
+
59
+ for (int j = 0 ; j < n - i; j++)
60
+ {
61
+ cout << " *" ;
62
+ }
63
+
64
+ cout << endl;
65
+ }
66
+ }
You can’t perform that action at this time.
0 commit comments