Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "math"
- )
- func main() {
- var n, number int
- fmt.Scanln(&n)
- var oddSum = 0
- var evenSum = 0
- for i := 1; i <= n; i++ {
- fmt.Scanln(&number)
- if (i % 2 == 1) {
- oddSum += number
- } else {
- evenSum += number
- }
- }
- if (oddSum == evenSum) {
- fmt.Printf("Yes\nSum = %d\n", oddSum)
- } else {
- fmt.Printf("No\nDiff = %d\n", int(math.Abs(float64(oddSum - evenSum))))
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement