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.
31 lines
716 B
31 lines
716 B
6 years ago
|
## range
|
||
|
|
||
|
### Instructions
|
||
|
|
||
5 years ago
|
Write a program which must:
|
||
6 years ago
|
|
||
5 years ago
|
- **Allocate (with `make`)** a slice of integers.
|
||
6 years ago
|
|
||
5 years ago
|
- Fill it with consecutive values that begins at the first argument and end at the second argument (Including the values of thoses arguments !).
|
||
6 years ago
|
|
||
5 years ago
|
- That prints the slice.
|
||
6 years ago
|
|
||
5 years ago
|
Errors should be handled.
|
||
6 years ago
|
|
||
5 years ago
|
If the number of arguments is different from 2 the program prints nothing.
|
||
6 years ago
|
|
||
5 years ago
|
### Usage :
|
||
5 years ago
|
|
||
|
```console
|
||
5 years ago
|
student@ubuntu:~/range$ go build
|
||
|
student@ubuntu:~/range$ ./range 1 3
|
||
5 years ago
|
[1 2 3]
|
||
5 years ago
|
student@ubuntu:~/range$ ./range -1 2 | cat -e
|
||
|
[-1 0 1 2]$
|
||
5 years ago
|
student@ubuntu:~/range$ ./range 0 0
|
||
5 years ago
|
[0]
|
||
5 years ago
|
student@ubuntu:~/reverserange$ ./reverserange 0 nan | cat -e
|
||
|
strconv.Atoi: parsing "nan": invalid syntax$
|
||
5 years ago
|
student@ubuntu:~/range$
|
||
|
```
|