Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
3.3 kB
1
Indexable
Never
// risuvane.cpp : This file contains the 'main' function. Program execution begins and ends there.

#include <iostream>

int main()
{
    std::cout << "This code prints a bunch of triangles and a swastika. \nEnter size: ";
    int n;
    std::cin >> n;
    for (int i = 1; i <= n; i++)
    {
        for (int j = i; j <= n; j++)
        {
            std::cout << '*';
        }
        std::cout << std::endl;
    }
    std::cout << std::endl;



    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= i; j++)
        {
            std::cout << '*';
        }
        std::cout << std::endl;
    }
    std::cout << std::endl;
    
    for (int i = 1; i <= n; i++)
    {
        for (int j = i; j < n; j++)
        {
            std::cout << ' ';
        }
        for (int j = 1; j <= i; j++)
        {
            std::cout << '*';
        }
        std::cout << std::endl;
    }
    std::cout << std::endl;

    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j < i; j++)
        {
            std::cout << ' ';
        }
        for (int j = i; j <= n; j++)
        {
            std::cout << '*';
        }
        std::cout << std::endl;
    }
    std::cout << std::endl;
    for (int i = 1; i <= n; i++)
    {
        for (int j = i; j < n; j++)
        {
            std::cout << ' ';
        }
        for (int j = 1; j <= i; j++)
        {
            std::cout << '*';
        }
        for (int j = 1; j < i; j++)
        {
            std::cout << '*';
        }
        std::cout << std::endl;
    }
    std::cout << std::endl;


    for (int i = 1; i < n; i++)
    {
        for (int j = i; j < n; j++)
        {
            std::cout << ' ';
        }
        while (i > 1)
        {
            std::cout << '*'; break;
        }
        for (int j = 1; j < i; j++)
        {
            std::cout << ' ';
        }
        int p;
        for (p = 1; p <= i -2 ; p++)
        {
            std::cout << ' ';
        }
        std::cout << '*';
        std::cout << std::endl;
    }
    for (int i = 1; i <= (n*2)-1; i++)
    {
        std::cout << '*';
    }
    std::cout << std::endl;
    std::cout << std::endl;
    for (int p = 1; p <= n - 1; p++)
    {
        std::cout << '*';
        for (int i = 1; i <= n - 2; i++)
        {
            std::cout << ' ';
        }
        std::cout << '*';
        for (int i = 1; i <= n - 1; i++)
        {
            if (p == 1)
            {
                std::cout << "*";
            }
        }
        std::cout << std::endl;
    }
    for (int p = 1; p <= n; p++)
    {
        for (int i = 1; i < n; i++)
        {
            if (p == 1 || p == n)
            {
                std::cout << '*';
            }
            else
            {
                std::cout << ' ';
            }
        }
        std::cout << '*';
        for (int i = 1; i <= n-2; i++)
        {
            if (p == 1)
            {
                std::cout << '*';
            }
            else
            {
                std::cout << ' ';
            }
        }
        std::cout << '*' << std::endl;
    }
    return 0;
}