Program.cs 923 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.IO;
  3. using System.Linq;
  4. namespace D02._1
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. if (args.Length < 1) return;
  11. if (File.Exists(args[0]) == false) throw new FileNotFoundException();
  12. int sq = 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. var dim = line.Split("x").Select(s => int.Parse(s)).ToArray();
  20. int l = dim[0], w = dim[1], h = dim[2];
  21. int side1 = l * w, side2 = w * h, side3 = h * l;
  22. sq += 2 * side1 + 2 * side2 + 2 * side3 + Math.Min(side1, Math.Min(side2, side3));
  23. }
  24. }
  25. Console.WriteLine($"Answer is : {sq}");
  26. }
  27. }
  28. }