You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

911 B

lastword

Instructions

Écrire un programme qui prend une string et qui affiche son dernier mot, suivi d'un newline('\n').

  • Un mot est une section de string délimité par des espace ou par le début/fin d'une string.

  • L'output sera suivi d'un newline('\n').

  • Si le nombre de paramètres n'est pas 1, ou si il n'y a pas de mots, le programme affiche un newline('\n').

Utilisation

student@ubuntu:~/student/lastword$ go build
student@ubuntu:~/student/lastword$ ./lastword "FOR PONY" | cat -e
PONY$
student@ubuntu:~/student/lastword$ ./lastword "this        ...       is sparta, then again, maybe    not" | cat -e
not$
student@ubuntu:~/student/lastword$ ./lastword "  " | cat -e
$
student@ubuntu:~/student/lastword$ ./lastword "a" "b" | cat -e
$
student@ubuntu:~/student/lastword$ ./lastword "  lorem,ipsum  " | cat -e
lorem,ipsum$
student@ubuntu:~/student/lastword$