Пример #1
0
        static void Main(string[] args)
        {
            long a;

            do
            {
                Console.WriteLine("Введите число a:");
            }while (!Int64.TryParse(Console.ReadLine(), out a));

            long b;

            do
            {
                Console.WriteLine("Введите число b:");
            }while (!Int64.TryParse(Console.ReadLine(), out b));
            long time;

            Console.WriteLine(Evklid.Gcd(a, b, out time));
            Console.WriteLine("Затраченное время на Gcd - " + time.ToString());
            Console.WriteLine(Evklid.BinaryGcd(a, b, out time));
            Console.WriteLine("Затраченное время на GcdBinary - " + time.ToString());
            Console.WriteLine(Evklid.GcdMany(out time, 150586, 4548595, 90012522, 7525482, -5, 1055842554, 15025485));
            Console.WriteLine("Затраченное время на GcdMany - " + time.ToString());
            Console.ReadLine();
        }
Пример #2
0
        public void Gcd_140and70_70()
        {
            long time;
            long number = Evklid.Gcd(140, 70, out time);

            Assert.AreEqual(number, 70);
            Assert.AreEqual(time, 0);
        }
Пример #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Length < 1 && textBox2.Text.Length < 1)
            {
                MessageBox.Show("Введите числа a и b");
            }
            long timeGcd;
            long timeGcdBinary;
            long timeGcdMany;

            string[] data = richTextBox1.Text.Split(',').ToArray();

            long[] datalong = data.Select(x => Int64.Parse(x)).ToArray();
            textBox3.Text = Evklid.Gcd(Convert.ToInt64(textBox2.Text), Convert.ToInt64(textBox1.Text), out timeGcd).ToString();
            textBox4.Text = Evklid.BinaryGcd(Convert.ToInt64(textBox2.Text), Convert.ToInt64(textBox1.Text), out timeGcdBinary).ToString();
            textBox5.Text = Evklid.GcdMany(out timeGcdMany, datalong).ToString();

            chart1.Series["Execution Time"].Points.AddXY("Gcd", timeGcd);
            chart1.Series["Execution Time"].Points.AddXY("GcdMany", timeGcdMany);
            chart1.Series["Execution Time"].Points.AddXY("GcdBinary", timeGcdBinary);
        }