AcWing 1. A + B
原题链接
简单
作者:
lxcstudy
,
2024-10-29 16:39:32
,
所有人可见
,
阅读 2
package main
import (
"strings"
"bufio"
"strconv"
"fmt"
"os"
"io"
)
func add(info string) int {
numStrList := strings.Split(info, " ");
num1, err := strconv.Atoi(numStrList[0])
if err != nil {
return 0
}
num2, err := strconv.Atoi(numStrList[1])
if err != nil {
return 0
}
return num1 + num2
}
func main(){
reader := bufio.NewReader(os.Stdin)
text, err := reader.ReadString('\n')
if err != nil && err != io.EOF{
fmt.Println("读取输入时发生错误:", err)
return
}
re := strings.Split(text,"\n")
fmt.Println(add(re[0]))
}