A+B: Difference between revisions

13 bytes removed ,  14 years ago
→‎Solution: whitespace improvements
m (Alphabetize)
(→‎Solution: whitespace improvements)
Line 25:
|}
 
= SolutionSolutions =
 
=={{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 c>
}
</lang>
 
=={{header|C++}}==
<lang cpp>// Standard input-output streams
// 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;
using System.IO;
 
class plus {
Line 98 ⟶ 91:
}
}
}</lang cpp>
}
</lang>
 
=={{header|Factor}}==
Line 106 ⟶ 98:
[ string>number ] bi@ +
number>string print ;</lang>
<pre>
 
( scratchpad ) a+b
2 2
4
</langpre>
 
=={{header|Haskell}}==
<lang text>import Control.Monad
import Control.Monad
 
main = liftM2 (+) readLn readLn >>= print</lang>
</lang>
 
=={{header|Java}}==
Line 156 ⟶ 147:
out.println(nextInt() + nextInt());
}
}</lang>
}
</lang>
 
<lang java>import java.io.*;
Line 180 ⟶ 170:
 
=={{header|Pascal}}==
<lang pascal>var
var
a, b: integer;
begin
readln(a, b);
writeln(a + b);
end.</lang>
</lang>
Same with input from file <tt>input.txt</tt> and output from file <tt>output.txt</tt>.
<lang pascal>var
var
a, b: integer;
begin
Line 199 ⟶ 186:
close(input);
close(output);
end.</lang>
</lang>
 
=={{header|PicoLisp}}==
Line 208 ⟶ 194:
 
=={{header|Scheme}}==
<lang scheme>(write (+ (read) (read)))</lang>
(write (+ (read) (read)))
</lang>
 
=={{header|Python}}==
===Console===
<lang python>r = raw_input().split()
print int(r[0]) + int(r[1])</lang>
r = raw_input().split()
print int(r[0]) + int(r[1])
</lang>
===File===
<lang python>fin = open("input.txt", "r")
fin = open("input.txt", "r")
fout = open("output.txt","w")
r = fin.readline().split()
fout.write(str(int(r[0]) + int(r[1])))</lang>
</lang>
 
=={{header|Ruby}}==
<lang ruby>puts gets.split(/\s+/).map{|x| x.to_i}.inject{|sum, x| sum + x}</lang>
<lang ruby>
puts gets.split(/\s+/).map{|x| x.to_i}.inject{|sum, x| sum + x}
</lang>
Anonymous user