# Input-Output Lecture (0) for ACM Freshman

Tags:       先做这道题，小白们  基本输入输出  萌新入坑题
Time Limit:  1 s      Memory Limit:   1024 MB
Submission：5041     AC：3277     Score：10.00

input
1 5 10 20
output
6 30
input
1 2
output
3

## Hint

C版：

#include <stdio.h>
int main()
{
int a,b;
while(scanf("%d %d",&a, &b) != EOF)
printf("%d\n",a+b);
return 0;
}

C++版：

#include <iostream>
using namespace std;
int main()
{
int a,b;
while(cin >> a >> b)
cout << a+b << endl;
}

Java版：

import java.util.Scanner;
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);
}
}
}

Pascal(FPC)：

program p1000(Input,Output);
var
a,b:Integer;
begin
while not eof(Input) do
begin
Writeln(a+b);
end;
end.

Python2/3版：

import sys
for line in sys.stdin:
a = line.split()
print(int(a[0]) + int(a[1])) 

PHP版：

<?php
while (fscanf(STDIN, "%d%d", $a,$b) == 2) {
print ($a +$b) . "\n";
}
?>

C#版：

using System;
using System.Linq;

namespace ConsoleApp
{
public class Program
{
private static void Main()
{
string line;
{
Console.WriteLine(line.Split().Select(int.Parse).Sum());
}
}
}
}

Lua版：

local count = 0
function string.split(str, delimiter)
if str==nil or str=='' or delimiter==nil then
return nil
end

local result = {}
for match in (str..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match)
end
return result
end
while true do
if line == nil or line == "" then break end
local tb = string.split(line, " ")
local sum = 0
for i=1, #tb do
local a = tonumber(tb[i])
sum = sum+a
end
if count>0 then
io.write("\n")
end
io.write(string.format("%d", sum))
count = count+1
end

Perl版：

my $input; while($input = <>){
chomp($input); my @array = split ' ',$input;
print $array[0]+$array[1],"\n";
}

GO版：

package main
import "fmt"
import "io"

func main() {
var A, B int
for {
_, err := fmt.Scan(&A, &B)
if err == io.EOF {
break
}
fmt.Println(A+B)
}
}