forked from root/public
Compare commits
7 Commits
master
...
1138-swap-
Author | SHA1 | Date |
---|---|---|
Hamza elkhatri | 2e5ee3091e | 2 years ago |
Hamza elkhatri | 07034381da | 2 years ago |
Hamza elkhatri | 368da4a0f1 | 2 years ago |
Hamza elkhatri | a4ccd1bd2e | 2 years ago |
Hamza elkhatri | 06b64ee1ee | 2 years ago |
Hamza elkhatri | 9a0f471812 | 2 years ago |
hamza | 17c1961804 | 2 years ago |
1 changed files with 26 additions and 0 deletions
@ -0,0 +1,26 @@ |
|||||||
|
## swap-name |
||||||
|
|
||||||
|
### Instructions |
||||||
|
|
||||||
|
Write a program that takes a first and last name as one argument and swaps them. |
||||||
|
- If there is more than one argument, nothing should be printed. |
||||||
|
- The argument should contain only alphabetic characters and spaces and only two words, if not, you have to print `"Error\n"` |
||||||
|
- The result must be followed with a new line at the end (`'\n'`). |
||||||
|
- Trim any extra space in the beginning or end of the string. |
||||||
|
|
||||||
|
### Usage |
||||||
|
|
||||||
|
```console |
||||||
|
$ go run . | cat -e |
||||||
|
$ go run . "James Carl" "Peter Lab" | cat -e |
||||||
|
$ go run . "ROB carlos" | cat -e |
||||||
|
carlos ROB$ |
||||||
|
$ go run . "He2 $%hello" | cat -e |
||||||
|
Error$ |
||||||
|
$ go run . " JULIE BIRD " | cat -e |
||||||
|
BIRD JULIE$ |
||||||
|
$ go run . "Carl Jon Mic" | cat -e |
||||||
|
Error$ |
||||||
|
$ go run . "ROB" | cat -e |
||||||
|
Error$ |
||||||
|
``` |
Loading…
Reference in new issue