Пример #1
0
        static void Main()
        {
            var records = new List <long>();

            while (true)
            {
                try
                {
                    using (var sc = new SetConsole())
                    {
                        var sw = new Stopwatch();
                        sw.Start();
                        Program.Main(null);
                        sw.Stop();
                        records.Add(sw.ElapsedMilliseconds);
                        sw.Reset();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    Console.WriteLine("\n====================");
                    Console.WriteLine("Process was supended");
                    Console.WriteLine("====================\n");
                }
                if (records.Any())
                {
                    Console.WriteLine("\n====================");
                    Console.WriteLine($"Time is {records.Last()}ms");
                    Console.WriteLine($"AveTime is {records.Average()}ms");
                    Console.WriteLine("====================\n");
                }
            }
        }
Пример #2
0
 public static void Main(string[] args)
 {
     using (var sc = new SetConsole())
     {
         int n     = GetString().ToInt();
         var str   = GetString();
         int count = 0;
         var flg   = false;
         var prev  = -1;
         for (int i = 0; i < n; i++)
         {
         }
         int charge = 0;
         for (int i = 0; i < n - 1; i++)
         {
             if (str[i] == '#' && str[i + 1] == '#')
             {
                 charge++;
             }
             else if (str[i] == '#' && str[i + 1] == '.')
             {
                 count = charge != 0 ? charge : 1;
                 if (flg && prev == i - 1)
                 {
                     count--;
                     flg = false;
                 }
                 else
                 {
                     flg = true;
                 }
                 prev   = i + 1;
                 charge = 0;
             }
             else
             {
                 charge = 0;
             }
         }
         CWrite(count);
     }
 }