ง่าย 0 ข้อที่แก้แล้ว อัตราผ่าน 0%

Hollow Square

Draw the outline of a square with * characters.

โจทย์

Draw a hollow square of side size: the first and last rows are all *, and the rows in between have * only at the two ends with spaces inside.

Implement hollow_square(size).

Input

size: The side length.

Output

Return the rows from top to bottom.

เงื่อนไข

1 ≤ size ≤ 50

ตัวอย่าง

ตัวอย่างที่ 1
อินพุต:
size = 4

ผลลัพธ์ที่คาดหวัง:
expected = ["****", "*  *", "*  *", "****"]
อินพุต:
long long size = 4;

ผลลัพธ์ที่คาดหวัง:
std::vector<std::string> expected = {"****", "*  *", "*  *", "****"};
อินพุต:
long size = 4;

ผลลัพธ์ที่คาดหวัง:
string[] expected = new string[] {"****", "*  *", "*  *", "****"};

คำอธิบาย

Rows are "****", "* *", "* *", "****".

ตัวอย่างที่ 2
อินพุต:
size = 1

ผลลัพธ์ที่คาดหวัง:
expected = ["*"]
อินพุต:
long long size = 1;

ผลลัพธ์ที่คาดหวัง:
std::vector<std::string> expected = {"*"};
อินพุต:
long size = 1;

ผลลัพธ์ที่คาดหวัง:
string[] expected = new string[] {"*"};

คำอธิบาย

A 1×1 square is a single "*".

แหล่งอ้างอิง

โจทย์นี้ปรับให้เหมาะกับ CodeUtility กรุณาทำตามคำชี้แจงและข้อจำกัดด้านบน

เรียนรู้จากคนอื่น

แนวทางจากชุมชน

ยังไม่มีวิธีทำที่เผยแพร่ ลองแก้โจทย์นี้เพื่อแชร์วิธีแรก