โจทย์
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 กรุณาทำตามคำชี้แจงและข้อจำกัดด้านบน