A+B: Difference between revisions
Content deleted Content added
Add Factor |
m Alphabetize |
||
Line 26:
= Solution =
=={{header|C}}==
Line 102 ⟶ 80:
return 0;
}
</lang>
=={{header|C_sharp|C#}}==
<lang csharp>
using System.IO;
class plus {
public static void Main(string[] args) {
int a,b;
{
StreamReader reader = new StreamReader("plus.in");
a = int.Parse(reader.ReadLine());
b = int.Parse(reader.ReadLine());
StreamWriter writer = new StreamWriter("plus.out");
writer.WriteLine(a+b);
writer.Close();
}
}
}
</lang>
=={{header|Factor}}==
<lang factor>: a+b ( -- )
readln " " split1
[ string>number ] bi@ +
number>string print ;</lang>
( scratchpad ) a+b
2 2
4
=={{header|Haskell}}==
<lang text>
import Control.Monad
main = liftM2 (+) readLn readLn >>= print
</lang>
=={{header|Java}}==
<lang java>import java.util.*;
public class Sum2 {
Line 113 ⟶ 126:
System.out.println(in.nextInt() + in.nextInt()); // Standard output
}
}</lang>
Object of [[class]] Scanner works slow enough, because of that contestants prefer to avoid its use. Often, longer solution works faster and easily scales to problems.
<lang java>import java.io.*;
import java.util.*;
Line 168 ⟶ 179:
}</lang>
=={{header|
<lang
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
reset(input, 'input.txt');
rewrite(output, 'output.txt');
readln(a, b);
writeln(a + b);
close(input);
close(output);
end.
</lang>
=={{header|PicoLisp}}==
Line 219 ⟶ 224:
r = fin.readline().split()
fout.write(str(int(r[0]) + int(r[1])))
</lang>
|