Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- func main() {
- var n, number int
- fmt.Scanln(&n)
- var p1 = 0.0
- var p2 = 0.0
- var p3 = 0.0
- var p4 = 0.0
- var p5 = 0.0
- for i := 0; i < n; i++ {
- fmt.Scanln(&number)
- if number < 200 {
- p1 += 1
- } else if number < 400 {
- p2 += 1
- } else if number < 600 {
- p3 += 1
- } else if number < 800 {
- p4 += 1
- } else {
- p5 += 1
- }
- }
- fmt.Printf("%.2f%%\n", p1 / float64(n) * 100)
- fmt.Printf("%.2f%%\n", p2 / float64(n) * 100)
- fmt.Printf("%.2f%%\n", p3 / float64(n) * 100)
- fmt.Printf("%.2f%%\n", p4 / float64(n) * 100)
- fmt.Printf("%.2f%%\n", p5 / float64(n) * 100)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement