import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int a,b;
while(cin.hasNext())
{
a=cin.nextInt(); b=cin.nextInt();
System.out.println(a+b);
}
}
}
输入用 StreamTokenizer ,输出用 PrintWriter 就 很快
1234567891011121314151617
import java.io.*;public class Main
{
public static void main(String[] args) throws IOException
{
StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
int a, b;
while(in.nextToken() != StreamTokenizer.TT_EOF)
{
a = (int)in.nval;
in.nextToken();
b = (int)in.nval;
out.println(a + b);
}
out.flush();
}
}
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner ( System.in );
int a,b;
a=cin.nextInt(); b=cin.nextInt();
System.out.println(a+b);
}
}
当输入有多组数据时,可以改成
12345678910111213
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner ( System.in );
int a,b;
while(cin.hasNext())
{
a=cin.nextInt(); b=cin.nextInt();
System.out.println(a+b);
}
}
}