-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpattern7.cpp
93 lines (83 loc) · 2.08 KB
/
pattern7.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*Lecture 4.1.7: Awesome Pattern Question-7 */
/*Butterfly Pattern Question
* *
* * * *
* * * * * *
* * * * * * * *
* * * * * * * * * *
* * * * * * * * * * * *
* * * * * * * * * * * * * *
* * * * * * * * * * * * * *
* * * * * * * * * * * *
* * * * * * * * * *
* * * * * * * *
* * * * * *
* * * *
* *
n= 7;
Rows;( 1 to n);
start *:Row No. , mere star jo hoge voo equal hoge mere row no ke
spacing: 1st row--> 6spaces, 2nd row--> 4 spaces then 2 then 0, so ye, (2*n-2*Row No)
Then 2nd part ke liye row wala part chalega (n to 1)
*/
#include<iostream>
using namespace std;
int main() {
int num;
cout<<"Enter the No: ";
cin>>num;
/*First Part of Butterfly Pattern Section */
//row
for(int i=1; i<=num; i++) {
//column
for(int j=1; j<=i; j++) {
cout<<"* ";
}
//space part
int spaceSec = 2*num - 2*i;
//column
for(int j=1; j<=spaceSec; j++) {
cout<<" ";
}
for(int j=1; j<=i; j++) {
cout<<"* ";
}
cout<<endl;
}
/*Second Part of Butterfly Pattern Section */
//row
for(int i=num; i>=1; i--) {
//column
for(int j=1; j<=i; j++) {
cout<<"* ";
}
//space part
int spaceSec = 2*num-2*i;
//column
for(int j=1; j<=spaceSec; j++) {
cout<<" ";
}
for(int j=1; j<=i; j++) {
cout<<"* ";
}
cout<<endl;
}
return 0;
}
/*Output:
Enter the No: 7
* *
* * * *
* * * * * *
* * * * * * * *
* * * * * * * * * *
* * * * * * * * * * * *
* * * * * * * * * * * * * *
* * * * * * * * * * * * * *
* * * * * * * * * * * *
* * * * * * * * * *
* * * * * * * *
* * * * * *
* * * *
* *
*/