Đề bài
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.
Ràng buộc
1 ≤ size ≤ 50
Ví dụ
Ví dụ 1
Đầu vào:
size = 4
Kết quả mong đợi:
expected = ["****", "* *", "* *", "****"]
Đầu vào:
long long size = 4;
Kết quả mong đợi:
std::vector<std::string> expected = {"****", "* *", "* *", "****"};
Đầu vào:
long size = 4;
Kết quả mong đợi:
string[] expected = new string[] {"****", "* *", "* *", "****"};
Giải thích
Rows are "****", "* *", "* *", "****".
Ví dụ 2
Đầu vào:
size = 1
Kết quả mong đợi:
expected = ["*"]
Đầu vào:
long long size = 1;
Kết quả mong đợi:
std::vector<std::string> expected = {"*"};
Đầu vào:
long size = 1;
Kết quả mong đợi:
string[] expected = new string[] {"*"};
Giải thích
A 1×1 square is a single "*".
Tham khảo
Thử thách này đã được điều chỉnh cho CodeUtility. Hãy làm theo đề bài và các ràng buộc ở trên.