La tua sfida è quella di prendere un nome (stringa) come input, come
Albert Einstein
e uscita:
Einstein, Albert
pseudocodice:
set in to input
set arr to in split by " "
set last to the last element of arr
remove the last element of arr
set out to arr joined with " "
prepend ", " to out
prepend last to out
output out
Altri casi di test:
John Fitzgerald Kennedy => Kennedy, John Fitzgerald
Abraham Lincoln => Lincoln, Abraham
Regole
- L'input corrisponderà sempre alla regex
^([A-Z][a-z]+ )+([A-Z][a-z]+)$. - Non è necessario gestire nomi strani , anche se l'output è tecnicamente errato, qui va bene.
- Gli spazi bianchi / newline finali sono OK.
- Qualsiasi domanda? Commenta sotto!
lecon siply ,e hai questa domanda
lecon ,.