mirror of https://github.com/01-edu/public.git
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.
34 lines
475 B
34 lines
475 B
5 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
|
||
|
"github.com/01-edu/z01"
|
||
|
)
|
||
|
|
||
|
func printStr(str string) {
|
||
|
arrayStr := []rune(str)
|
||
|
|
||
|
for i := 0; i < len(arrayStr); i++ {
|
||
|
z01.PrintRune(arrayStr[i])
|
||
|
}
|
||
|
z01.PrintRune('\n')
|
||
|
}
|
||
|
|
||
|
func isEven(nbr int) bool {
|
||
|
return nbr%2 == 0
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
EvenMsg := "I have an even number of arguments"
|
||
|
OddMsg := "I have an odd number of arguments"
|
||
|
|
||
|
lenOfArg := len(os.Args) - 1
|
||
|
|
||
5 years ago
|
if isEven(lenOfArg) {
|
||
5 years ago
|
printStr(EvenMsg)
|
||
|
} else {
|
||
|
printStr(OddMsg)
|
||
|
}
|
||
|
}
|