| 12345678910111213141516171819202122232425262728293031323334 |
- using System;
- using System.IO;
- using System.Text.RegularExpressions;
- namespace D08._2
- {
- class Program
- {
- static void Main(string[] args)
- {
- if (args.Length < 1) throw new ArgumentException();
- if (File.Exists(args[0]) == false) throw new FileNotFoundException();
- int original = 0, escaped = 0;
- using (var file = File.OpenText(args[0]))
- {
- while (true)
- {
- var line = file.ReadLine();
- if (line == null) break;
- var nstring = '"' + Regex.Escape(line).Replace("\"", "\\\"") + '"';
- original += line.Length;
- escaped += nstring.Length;
- }
- }
- int answer = escaped - original;
- Console.WriteLine($"The answer is : {answer}");
- }
- }
- }
|