1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package main
- import (
- "bufio"
- "fmt"
- "os"
- "strconv"
- "strings"
- )
- func main() {
- input := bufio.NewScanner(os.Stdin)
- var output int
- var digits []int
- for input.Scan() {
- line := input.Text()
- digits = []int{}
- values := strings.Split(line, " ")
- for _, v := range values {
- d, _ := strconv.Atoi(v)
- digits = append(digits, d)
- }
- output = findRepeatNumber(digits)
- fmt.Println(output)
- }
- }
- func findRepeatNumber(nums []int) int {
- var record = map[int]bool{}
- for _, v := range nums {
- if _, ok := record[v]; !ok {
- record[v] = true
- continue
- }
- return v
- }
- return 0
- }
|