Problem
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.
Einschränkungen
1 ≤ size ≤ 50
Beispiele
Beispiel 1
Eingabe:
size = 4
Erwartete Ausgabe:
expected = ["****", "* *", "* *", "****"]
Eingabe:
long long size = 4;
Erwartete Ausgabe:
std::vector<std::string> expected = {"****", "* *", "* *", "****"};
Eingabe:
long size = 4;
Erwartete Ausgabe:
string[] expected = new string[] {"****", "* *", "* *", "****"};
Erläuterung
Rows are "****", "* *", "* *", "****".
Beispiel 2
Eingabe:
size = 1
Erwartete Ausgabe:
expected = ["*"]
Eingabe:
long long size = 1;
Erwartete Ausgabe:
std::vector<std::string> expected = {"*"};
Eingabe:
long size = 1;
Erwartete Ausgabe:
string[] expected = new string[] {"*"};
Erläuterung
A 1×1 square is a single "*".
Referenzen
Diese Aufgabe wurde für CodeUtility angepasst. Beachte die oben genannten Vorgaben und Einschränkungen.