using System using System IO using System Linq class AddRev const stri

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using System;
using System.IO;
using System.Linq;
class AddRev
{
const string FileName = "/home/red-agent/AddRev.in";
static string Reverse(string x)
{
return new string(x.Reverse().ToArray());
}
static void Main()
{
foreach (string line in File.ReadAllLines(FileName))
{
string[] tokens = line.Split(' ');
int[] operands = new int[tokens.Length];
for (int i = 0; i < operands.Length; i++)
{
operands[i] = int.Parse(Reverse(tokens[i]));
}
Console.WriteLine(Reverse(operands.Sum().ToString().TrimEnd('0')));
}
}
}