You are viewing a single comment's thread. Return to all comments →
Finally, someone else using Go! :) Can be solved more efficiantly, though:
func main() { var n, tmp int var plus, minus, zero float64 fmt.Scanf("%d", &n) for i := 0; i < n; i++ { fmt.Scanf("%d", &tmp) switch { case tmp > 0: plus++ case tmp < 0: minus++ case tmp == 0: zero++ } } fmt.Printf("%.6f\n%.6f\n%.6f\n", plus/float64(n), minus/float64(n), zero/float64(n)) }
Seems like cookies are disabled on this browser, please enable them to open this website
Plus Minus
You are viewing a single comment's thread. Return to all comments →
Finally, someone else using Go! :)
Can be solved more efficiantly, though: