forked from root/public
Compare commits
3 Commits
master
...
1125-print
Author | SHA1 | Date |
---|---|---|
Hamza elkhatri | cae28ea4a7 | 2 years ago |
Hamza elkhatri | 85af3acbc3 | 2 years ago |
hamza | 5c30f4f20f | 2 years ago |
1 changed files with 24 additions and 0 deletions
@ -0,0 +1,24 @@
|
||||
## print-middle |
||||
|
||||
### Instructions |
||||
|
||||
Write a program that prints the middle argument of the command line. |
||||
- If the number of arguments is less than 1, print (`'\n'`) |
||||
- If the number of arguments is **even**, print the middle two arguments with a space (`' '`) between the arguments |
||||
- If the number of arguments is **odd**, print the middle one. |
||||
- Print (`'\n'`) at the end of the output. |
||||
|
||||
### Usage |
||||
|
||||
```console |
||||
$ go run . | cat -e |
||||
$ |
||||
$ go run . "Hello World!" | cat -e |
||||
Hello World!$ |
||||
$ go run . "Hello World!" "World!" "All" | cat -e |
||||
World!$ |
||||
$ go run . 1 2 3 4 | cat -e |
||||
2 3$ |
||||
$ go run . "Hello" "World!" | cat -e |
||||
Hello World!$ |
||||
``` |
Loading…
Reference in new issue