4
* * ** ** *** *** ******** ******** *** *** ** ** * *
void pattern_q11_butterfly() {
int n = 5;
// Upper half
for(int i = 1; i <= n; i++) {
// Left stars
for(int j = 1; j <= i; j++) {
cout << "*";
}
// Middle spaces
for(int j = 1; j <= 2*(n-i); j++) {
cout << " ";
}
// Right stars
for(int j = 1; j <= i; j++) {
cout << "*";
}
cout << endl;
}
// Lower half
for(int i = n; i >= 1; i--) {
for(int j = 1; j <= i; j++) {
cout << "*";
}
for(int j = 1; j <= 2*(n-i); j++) {
cout << " ";
}
for(int j = 1; j <= i; j++) {
cout << "*";
}
cout << endl;
}
}
void pattern_q11_butterfly() {
int n = 5;
// Upper half
for(int i = 1; i <= n; i++) {
// Left stars
for(int j = 1; j <= i; j++) {
cout << "*";
}
// Middle spaces
for(int j = 1; j <= 2*(n-i); j++) {
cout << " ";
}
// Right stars
for(int j = 1; j <= i; j++) {
cout << "*";
}
cout << endl;
}
// Lower half
for(int i = n; i >= 1; i--) {
for(int j = 1; j <= i; j++) {
cout << "*";
}
for(int j = 1; j <= 2*(n-i); j++) {
cout << " ";
}
for(int j = 1; j <= i; j++) {
cout << "*";
}
cout << endl;
}
}