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.

64 lines
1.2 KiB

5 years ago
## putnbrbase
5 years ago
### Instructions
Écrire une fonction qui affiche un `int` dans une base en `string` passés en paramètres.
Si la base n'est pas valide, la fonction affiche `NV` (Not Valid):
Règles de validité d'une base :
- Une base doit contenir au moins 2 caractères.
- Chaque caractère d'une base doit être unique.
- Une base ne doit pas contenir les caractères `+` ou `-`.
La fonction doit gérer les nombres négatifs (comme montré sur l'exemple).
5 years ago
### Fonction attendue
```go
func PrintNbrBase(nbr int, base string) () {
}
```
5 years ago
### Utilisation
Voici un éventuel [programme](TODO-LINK) pour tester votre fonction :
```go
package main
import (
"fmt"
"github.com/01-edu/z01"
piscine ".."
)
func main() {
piscine.PrintNbrBase(125, "0123456789")
z01.PrintRune('\n')
piscine.PrintNbrBase(-125, "01")
z01.PrintRune('\n')
piscine.PrintNbrBase(125, "0123456789ABCDEF")
z01.PrintRune('\n')
piscine.PrintNbrBase(-125, "choumi")
z01.PrintRune('\n')
piscine.PrintNbrBase(125, "aa")
z01.PrintRune('\n')
}
```
Et son résultat :
```console
student@ubuntu:~/piscine/test$ go build
student@ubuntu:~/piscine/test$ ./test
125
-1111101
7D
-uoi
NV
student@ubuntu:~/piscine/test$
```