add(subject):print-middle

This commit is contained in:
hamza 2022-06-13 10:32:18 +01:00 committed by Dav Hojt
parent 6a53d215e6
commit 5ce527c2d4
1 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,22 @@
## 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$
```