题解 | #实现四舍五入#
实现四舍五入
http://www.nowcoder.com/practice/020a0cf673174d5795d97ae79cff59a0
// 四舍五入
package main
import "fmt"
func main () {
var (
in float32
out int
)
fmt.Scanf("%f", &in)
if in >= 0 {
out = int(in+0.5)
} else {
out = int(in-0.5)
}
fmt.Printf("%d", out)
}