| 1234567891011121314151617181920212223242526 |
- using System;
- using System.IO;
- using System.Text.RegularExpressions;
- namespace D12._1
- {
- class Program
- {
- static void Main(string[] args)
- {
- if (args.Length < 1) throw new ArgumentException();
- if (File.Exists(args[0]) == false) throw new FileNotFoundException();
- var input = File.ReadAllText(args[0]);
- int answer = 0;
- var regex = new Regex(@"(-?\d+)");
- var matches = regex.Matches(input);
- foreach (Match match in matches)
- answer += int.Parse(match.Value);
- Console.WriteLine($"The answer is : {answer}");
- }
- }
- }
|