Sec

Sec


using System;

using System.Threading;


namespace ConsoleApplication60

{

  class Program

  {

    static void Main(string[] args)

    {

      string time;

      int znach = 0, k = 3, Seconds = 0, Minutes = 0, Milliseconds = 0;

      Console.WriteLine("Space - start, 0 - exit, 1 - restart, 2 - resume, 3 - save");

      Console.ForegroundColor = ConsoleColor.Black;

      object a = Console.ReadLine();

      Console.ResetColor();

      if (a.Equals(" ")) znach = 2;

      else Console.WriteLine("Ошибка! Вы ввели неверное значение!");

    m1: switch (znach)

      {

        case 0:

          break;


        case 1:

        case 2:

        case 3:

          while (!Console.KeyAvailable)

          {

            if (znach == 3)

            {

              Console.SetCursorPosition(0, k);

              Console.Write("{0:00}:{1:00}:{2:00}", Minutes, Seconds, Milliseconds);

              k++;

              znach = 2;

            }

            if (znach == 1) { Milliseconds = 0; Seconds = 0; Minutes = 0; }

            time = String.Format("{0:00}:{1:00}:{2:00}", Minutes, Seconds, Milliseconds);

            Milliseconds +=1;

            if (Milliseconds == 100) { Milliseconds = 0; Seconds += 1; }

            if (Seconds == 60) { Seconds = 0; Minutes += 1; }

            if (Minutes == 60) Minutes = 0;

            Console.SetCursorPosition(35, 11);

            Console.Write(time);

            Thread.Sleep(10);

            Console.SetCursorPosition(0, 1);

          }

          Console.ForegroundColor = ConsoleColor.Black;

          znach = Int32.Parse(Console.ReadLine());

          Console.ResetColor();

          if (znach == 0 || znach == 1 || znach == 2 || znach == 3) goto m1;

          else Console.WriteLine("Ошибка! Вы ввели неверное значение!");

          break;


        default:

          Console.WriteLine("Ошибка! Вы ввели неверное значение!");

          break;

      }

      Console.ReadKey();

      return;

    }

  }

}

Report Page