// HW week1 DSA course
//1.Print triangles using *, numbers, and characters
//2.Rectangle Pattern
//3. Hollow Rectangle Pattern
//4. Inverted Half Pyramid
//5. Floyd’s Triangle
//6. Butterfly Pattern
//7. Print Pascal's triangle
// 8.Print Full Pyramid Pattern of Stars
#include<iostream>
using namespace std;
int main(){
// 1.Print triangles using *, numbers, and characters
/* int rows;
// Getting the number of rows.
cout << "Enter the Number of rows - ";
cin >> rows;
cout << "Triangle of " << rows << " using * -\n";
for( int i = 0; i < rows; i++ ) {
for( int j = 0; j <= i; j++ ){
cout << "* ";
}
cout<<endl;
}*/
//2.Rectangle Pattern
/*int rows, cols;
// Getting dimensions of the rectangle.
cout << "Enter the number of rows in rectangle - ";
cin >> rows;
cout << "Enter the number of columns in rectangle - ";
cin >> cols;
cout << "Rectangle of dimensions " << rows << "*" << cols << endl;
for( int i = 0; i < rows; i++ ) {
for( int j = 0; j < cols; j++ ){
cout << "* ";
}
cout<<endl;
}*/
//3. Hollow Rectangle Pattern
/* int rows, cols;
// Getting dimensions of rectangle.
cout << "Enter the number of rows in rectangle - ";
cin >> rows;
cout << "Enter the number of columns in rectangle - ";
cin >> cols;
cout << "Rectangle of dimensions " << rows << "*" << cols << 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;
}*/
//4. Inverted Half Pyramid
/* int rows;
// Getting the number of rows.
cout << "Enter the Number of rows - ";
cin >> rows;
cout << "Floyd's Triangle of " << rows << " rows." << 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;
}*/
//5. Floyd’s Triangle
/* int rows;
// Getting the number of rows.
cout << "Enter the Number of rows - ";
cin >> rows;
cout << "Floyd's Triangle of " << rows << " rows." << 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;
}*/
//6. Butterfly Pattern
/*int rows;
// Getting the number of rows.
cout << "Enter the Number of rows - ";
cin >> rows;
cout << "Butterfly Pattern of " << rows << " rows." << 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;
}*/
//7. Print Pascal's triangle
/* int rows;
// Getting the number of rows.
cout << "Enter the Number of rows - ";
cin >> rows;
cout << "Pascal's Triangle of " << rows << " rows." << 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;
}*/
// 8.Print Full Pyramid Pattern of Stars
int rows;
// Getting the number of rows.
cout << "Enter the Number of rows - ";
cin >> rows;
cout << "Full Pyramid of " << rows << " using * -\n";
// 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;
}