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.
39 lines
1.2 KiB
39 lines
1.2 KiB
5 years ago
|
## itoabaseprog
|
||
|
|
||
|
### Instructions
|
||
|
|
||
|
Write a program that:
|
||
|
|
||
|
- converts a number in base 10 into the number in the specified base
|
||
|
- the program receives two parameter:
|
||
|
- the first is the value
|
||
|
- the second is the base
|
||
|
|
||
|
The base is expressed as an `int`, from 2 to 16. The characters comprising
|
||
|
the base are the digits from 0 to 9, followed by uppercase letters from A to F.
|
||
|
|
||
|
For example, the base `4` would be the equivalent of "0123" and the base `16` would be the equivalent of "0123456789ABCDEF".
|
||
|
|
||
|
If the value is negative, the resulting `string` has to be preceded with a
|
||
|
minus sign `-`.
|
||
|
|
||
|
### Expected output
|
||
|
|
||
|
```console
|
||
|
student@ubuntu:~/piscine-go/itoabaseprog$ go build
|
||
|
student@ubuntu:~/piscine-go/itoabaseprog$ ./itoabaseprog 15 16
|
||
|
F
|
||
|
student@ubuntu:~/piscine-go/itoabaseprog$ ./itoabaseprog 255 2
|
||
|
11111111
|
||
|
student@ubuntu:~/piscine-go/itoabaseprog$ ./itoabaseprog -4 2
|
||
|
-100
|
||
|
student@ubuntu:~/piscine-go/itoabaseprog$ ./itoabaseprog -df sdf
|
||
|
The value "-df" can not be converted to int
|
||
|
student@ubuntu:~/piscine-go/itoabaseprog$ ./itoabaseprog 23 ew
|
||
|
The value "ew" can not be converted to int
|
||
|
student@ubuntu:~/piscine-go/itoabaseprog$ ./itoabaseprog 4 23
|
||
|
|
||
|
student@ubuntu:~/piscine-go/itoabaseprog$ 323 12
|
||
|
22B
|
||
|
student@ubuntu:~/piscine-go/itoabaseprog$
|
||
|
```
|