Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- int height = n * 2 + 1;
- int width = 2 * n + 3;
- int number_of_inner_dots = n;
- //First half
- for (int row = 0; row < n - 1; row++)
- {
- int number_of_outer_dots = row;
- cout
- << string(number_of_outer_dots, '.')
- << "*"
- << string(number_of_inner_dots, '.')
- << "*"
- << string(number_of_inner_dots, '.')
- << "*"
- << string(number_of_outer_dots, '.')
- << endl;
- number_of_inner_dots--;
- }
- //Middle
- int middle_outer_dots = (width - 5) / 2;
- cout
- << string(middle_outer_dots, '.')
- << string(5, '*')
- << string(middle_outer_dots, '.')
- << endl;
- cout << string(width, '*') << endl;
- cout
- << string(middle_outer_dots, '.')
- << string(5, '*')
- << string(middle_outer_dots, '.')
- << endl;
- //Second half
- for (int row = n-2; row >= 0; row--)
- {
- number_of_inner_dots++;
- int number_of_outer_dots = row;
- cout
- << string(number_of_outer_dots, '.')
- << "*"
- << string(number_of_inner_dots, '.')
- << "*"
- << string(number_of_inner_dots, '.')
- << "*"
- << string(number_of_outer_dots, '.')
- << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement