Exemple #1
0
        private void Do(object sender, RoutedEventArgs e)
        {
            TimeSpan time;
            long     result = 0;

            try
            {
                List <long> numbers = new List <long>();
                if (one.Text != "")
                {
                    numbers.Add(Convert.ToInt64(one.Text));
                }
                ;
                if (two.Text != "")
                {
                    numbers.Add(Convert.ToInt64(two.Text));
                }
                ;
                if (three.Text != "")
                {
                    numbers.Add(Convert.ToInt64(three.Text));
                }
                ;
                if (four.Text != "")
                {
                    numbers.Add(Convert.ToInt64(four.Text));
                }
                ;
                if (five.Text != "")
                {
                    numbers.Add(Convert.ToInt64(five.Text));
                }
                ;

                switch (numbers.Count)
                {
                case 2: result = GCD.Euclidean(out time, numbers[0], numbers[1]); break;

                case 3: result = GCD.Euclidean(out time, numbers[0], numbers[1], numbers[2]); break;

                case 4: result = GCD.Euclidean(out time, numbers[0], numbers[1], numbers[2], numbers[3]); break;

                case 5: result = GCD.Euclidean(out time, numbers[0], numbers[1], numbers[2], numbers[3], numbers[4]); break;

                default: throw new Exception();
                }
                string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", time.Hours, time.Minutes, time.Seconds, time.Milliseconds / 10);
                if (result != 0)
                {
                    MessageBox.Show($"НОД чисел является число {result}. Время выполнения: {elapsedTime}");
                }
            }
            catch { MessageBox.Show("Заполните поля правильно!"); }
        }
Exemple #2
0
 private void DoCompare(object sender, RoutedEventArgs e)
 {
     try
     {
         TimeSpan timeE;
         TimeSpan timeS;
         GCD.Euclidean(out timeE, Convert.ToInt64(OneE.Text), Convert.ToInt64(TwoE.Text));
         GCD.BinaryEuclidean(out timeS, Convert.ToInt64(OneS.Text), Convert.ToInt64(TwoS.Text));
         string elapsedTimeE = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", timeE.Hours, timeE.Minutes, timeE.Seconds, timeE.Milliseconds / 10);
         string elapsedTimeS = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", timeS.Hours, timeS.Minutes, timeS.Seconds, timeS.Milliseconds / 10);
         ResultEuclidean.Text = $"Алгоритм Евклида " + elapsedTimeE;
         ResultStein.Text     = $"Алгоритм Стейна " + elapsedTimeS;
     }
     catch { MessageBox.Show("Заполните поля правильно!"); }
 }
Exemple #3
0
        private void DoB(object sender, RoutedEventArgs e)
        {
            TimeSpan time;
            long     result = 0;

            try
            {
                result = GCD.BinaryEuclidean(out time, Convert.ToInt64(oneB.Text), Convert.ToInt64(twoB.Text));
                string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", time.Hours, time.Minutes, time.Seconds, time.Milliseconds);
                if (result != 0)
                {
                    MessageBox.Show($"НОД чисел является число {result}. Время выполнения: {elapsedTime}");
                }
            }
            catch { MessageBox.Show("Заполните поля правильно!"); }
        }