Skip to content

Commit 32b17a8

Browse files
ButterflyPattern c++ program
1 parent 2221d6c commit 32b17a8

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

C++/ButterFlyPattern.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main(){
5+
int n;
6+
cin>>n;
7+
8+
for(int i=1;i<=n;i++){
9+
for(int j=1;j<=i;j++){
10+
cout<<"*";
11+
}
12+
int space =2*n-2*i;
13+
for(int j=1;j<=space;j++){
14+
cout<<" ";
15+
}
16+
for(int j=1;j<=i;j++){
17+
cout<<"*";
18+
}
19+
cout<<endl;
20+
}
21+
22+
for(int i=n;i>=1;i--){
23+
for(int j=1;j<=i;j++){
24+
cout<<"*";
25+
}
26+
int space =2*n-2*i;
27+
for(int j=1;j<=space;j++){
28+
cout<<" ";
29+
}
30+
for(int j=1;j<=i;j++){
31+
cout<<"*";
32+
}
33+
cout<<endl;
34+
}
35+
36+
37+
return 0;
38+
}

0 commit comments

Comments
 (0)