Dễ 0 đã giải Tỷ lệ chấp nhận 0%

Hollow Square

Draw the outline of a square with * characters.

Đề 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.

Học hỏi từ người khác

Giải pháp cộng đồng

Chưa có giải pháp nào được chia sẻ. Hãy giải thử thách này để đăng giải pháp đầu tiên.