Submission

Status:

PPPPP

Subtask/Task Score:

100/100

Score: 100

User: APNICHANAN

Problemset: กังหันสี่ทิศ

Language: cpp

Time: 0.003 second

Submitted On: 2025-09-22 21:45:30

#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    char w[n];
    for (int i = 0; i < n + 1; i++)
    {
        w[i] = char(64 + i);
    }
    // foward
    for (int i = n; i > 0; i--)
    {
        for (int j = 0; j < (n - i) % n; j++)
        {
            cout << " ";
        }
        cout << w[i];
        for (int j = 0; j < 2 * (i - 2) + 1; j++)
        {
            cout << " ";
        }
        if (i > 1)
        {
            cout << w[i];
        }
        for (int j = 0; j < (n - i) % n; j++)
        {
            cout << " ";
        }

        cout << " ";
        for (int j = 0; j < (n - i) % n; j++)
        {
            cout << " ";
        }
        cout << "*";
        for (int j = 0; j < 2 * (i - 2) + 1; j++)
        {
            cout << " ";
        }
        if (i > 1)
        {
            cout << "*";
        }
        for (int j = 0; j < (n - i) % n; j++)
        {
            cout << " ";
        }
        cout << endl;
    }
    //
    //
    //
    //
    // reverse
    for (int i = 2; i <= n; i++)
    {
        for (int j = 0; j < abs(i - n); j++)
        {
            cout << " ";
        }
        cout << w[i];
        for (int j = 0; j < 2 * (i - 2) + 1; j++)
        {
            cout << " ";
        }
        cout << w[i];
        for (int j = 0; j < abs(i - n); j++)
        {
            cout << " ";
        }

        cout << " ";
        for (int j = 0; j < (n - i) % n; j++)
        {
            cout << " ";
        }
        cout << "*";
        for (int j = 0; j < 2 * (i - 2) + 1; j++)
        {
            cout << " ";
        }
        cout << "*";
        for (int j = 0; j < (n - i) % n; j++)
        {
            cout << " ";
        }
        cout << endl;
    }
}

// int main()
// {
//     int n;
//     cin >> n;
//     char w[n];
//     for (int i = 0; i < n + 1; i++)
//     {
//         w[i] = char(64 + i);
//     }
//     // foward
//     for (int i = n; i > 0; i--)
//     {
//         for (int j = 0; j < n - i; j++)
//         {
//             cout << " ";
//         }
//         cout << w[i];
//         for (int j = 0; j < 2 * (i - 2) + 1; j++)
//         {
//             cout << " ";
//         }
//         if (i > 1)
//         {
//             cout << w[i];
//         }
//         for (int j = 0; j < n - i; j++)
//         {
//             cout << " ";
//         }
//         cout << endl;
//     }

//     // reverse
//     for (int i = 2; i < n + 1; i++)
//     {
//         for (int j = 0; j < (n - i) % n; j++)
//         {
//             cout << " ";
//         }
//         cout << w[i];
//         for (int j = 0; j < 2 * (i - 2) + 1; j++)
//         {
//             cout << " ";
//         }
//         cout << w[i];
//         for (int j = 0; j < (n - i) % n; j++)
//         {
//             cout << " ";
//         }
//         cout << endl;
//     }
// }