Program.cs 868 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.IO;
  3. using System.Linq;
  4. namespace D03._1
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. if (args.Length < 1) throw new ArgumentException();
  11. if (File.Exists(args[0]) == false) throw new FileNotFoundException();
  12. int answer = 0;
  13. using (var file = File.OpenText(args[0]))
  14. {
  15. while (true)
  16. {
  17. var line = file.ReadLine();
  18. if (line == null) break;
  19. int[] l = line.Split(' ', StringSplitOptions.RemoveEmptyEntries).Select(s => int.Parse(s)).ToArray();
  20. answer += l[0] + l[1] > l[2] && l[0] + l[2] > l[1] && l[1] + l[2] > l[0] ? 1 : 0;
  21. }
  22. }
  23. Console.WriteLine($"The answer is : {answer}");
  24. }
  25. }
  26. }