Submission

Status:

PPPPPPPPPPP

Score: 100

User: Nani

Problemset: ฝุ่นธุลีล้อมดาว

Language: cpp

Time: 0.067 second

Submitted On: 2024-10-25 12:47:47

#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    char ch[(999*2)+1][(999*2)+1];
    if(n == 1){
        cout << "*";
        return 0;
    }
    else{
        //top-left
        for(int i = 0; i < n; i++){
            for(int j = n-1; j >= 0; j--){
                if(j < n-i-1){
                    ch[i][j] = '-';
                }
                else{
                    ch[i][j] = '+';
                }
            }
        }

    //top-right
    for(int i = 0; i < n; i++){
        for(int j = n-1; j < n+(n-1); j++){
            if(j <= (n-1)+i){
                ch[i][j] = '+';
            }
            else
            {
                ch[i][j] = '-';
            }
        }
    }

    //bottom-left
    for(int i = n-1; i < n+(n-1); i++){
        for(int j = 0; j < n; j++){
            if(j < i-(n-1)){
                ch[i][j] = '-';
            }
            else{
                ch[i][j] = '+';
            }
        }
    }

    //bottom-right
    for(int i = n-1; i < n+(n-1); i++){
        for(int j = n-1; j < n+(n-1); j++){
            if(j < n+(n-1)+((n-1)-i)){
                ch[i][j] = '+';
            }
            else{
                ch[i][j] = '-';
            }
        }
    }
    
    ch[n-1][n-1] = '*';
    }

    //print
    for(int i = 0 ; i < ((n-1)*2)+1; i++){
        for(int j = 0; j < ((n-1)*2)+1; j++){
            cout << ch[i][j];
        }
        cout << endl;
    }
}