代码拉取完成,页面将自动刷新
<?xml version="1.0" encoding="UTF-8"?>
<fps version="1.2" url="https://github.com/zhblue/freeproblemset/">
<generator name="HUSTOJ" url="https://github.com/zhblue/hustoj/"/>
<item>
<title><![CDATA[送分题-A+B Problem]]></title>
<time_limit unit="s"><![CDATA[1]]></time_limit>
<memory_limit unit="mb"><![CDATA[256]]></memory_limit>
<description><![CDATA[<p>Calculate a+b</p>]]></description>
<input><![CDATA[<p>Two integer a,b (0<=a,b<=10)</p>]]></input>
<output><![CDATA[<p>Output a+b</p>]]></output>
<sample_input><![CDATA[1 2]]></sample_input>
<sample_output><![CDATA[3]]></sample_output>
<test_input><![CDATA[500 17]]></test_input>
<test_output><![CDATA[517]]></test_output>
<test_input><![CDATA[2 3
]]></test_input>
<test_output><![CDATA[5
]]></test_output>
<hint><![CDATA[<p>Q: Where are the input and the output? A: Your program shall always <font color="#ff0000">read input from stdin (Standard Input) and write output to stdout (Standard Output)</font>. For example, you can use 'scanf' in C or 'cin' in C++ to read from stdin, and use 'printf' in C or 'cout' in C++ to write to stdout. You <font color="#ff0000">shall not output any extra data</font> to standard output other than that required by the problem, otherwise you will get a "Wrong Answer". User programs are not allowed to open and read from/write to files. You will get a "Runtime Error" or a "Wrong Answer" if you try to do so. Here is a sample solution for problem 1000 using C++/G++:</p>
<pre>
#include <iostream>
using namespace std;
int main()
{
int a,b;
cin >> a >> b;
cout << a+b << endl;
return 0;
}</pre>
<p>It's important that the return type of main() must be int when you use G++/GCC,or you may get compile error. Here is a sample solution for problem 1000 using C/GCC:</p>
<pre>
#include <stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a, &b);
printf("%d\n",a+b);
return 0;
}</pre>
<p>Here is a sample solution for problem 1000 using PASCAL:</p>
<pre>
program p1000(Input,Output);
var
a,b:Integer;
begin
Readln(a,b);
Writeln(a+b);
end.</pre>
<p>Here is a sample solution for problem 1000 using JAVA: Now java compiler is jdk 1.5, next is program for 1000</p>
<pre>
import java.io.*;
import java.util.*;
public class Main
{
public static void main(String args[]) throws Exception
{
Scanner cin=new Scanner(System.in);
int a=cin.nextInt();
int b=cin.nextInt();
System.out.println(a+b);
}
}</pre>
<p>Old program for jdk 1.4</p>
<pre>
import java.io.*;
import java.util.*;
public class Main
{
public static void main (String args[]) throws Exception
{
BufferedReader stdin =
new BufferedReader(
new InputStreamReader(System.in));
String line = stdin.readLine();
StringTokenizer st = new StringTokenizer(line);
int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
System.out.println(a+b);
}
}</pre>]]></hint>
<source><![CDATA[系统原理,熟悉OJ]]></source>
<solution language="C"><![CDATA[#include <stdio.h>
int main()
{
int a,b;
while(scanf("%d%d",&a,&b)!=EOF)
{
printf("%d\n",a+b);
}
return 0;
}]]></solution>
<solution language="C++"><![CDATA[#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
int a,b;
while(cin >>a >>b)
{
cout <<a+b <<endl;
}
return 0;
}]]></solution>
<solution language="Pascal"><![CDATA[program abprob;
var
a,b:longint;
begin
readln(a,b);
writeln(a+b);
end.]]></solution>
<solution language="Java"><![CDATA[import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner cin = new Scanner(System.in);
int a,b;
while(cin.hasNextInt())
{
a = cin.nextInt();
b = cin.nextInt();
System.out.println(a+b);
}
}
}]]></solution>
<solution language="Bash"><![CDATA[read a b
let c=$a+$b
echo $c]]></solution>
<solution language="Python"><![CDATA[#!/usr/bin/python2
a=raw_input()
b=a.split(" ")
print eval(b[0]+"+"+b[1])
]]></solution>
<solution language="C#"><![CDATA[using System;
class Program {
public static void Main() {
string line;
string []p;
int a,b;
while((line=Console.ReadLine())!=null){
p=line.Split(' ');
a=int.Parse(p[0]);b=int.Parse(p[1]);
Console.WriteLine(a+b);
}
}
}]]></solution>
</item>
</fps>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。