A+B: Difference between revisions
Content deleted Content added
m Alphabetize |
→Solution: whitespace improvements |
||
Line 25:
|}
=
=={{header|C}}==
<lang c>// Standard input-output streams▼
<lang c>▼
▲// Standard input-output streams
#include <stdio.h>
main()
Line 50 ⟶ 49:
printf("%d\n", a + b);
return 0;
</lang>▼
=={{header|C++}}==
<lang cpp>// Standard input-output streams
#include <iostream>
using namespace std;
Line 64 ⟶ 61:
cout << a + b << endl;
return 0;
▲}</lang>
<lang cpp>// Input file: input.txt▼
</lang>▼
<lang cpp>▼
▲// Input file: input.txt
// Output file: output.txt
#include <fstream>
Line 79 ⟶ 74:
out << a + b << endl;
return 0;
▲}</lang>
</lang>▼
=={{header|C_sharp|C#}}==
<lang csharp>using System.IO;
class plus {
Line 98 ⟶ 91:
}
}
</lang>▼
=={{header|Factor}}==
Line 106 ⟶ 98:
[ string>number ] bi@ +
number>string print ;</lang>
<pre>
=={{header|Haskell}}==
<lang text>import Control.Monad
main = liftM2 (+) readLn readLn >>= print</lang>
=={{header|Java}}==
Line 156 ⟶ 147:
out.println(nextInt() + nextInt());
}
▲}</lang>
<lang java>import java.io.*;
Line 180 ⟶ 170:
=={{header|Pascal}}==
<lang pascal>var
a, b: integer;
begin
readln(a, b);
writeln(a + b);
end.</lang>
Same with input from file <tt>input.txt</tt> and output from file <tt>output.txt</tt>.
<lang pascal>var
a, b: integer;
begin
Line 199 ⟶ 186:
close(input);
close(output);
end.</lang>
=={{header|PicoLisp}}==
Line 208 ⟶ 194:
=={{header|Scheme}}==
<lang scheme>(write (+ (read) (read)))</lang>
=={{header|Python}}==
===Console===
<lang python>r = raw_input().split()
print int(r[0]) + int(r[1])</lang>▼
▲print int(r[0]) + int(r[1])
===File===
<lang python>fin = open("input.txt", "r")
fout = open("output.txt","w")
r = fin.readline().split()
fout.write(str(int(r[0]) + int(r[1])))</lang>
=={{header|Ruby}}==
<lang ruby>puts gets.split(/\s+/).map{|x| x.to_i}.inject{|sum, x| sum + x}</lang>▼
▲puts gets.split(/\s+/).map{|x| x.to_i}.inject{|sum, x| sum + x}
|