Last active
March 29, 2017 17:36
-
-
Save ranapu/c1a41d7e8e30c4cd7b148d0608fbb1f8 to your computer and use it in GitHub Desktop.
Plus Minus in Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
var n, num, pCount, nCount, zCount int | |
fmt.Scan(&n) | |
for i := 0; i < n; i++ { | |
fmt.Scan(&num) | |
if num > 0 { | |
pCount ++ | |
} else if num < 0 { | |
nCount++ | |
} else { | |
zCount++ | |
} | |
} | |
fn := float32(n) | |
fmt.Printf("%f\n%f\n%f", float32(pCount) / fn, float32(nCount) / fn, float32(zCount) / fn) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment