{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e计算 a + b\u003c/p\u003e"}},{"title":"输入","value":{"format":"HTML","content":"两个整数 a, b (0 ≤ a, b ≤ 10)"}},{"title":"输出","value":{"format":"HTML","content":"输出 a + b"}},{"title":"示例","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e1 2\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"提示","value":{"format":"HTML","content":"Q: 输入和输出在哪里?\u003cbr\u003e\u003cbr\u003eA: 你的程序应该始终从 stdin (标准输入) 读取输入,并将输出写入 stdout (标准输出)。例如,你可以在 C 中使用 \u0027scanf\u0027 从 stdin 读取,而在 C++ 中使用 \u0027cin\u0027,在 C 中使用 \u0027printf\u0027 或在 C++ 中使用 \u0027cout\u0027 写入 stdout。\u003cbr\u003e\u003cbr\u003e你不应该向标准输出输出任何额外的数据,除非问题要求,否则会得到“错误答案”。\u003cbr\u003e\u003cbr\u003e用户程序不允许打开文件进行读取/写入操作。如果尝试这样做,将会得到“运行时错误”或“错误答案”。\u003cbr\u003e\u003cbr\u003e这是使用 C++/G++ 解决问题 1000 的示例解决方案:\u003cbr\u003e\u003cpre\u003e\u003cbr\u003e#include \u0026lt;iostream\u0026gt;\u003cbr\u003eusing namespace std;\u003cbr\u003eint main()\u003cbr\u003e{\u003cbr\u003e int a,b;\u003cbr\u003e cin \u0026gt;\u0026gt; a \u0026gt;\u0026gt; b;\u003cbr\u003e cout \u0026lt;\u0026lt; a+b \u0026lt;\u0026lt; endl;\u003cbr\u003e return 0;\u003cbr\u003e}\u003c/pre\u003e\u003cbr\u003e当你使用 G++/GCC 时,main() 的返回类型必须是 int,否则可能会出现编译错误。\u003cbr\u003e\u003cbr\u003e这是使用 C/GCC 解决问题 1000 的示例解决方案:\u003cbr\u003e\u003cpre\u003e\u003cbr\u003e#include \u0026lt;stdio.h\u0026gt;\u003cbr\u003e\u003cbr\u003eint main()\u003cbr\u003e{\u003cbr\u003e int a,b;\u003cbr\u003e scanf(\"%d %d\",\u0026amp;a, \u0026amp;b);\u003cbr\u003e printf(\"%d\\n\",a+b);\u003cbr\u003e return 0;\u003cbr\u003e}\u003c/pre\u003e\u003cbr\u003e这是使用 PASCAL 解决问题 1000 的示例解决方案:\u003cbr\u003e\u003cpre\u003e\u003cbr\u003eprogram p1000(Input,Output); \u003cbr\u003evar \u003cbr\u003e a,b:Integer; \u003cbr\u003ebegin \u003cbr\u003e Readln(a,b); \u003cbr\u003e Writeln(a+b); \u003cbr\u003eend.\u003c/pre\u003e\u003cbr\u003e这是使用 JAVA 解决问题 1000 的示例解决方案:\u003cbr\u003e\u003cbr\u003e现在 java 编译器是 jdk 1.5,下面是问题 1000 的程序:\u003cbr\u003e\u003cpre\u003e\u003cbr\u003eimport java.io.*;\u003cbr\u003eimport java.util.*;\u003cbr\u003epublic class Main\u003cbr\u003e{\u003cbr\u003e public static void main(String args[]) throws Exception\u003cbr\u003e {\u003cbr\u003e Scanner cin\u003dnew Scanner(System.in);\u003cbr\u003e int a\u003dcin.nextInt(),b\u003dcin.nextInt();\u003cbr\u003e System.out.println(a+b);\u003cbr\u003e }\u003cbr\u003e}\u003c/pre\u003e\u003cbr\u003ejdk 1.4 的旧程序:\u003cbr\u003e\u003cpre\u003e\u003cbr\u003eimport java.io.*;\u003cbr\u003eimport java.util.*;\u003cbr\u003e\u003cbr\u003epublic class Main\u003cbr\u003e{\u003cbr\u003e public static void main (String args[]) throws Exception\u003cbr\u003e {\u003cbr\u003e BufferedReader stdin \u003d \u003cbr\u003e new BufferedReader(\u003cbr\u003e new InputStreamReader(System.in));\u003cbr\u003e\u003cbr\u003e String line \u003d stdin.readLine();\u003cbr\u003e StringTokenizer st \u003d new StringTokenizer(line);\u003cbr\u003e int a \u003d Integer.parseInt(st.nextToken());\u003cbr\u003e int b \u003d Integer.parseInt(st.nextToken());\u003cbr\u003e System.out.println(a+b);\u003cbr\u003e }\u003cbr\u003e}\u003c/pre\u003e"}}]}