| 12345678910111213141516171819202122232425262728293031323334 |
- using System;
- using System.IO;
- namespace D01._2
- {
- class Program
- {
- static void Main(string[] args)
- {
- if (args.Length < 1) return;
- if (File.Exists(args[0]) == false) throw new FileNotFoundException();
- int floor = 0;
- string text = "";
- using (var file = File.OpenText(args[0]))
- {
- text = file.ReadToEnd();
- }
- int c = 0;
- foreach (var car in text)
- {
- c++;
- if (car == '(') floor++;
- if (car == ')') floor--;
- if (floor == -1) break;
- }
- Console.WriteLine($"Answer is : {c}");
- }
- }
- }
|