Facile 0 résolus 0 % de réussite

Hollow Square

Draw the outline of a square with * characters.

Problème

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.

Contraintes

1 ≤ size ≤ 50

Exemples

Exemple 1
Entrée :
size = 4

Sortie attendue :
expected = ["****", "*  *", "*  *", "****"]
Entrée :
long long size = 4;

Sortie attendue :
std::vector<std::string> expected = {"****", "*  *", "*  *", "****"};
Entrée :
long size = 4;

Sortie attendue :
string[] expected = new string[] {"****", "*  *", "*  *", "****"};

Explication

Rows are "****", "* *", "* *", "****".

Exemple 2
Entrée :
size = 1

Sortie attendue :
expected = ["*"]
Entrée :
long long size = 1;

Sortie attendue :
std::vector<std::string> expected = {"*"};
Entrée :
long size = 1;

Sortie attendue :
string[] expected = new string[] {"*"};

Explication

A 1×1 square is a single "*".

Références

Ce défi a été adapté pour CodeUtility. Suivez l'énoncé et les contraintes ci-dessus.

Apprenez des autres

Solutions de la communauté

Aucune solution publiée pour l'instant. Résolvez ce défi pour partager la première.