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 leftSum = 0
- var rightSum = 0
- for i := 0; i < n; i++ {
- fmt.Scanln(&number)
- leftSum += number
- }
- for i := 0; i < n; i++ {
- fmt.Scanln(&number)
- rightSum += number
- }
- if (leftSum == rightSum) {
- fmt.Printf("Yes, sum = %d\n", leftSum)
- } else {
- fmt.Printf("No, diff = %d\n", int(math.Abs(float64(leftSum - rightSum))))
- }
- }
- ИЛИ:
- package main
- import (
- "fmt"
- "math"
- )
- func main() {
- var n, number int
- fmt.Scanln(&n)
- var leftSum = 0
- var rightSum = 0
- for i := -n; i < n; i++ {
- fmt.Scanln(&number)
- if (i < 0) {
- leftSum += number
- } else {
- rightSum += number
- }
- }
- if (leftSum == rightSum) {
- fmt.Printf("Yes, sum = %d\n", leftSum)
- } else {
- fmt.Printf("No, diff = %d\n", int(math.Abs(float64(leftSum - rightSum))))
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement