计算a+b
打开以下链接可以查看正确的代码
https://ac.nowcoder.com/acm/contest/5657#question
数据范围: 数据组数 , 数据大小满足
whileTrue: try: lst =input().split(" ") sum=int(lst[0])+int(lst[1]) print(sum) except: break |
while(true){ const putin = readline(); if (putin) { const arr = putin.split(' '); const a = Number(arr[0]); const b = Number(arr[1]); console.log(a+b) } else { break; } }
importjava.io.*; importjava.util.*; publicclassMain{ publicstaticvoidmain(String [] args) throwsIOException{ BufferedReader bf = newBufferedReader(newInputStreamReader(System.in)); try{ while(true){ String in = bf.readLine(); String [] st = in.split(" "); System.out.println(Integer.parseInt(st[0]) + Integer.parseInt(st[1])); } }catch(Exception e){ return; } } } |
package main import ( "bufio" "fmt" "log" "os" "strconv" "strings" ) func main() { inputReader := bufio.NewReader(os.Stdin) var nums []string for { input, err := inputReader.ReadString('\n') if err != nil { log.Print(err) } input = strings.Trim(input, "\n") nums = strings.Split(input, " ") var ans int var temp int if len(nums) == 1 { os.Exit(0) } for _, n := range nums { temp, _ = strconv.Atoi(n) ans += temp } fmt.Println(ans) } } 沙雕代码 stdin 的意义什么?