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.
49 lines
819 B
49 lines
819 B
6 years ago
|
## boolean
|
||
6 years ago
|
|
||
6 years ago
|
### Instructions
|
||
6 years ago
|
|
||
6 years ago
|
Create a `.go` file.
|
||
|
|
||
5 years ago
|
- The code below has to be copied in that file.
|
||
6 years ago
|
|
||
5 years ago
|
- The necessary changes have to be applied so that the program works.
|
||
6 years ago
|
|
||
5 years ago
|
- The program must be submitted inside a folder with the name `boolean`.
|
||
6 years ago
|
|
||
6 years ago
|
### Code to be copied
|
||
|
|
||
6 years ago
|
```go
|
||
5 years ago
|
func printStr(s string) {
|
||
|
for _, r := range s {
|
||
|
z01.PrintRune(r)
|
||
6 years ago
|
}
|
||
|
z01.PrintRune('\n')
|
||
|
}
|
||
|
|
||
|
func isEven(nbr int) boolean {
|
||
|
if even(nbr) == 1 {
|
||
|
return yes
|
||
|
} else {
|
||
|
return no
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
if isEven(lengthOfArg) == 1 {
|
||
|
printStr(EvenMsg)
|
||
|
} else {
|
||
|
printStr(OddMsg)
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
5 years ago
|
### Usage
|
||
6 years ago
|
|
||
|
```console
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/boolean$ go build
|
||
|
student@ubuntu:~/[[ROOT]]/boolean$ ./boolean "not" "odd"
|
||
6 years ago
|
I have an even number of arguments
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/boolean$ ./boolean "not even"
|
||
6 years ago
|
I have an odd number of arguments
|
||
6 years ago
|
```
|