Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- string repeat(char s, int n) {
- string result;
- for (int i = 0; i < n; i++)
- {
- result += s;
- }
- return result;
- }
- int main() {
- int n;
- cin >> n;
- int spaces = 2 * n - 2;
- int stars = 2;
- for (int row = 0; row < n; row++) {
- cout << repeat(' ', spaces)
- << repeat('*', stars) << endl;
- spaces -= 2;
- stars += 2;
- }
- spaces = 2;
- stars = 2 * n - 2;
- for (int row = 0; row < 2; row++) {
- cout << repeat('*', stars)
- << repeat(' ', spaces) << endl;
- spaces += 2;
- stars -= 2;
- }
- spaces = 2;
- stars = 2 * n - 2;
- for (int row = 0; row < 2; row++) {
- cout << repeat('*', stars)
- << repeat(' ', spaces) << endl;
- if (spaces > 0 && stars > 0) {
- spaces -= 2;
- stars += 2;
- }
- }
- spaces = 2;
- stars = 2 * n - 2;
- for (int row = 0; row < 2; row++) {
- cout << repeat(' ', spaces)
- << repeat('*', stars) << endl;
- spaces += 2;
- stars -= 2;
- }
- spaces = 2;
- stars = 2 * n - 2;
- for (int row = 0; row < 2; row++) {
- cout << repeat(' ', spaces)
- << repeat('*', stars) << endl;
- if (spaces > 0 && stars > 0) {
- spaces -= 2;
- stars += 2;
- }
- }
- spaces = 2;
- stars = 2 * n - 2;
- for (int row = 0; row < n; row++) {
- cout << repeat('*', stars)
- << repeat(' ', spaces) << endl;
- spaces += 2;
- stars -= 2;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement