mirror of https://github.com/01-edu/public.git
Browse Source
- fix folder name - fix exercise name - upgrade instructions - add missing import piscine - fix white-spaces and indentationpull/2076/head
Tiago Collot
2 years ago
committed by
MSilva95
2 changed files with 53 additions and 49 deletions
@ -1,49 +0,0 @@ |
|||||||
## not_decimal |
|
||||||
|
|
||||||
### Instructions |
|
||||||
|
|
||||||
Write a function called `Not_decimal` that takes a string in forme of a float number with the decimal point and returns an integer without the decimal point (you muliply by 10^n to remove `.`). |
|
||||||
|
|
||||||
- If the number is doesn'the have a decimal point or there is only zero after `.` return the number followed by a newline `\n`. |
|
||||||
- If the argument is empty return newline `\n`. |
|
||||||
- If The argument is not a number return it followed by newline `\n`. |
|
||||||
|
|
||||||
### Expected function |
|
||||||
|
|
||||||
```go |
|
||||||
func Not_decimal(dec string) string { |
|
||||||
} |
|
||||||
``` |
|
||||||
### Usage |
|
||||||
|
|
||||||
Here is a possible program to test your function : |
|
||||||
|
|
||||||
```go |
|
||||||
package main |
|
||||||
|
|
||||||
import "fmt" |
|
||||||
|
|
||||||
func main() { |
|
||||||
fmt.Print(Not_decimal("0.1")) |
|
||||||
fmt.Print(Not_decimal("174.2")) |
|
||||||
fmt.Print(Not_decimal("0.1255")) |
|
||||||
fmt.Print(Not_decimal("1.20525856")) |
|
||||||
fmt.Print(Not_decimal("-0.0f00d00")) |
|
||||||
fmt.Print(Not_decimal("")) |
|
||||||
fmt.Print(Not_decimal("-19.525856")) |
|
||||||
fmt.Print(Not_decimal("1952")) |
|
||||||
} |
|
||||||
``` |
|
||||||
And its output : |
|
||||||
|
|
||||||
```go |
|
||||||
$ go run . | cat -e |
|
||||||
1$ |
|
||||||
1742$ |
|
||||||
1255$ |
|
||||||
120525856$ |
|
||||||
-0.0f00d00$ |
|
||||||
$ |
|
||||||
-19525856$ |
|
||||||
1952$ |
|
||||||
``` |
|
@ -0,0 +1,53 @@ |
|||||||
|
## notdecimal |
||||||
|
|
||||||
|
### Instructions |
||||||
|
|
||||||
|
Write a function called `NotDecimal()` that takes as an argument a `string` in forme of a float number with the decimal point and returns a string converted to an `int` without the decimal point (you will have to multiply it by 10^n to remove the `.`). |
||||||
|
|
||||||
|
- If the number doesn't have a decimal point or there is only a zero after the `.` return the number followed by a newline `\n`. |
||||||
|
- If the argument is empty return newline `\n`. |
||||||
|
- If the argument is not a number return it followed by newline `\n`. |
||||||
|
|
||||||
|
### Expected function |
||||||
|
|
||||||
|
```go |
||||||
|
func NotDecimal(dec string) string { |
||||||
|
|
||||||
|
} |
||||||
|
``` |
||||||
|
### Usage |
||||||
|
|
||||||
|
Here is a possible program to test your function: |
||||||
|
|
||||||
|
```go |
||||||
|
package main |
||||||
|
|
||||||
|
import ( |
||||||
|
"fmt" |
||||||
|
"piscine" |
||||||
|
) |
||||||
|
|
||||||
|
func main() { |
||||||
|
fmt.Print(piscine.NotDecimal("0.1")) |
||||||
|
fmt.Print(piscine.NotDecimal("174.2")) |
||||||
|
fmt.Print(piscine.NotDecimal("0.1255")) |
||||||
|
fmt.Print(piscine.NotDecimal("1.20525856")) |
||||||
|
fmt.Print(piscine.NotDecimal("-0.0f00d00")) |
||||||
|
fmt.Print(piscine.NotDecimal("")) |
||||||
|
fmt.Print(piscine.NotDecimal("-19.525856")) |
||||||
|
fmt.Print(piscine.NotDecimal("1952")) |
||||||
|
} |
||||||
|
``` |
||||||
|
And its output: |
||||||
|
|
||||||
|
```console |
||||||
|
$ go run . | cat -e |
||||||
|
1$ |
||||||
|
1742$ |
||||||
|
1255$ |
||||||
|
120525856$ |
||||||
|
-0.0f00d00$ |
||||||
|
$ |
||||||
|
-19525856$ |
||||||
|
1952$ |
||||||
|
``` |
Loading…
Reference in new issue