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.
42 lines
1.1 KiB
42 lines
1.1 KiB
6 years ago
|
## doop
|
||
6 years ago
|
|
||
|
### Instructions
|
||
|
|
||
5 years ago
|
Write a program that is called `doop`.
|
||
6 years ago
|
|
||
6 years ago
|
The program has to be used with three arguments:
|
||
6 years ago
|
|
||
5 years ago
|
- A value
|
||
5 years ago
|
- An operator, one of : `+`, `-`, `/`, `*`, `%`
|
||
5 years ago
|
- Another value
|
||
6 years ago
|
|
||
5 years ago
|
In case of an invalid operator, value, number of arguments or an overflow the programs prints nothing.
|
||
6 years ago
|
|
||
5 years ago
|
The program has to handle the modulo and division operations by 0 as shown on the output examples below.
|
||
6 years ago
|
|
||
5 years ago
|
### Usage
|
||
6 years ago
|
|
||
|
```console
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$ go build doop.go
|
||
|
student@ubuntu:~/[[ROOT]]/test$ ./doop
|
||
|
student@ubuntu:~/[[ROOT]]/test$ ./doop 1 + 1 | cat -e
|
||
5 years ago
|
2$
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$ ./doop hello + 1
|
||
|
student@ubuntu:~/[[ROOT]]/test$ ./doop 1 p 1
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$ ./doop 1 / 0 | cat -e
|
||
6 years ago
|
No division by 0$
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$ ./doop 1 % 0 | cat -e
|
||
5 years ago
|
No modulo by 0$
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$ ./doop 9223372036854775807 + 1
|
||
5 years ago
|
0
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$ ./doop -9223372036854775809 - 3
|
||
5 years ago
|
0
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$ ./doop 9223372036854775807 "*" 3
|
||
5 years ago
|
0
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$ ./doop 1 "*" 1
|
||
6 years ago
|
1
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$ ./doop 1 "*" -1
|
||
5 years ago
|
-1
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$
|
||
5 years ago
|
```
|