Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- int middle;
- int rows;
- cout << "Enter the number of '*'s on the middle row: ";
- cin >> middle;
- cout << "Enter the number of rows above and below the middle row: ";
- cin >> rows;
- if(middle - 2 * rows < 2){
- cout << "Invalid values. Exiting\n";
- return 0;
- }
- for(int i = 1; i <= rows; i++){
- for(int j = 1; j <= rows - i + 1; j++) cout << " ";
- for(int j = 1; j <= middle - 2 * (rows - i + 1); j++){
- cout << "*";
- }
- cout << "\n";
- }
- for(int i = 1; i <= middle; i++) cout << "*";
- cout << "\n";
- for(int i = 1; i <= rows; i++){
- for(int j = 1; j <= i; j++) cout << " ";
- for(int j = 1; j <= middle - 2 * i; j++){
- cout << "*";
- }
- cout << "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement