#include <iostream>
using namespace std;
// quote- break down bigger problems into smaller problems
// Butterfly Pattern -
/*
pseudocode
1. build first pyramid
then second pyramid
*/
int main() {
int n = 4;
// upper half
for(int i=1; i <= n; i++){
//stars
for(int j = 1; j <= i; j++){
cout << "*";
} //spaces
for(int j =1; j <= 2*(n-i); j++){
cout << " ";
} //stars
for(int j = 1; j <= i; j++){
cout << "*";
}
cout << endl;
}
// lower half , Mylearnings- just change outer loop to make it opposite pattern
for(int i = n; i >= 1; i--){ // outer loop(n to 1) so
// int i = n; i >= 1; i--
// stars
for(int j = 1; j <= i; j++){
cout << "*";
}
// spaces
for(int j = 1; j <= 2*(n-i); j++ ){
cout << " ";
}
// stars
for(int j = 1; j <= i; j++){
cout << "*";
}
cout << endl;
}
return 0;
}
OUTPUT-
* *
** **
*** ***
********
********
*** ***
** **
* *