diff options
author | Serghei Cebotari <serghei@cebotari.ru> | 2023-08-09 09:42:50 +0300 |
---|---|---|
committer | Serghei Cebotari <serghei@cebotari.ru> | 2023-08-09 09:42:50 +0300 |
commit | c9ca856d8f76d3b4c86532defa04d47c0d0a17f2 (patch) | |
tree | f71839a0721050f89e120695faefcd203ab0fd2e /Codeforces.Console | |
parent | d6adac69ab2ebcbb4b0b234005b4f928319e5cb3 (diff) |
Simple task
Diffstat (limited to 'Codeforces.Console')
-rw-r--r-- | Codeforces.Console/IOTester.cs | 54 | ||||
-rw-r--r-- | Codeforces.Console/Program.cs | 19 |
2 files changed, 71 insertions, 2 deletions
diff --git a/Codeforces.Console/IOTester.cs b/Codeforces.Console/IOTester.cs new file mode 100644 index 0000000..c5ffc77 --- /dev/null +++ b/Codeforces.Console/IOTester.cs @@ -0,0 +1,54 @@ +namespace Codeforces +{ + public class IOTester + { + private static readonly TextReader originalStdIn = Console.In; + private static StringReader? stdIn; + + private static readonly TextWriter originalStdOut = Console.Out; + private static StringWriter? stdOut; + + public static void Start() + { + stdOut = new StringWriter(); + Console.SetOut(stdOut); + } + + public static void End() + { + stdOut = null; + stdIn = null; + Console.SetOut(originalStdOut); + Console.SetIn(originalStdIn); + } + + public static void SetInput(params string[] lines) + { + string input = string.Join(Environment.NewLine, lines); + stdIn = new StringReader(input); + Console.SetIn(stdIn); + } + + public static string GetOutput() + { + if (stdOut == null) + { + return ""; + } + else + { + return stdOut.ToString(); + } + } + + public static string[] GetOutputLines() + { + return GetOutput().Split(Environment.NewLine); + } + + public static IList<string> GetOutputLinesAsList() + { + return new List<string>(GetOutputLines()); + } + } +}
\ No newline at end of file diff --git a/Codeforces.Console/Program.cs b/Codeforces.Console/Program.cs index 3751555..21ac3e9 100644 --- a/Codeforces.Console/Program.cs +++ b/Codeforces.Console/Program.cs @@ -1,2 +1,17 @@ -// See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); +namespace Codeforces +{ + public class Program + { + public static void Main(string[] args) + { + int count = int.Parse(Console.ReadLine()!); + for (int i = 0; i < count; i++) + { + var numbers = Console.ReadLine()! + .Split(' ') + .Select(x => int.Parse(x)); + Console.WriteLine(numbers.Sum()); + } + } + } +}
\ No newline at end of file |