← Back to List

5354번: J박스 ↗

Solutions

C++14
666 B | 666 chars
#include <iostream>
using namespace std;
int T,A;
int main()
{
    cin>>T;
    for(int x=0; x<T; x++)
    {
        cin>>A;
        if(A==1||A==2)
        {
            for(int x=0; x<A; x++)
            {
                for(int y=0; y<A; y++)
                {
                    cout<<"#";
                }
                cout<<endl;
            }
            cout<<endl;
            continue;
        }

        for(int y=0; y<A; y++)
        {
            for(int x=0; x<A; x++)
            {
                if(x==0||y==0||x==A-1||y==A-1) cout<<"#";
                else cout<<"J";
            }
            cout<<endl;
        }
        cout<<endl;
    }
}