欢迎提交PR,贡献其他语言版本
#include<iostream>
using namespace std;
int main() {
int a, b;
while (cin >> a >> b) cout << a + b << endl;
}
import java.lang.*;
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
while(in.hasNextInt()){
int a = in.nextInt();
int b = in.nextInt();
System.out.println(a+b);
}
}
}
import sys
for line in sys.stdin:
a, b = line.split(' ')
print(int(a) + int(b))
package main
import "fmt"
func main(){
var a, b int
for {
_, err := fmt.Scanf("%d %d",&a, &b)
if err != nil {
break
}
fmt.Println(a + b)
}
}
// 引入readline模块来读取标准输入
const readline = require('readline');
// 创建readline接口
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
// 处理输入和输出
function processInput() {
rl.on('line', (input) => {
// 将输入按空格分割成a和b的数组
const [a, b] = input.split(' ').map(Number);
// 计算a和b的和并输出
const sum = a + b;
console.log(sum);
});
}
// 开始处理输入
processInput();
#include <stdio.h>
int main() {
int a, b;
while (scanf("%d%d", &a, &b) == 2) {
int sum = a + b;
printf("%d\n", sum);
}
return 0;
}
<?php
while (true) {
$input = fgets(STDIN);
if ($input === false) {
break;
}
$numbers = explode(' ', trim($input));
$a = intval($numbers[0]);
$b = intval($numbers[1]);
echo ($a + $b) . "\n";
}