Einfach 0 gelöst 0% Erfolgsquote

Hollow Square

Draw the outline of a square with * characters.

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.

Von anderen lernen

Community-Lösungen

Noch keine veröffentlichten Lösungen. Löse die Aufgabe und teile als Erster eine Lösung.