A+B for Input-Output Practice (I)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9369 Accepted Submission(s): 4523
Problem DescriptionYour task is to Calculate a + b.
Too easy?! Of course! I specially designed the problem for acm beginners.
You must have found that some problems have the same titles with this one, yes, all these problems were designed for the same aim.
InputThe input will consist of a series of pairs of integers a and b, separated by a space, one pair of integers per line.
OutputFor each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input.
Sample Input
1 5
10 20
Sample Output
6
30
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9369 Accepted Submission(s): 4523
Problem DescriptionYour task is to Calculate a + b.
Too easy?! Of course! I specially designed the problem for acm beginners.
You must have found that some problems have the same titles with this one, yes, all these problems were designed for the same aim.
InputThe input will consist of a series of pairs of integers a and b, separated by a space, one pair of integers per line.
OutputFor each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input.
Sample Input
1 5
10 20
Sample Output
6
30
解决方案 »
- 正确吗: 创建子类的对象时,先调用子类自己的构造函数,然后调用父类的构造函数。
- 哪位有兴趣帮俺做个RFID方面的 demo,我可以提供交换,如arm开发项目 呵呵
- 我要学习JAVA 请哥哥姐姐前辈们指点指点我~~谢谢了
- 自动登陆VPN的java程序怎么写?
- 一个向文件中写入内容的问题!!!!
- 生成JAVADOC的问题
- 放分!你知道为什么,分就给你!
- 请教一个问题 聊天账号的自动生成问题
- 求推荐java并发书籍
- 关于String与StringBuffer问题的再次提问----在线等待
- 为什么会出现java.lang.NoClassDefFoundError: GameFrame (我是新手)
- 数的排序问题
//输入范例:
//3 6
//5 8
//end
List<Integer> result = new ArrayList<>();
Scanner sc = new Scanner(System.in);
String s = null;
boolean flag = true;
System.out.println("请输入若干对整数,输入“end”表示结束:");
do{
s = sc.nextLine();
if(s.equals("end")) {
System.out.println("\n求和结果为:");
for(Integer x:result) {
System.out.println(x);
}
flag = false;
}else {
Scanner scanner = new Scanner(s);
int a = scanner.nextInt();
int b = scanner.nextInt();
result.add(a+b);
}
}while(flag);
public static void main(String[] args) { int a, b;
Scanner scanner = new Scanner(System.in);
while (scanner.hasNextInt()) {
a = scanner.nextInt();
b = scanner.nextInt();
System.out.println(a + b);
}
}
}
public static void main(String[] args) { int a, b;
Scanner scanner = new Scanner(System.in); a = scanner.nextInt();
b = scanner.nextInt();
System.out.println(a + b); }
}