#include <iostream>
using namespace std;
int main() {
// your code goes here
int rows=6;
int cols=4;
//printing half pyramid using *
for( int i = 0; i < rows; i++ ) {
for( int j = 0; j <= i; j++ ){
cout << "* ";
}
cout<<endl;
}
//using numbers
for( int i = 0; i < rows; i++ ) {
for( int j = 0; j <= i; j++ ){
cout << i + 1 << " ";
}
cout<<endl;
}
//usimg alphabets
for( int i = 0; i < rows; i++ ) {
for( int j = 0; j <= i; j++ ){
cout << (char)('A' + j) << " ";
}
cout<<endl;
}
// Main logic to print Rectangle.
for( int i = 0; i < rows; i++ ) {
for( int j = 0; j < cols; j++ ){
cout << "* ";
}
cout<<endl;
}
// Main logic to print hollow rectangle.
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
// If the index is at the border, then print *.
if (i == 0 || i == rows - 1 || j == 0 || j == cols - 1)
cout << "* ";
else
cout << " ";
}
cout << endl;
}
// Main logic to print Floyd's Triangle.
int counter = 1;
for( int i = 0; i < rows; i++ ) {
for( int j = 0; j <= i; j++ ){
cout << (counter++) << " ";
}
cout << endl;
}
// Main logic to print the Butterfly pattern.
// Printing upper part.
for( int i = 0; i <= rows; i++ ){
// Print left side stars.
for( int j = 0; j <= i; j++ ){
cout << "* ";
}
// Print spaces.
int spaces = 2 * (rows - i);
for( int j = 0; j < spaces; j++){
cout << " ";
}
// Print right side stars.
for( int j = 0; j <= i; j++ ){
cout << "* ";
}
cout << endl;
}
// Printing bottom part.
for( int i = rows - 1; i >= 0; i-- ){
// Print left side spaces.
for( int j = 0; j <= i; j++ ){
cout << "* ";
}
// Print spaces.
int spaces = 2 * (rows - i);
for( int j = 0; j < spaces; j++){
cout << " ";
}
// Print right side stars.
for( int j = 0; j <= i; j++ ){
cout << "* ";
}
cout << endl;
}
// Main logic to print Pascal's triangle.
for( int i = 0; i < rows; i++){
int spaces = rows - i;
// Print spaces.
for( int j = 0; j < spaces; j++){
cout<<" ";
}
int coefficient;
// Print values.
for( int j = 0; j <= i; j++){
// Update coefficient's value
if( j == 0 )
coefficient = 1;
else
coefficient = coefficient * (i - j + 1) / j;
cout << coefficient << " ";
}
cout << endl;
}
// Main logic to print full pyramid.
for( int i = 0; i < rows; i++ ) {
// Print spaces.
int spaces = rows - i;
for( int j = 0; j < spaces; j++){
cout <<" ";
}
// Print stars.
for( int j = 0; j < 2 * i - 1; j++){
cout <<"* ";
}
cout << endl;
}
return 0;
}