Problème
Afficher l’original (anglais)Inversez text de sorte que le dernier caractère devienne le premier.
Implémentez reverse_string(text).
Entrée
text : Le texte à inverser.
Sortie
Renvoyez le texte inversé.
Contraintes
0 ≤ longueur ≤ 10 000
Exemples
Exemple 1
Entrée :
text = "hello"
Sortie attendue :
expected = "olleh"
Entrée :
std::string text = "hello";
Sortie attendue :
std::string expected = "olleh";
Entrée :
string text = "hello";
Sortie attendue :
string expected = "olleh";
Explication
h-e-l-l-o lu à l'envers donne "olleh".
Exemple 2
Entrée :
text = "a"
Sortie attendue :
expected = "a"
Entrée :
std::string text = "a";
Sortie attendue :
std::string expected = "a";
Entrée :
string text = "a";
Sortie attendue :
string expected = "a";
Explication
Un seul caractère inversé reste lui-même.
Références
Ce défi a été adapté pour CodeUtility. Suivez l'énoncé et les contraintes ci-dessus.