Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "math"
- )
- func main() {
- var n int
- fmt.Scanln(&n)
- var oddMin = math.MaxFloat64
- var oddMax = -math.MaxFloat64
- var evenMin = math.MaxFloat64
- var evenMax = -math.MaxFloat64
- var oddSum = 0.0
- var evenSum = 0.0
- var currentNum float64
- for i := 1; i <= n; i++ {
- fmt.Scanln(¤tNum)
- if i % 2 == 1 {
- oddSum += currentNum
- if currentNum < oddMin {
- oddMin = currentNum
- }
- if currentNum > oddMax {
- oddMax = currentNum
- }
- } else {
- evenSum += currentNum
- if currentNum < evenMin {
- evenMin = currentNum
- }
- if currentNum > evenMax {
- evenMax = currentNum
- }
- }
- }
- if n == 0 {
- fmt.Println("OddSum=0.00,\nOddMin=No,\nOddMax=No,")
- } else {
- fmt.Printf("OddSum=%.2f,\nOddMin=%.2f,\nOddMax=%.2f,\n", oddSum, oddMin, oddMax)
- }
- if n <= 1 {
- fmt.Println("EvenSum=0.00,\nEvenMin=No,\nEvenMax=No")
- } else {
- fmt.Printf("EvenSum=%.2f,\nEvenMin=%.2f,\nEvenMax=%.2f\n", evenSum, evenMin, evenMax)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement