From 5ce527c2d4c99c0c9f6369ab49f16f130a89fe73 Mon Sep 17 00:00:00 2001 From: hamza Date: Mon, 13 Jun 2022 10:32:18 +0100 Subject: [PATCH] add(subject):print-middle --- subjects/printmiddle/README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 subjects/printmiddle/README.md diff --git a/subjects/printmiddle/README.md b/subjects/printmiddle/README.md new file mode 100644 index 000000000..6ca559951 --- /dev/null +++ b/subjects/printmiddle/README.md @@ -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$ +``` \ No newline at end of file