File tree 1 file changed +58
-0
lines changed
1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Pattern Type Mix-pattern m.01
2
+ // 1 2 3 4 5 5 4 3 2 1
3
+ // 1 2 3 4 * * 4 3 2 1
4
+ // 1 2 3 * * * * 3 2 1
5
+ // 1 2 * * * * * * 2 1
6
+ // 1 * * * * * * * * 1
7
+ // 1st triangle
8
+ // 1 2 3 4 5
9
+ // 1 2 3 4 *
10
+ // 1 2 3 * *
11
+ // 1 2 * * *
12
+ // 2nd triangle
13
+ // 5 4 3 2 1
14
+ // * 4 3 2 1
15
+ // * * 3 2 1
16
+ // * * * 2 1
17
+ // * * * * 1
18
+ #include < iostream>
19
+ using namespace std ;
20
+ int main ()
21
+ {
22
+ int n = 5 ;
23
+ int i = 1 ;
24
+ while (i <= n)
25
+ {
26
+ // print numbers (1st triangle)
27
+ int j = 1 ;
28
+ while (j <= n - i + 1 )
29
+ {
30
+ cout << j;
31
+ j++;
32
+ }
33
+ // print stars (1st triangle)
34
+ int star = i - 1 ;
35
+ while (star)
36
+ {
37
+ cout << " *" ;
38
+ star--;
39
+ }
40
+ // print stars (2nd triangle)
41
+ int star2 = i - 1 ;
42
+ while (star2)
43
+ {
44
+ cout << ' *' ;
45
+ star2--;
46
+ }
47
+ // print numbers (second triangle)
48
+ int k = 1 ;
49
+ while (k <= n - i + 1 )
50
+ {
51
+ cout << n - i - k + 2 ;
52
+ k++;
53
+ }
54
+ i++;
55
+ cout << endl;
56
+ }
57
+ return 0 ;
58
+ }
You can’t perform that action at this time.
0 commit comments