示例#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 BinaryGcd_10and20_10()
        {
            //arrange
            var expected = 10L;
            var time     = 0L;

            //act
            var actual = Evklid.BinaryGcd(10, 20, out time);

            //assert
            Assert.AreEqual(expected, actual);
            Assert.AreEqual(0, time, 1);
        }
示例#3
0
        public void BinaryGcd_0and15_15()
        {
            //arrange
            var expected = 15L;
            var time     = 0L;

            //act
            var actual = Evklid.BinaryGcd(0, 15, out time);

            //assert
            Assert.AreEqual(expected, actual);
            Assert.AreEqual(0, time, 1);
        }
示例#4
0
        public void BinaryGcd_70and140_70()
        {
            //arrange
            var expected = 70L;
            var time     = 0L;

            //act
            var actual = Evklid.BinaryGcd(70, 140, out time);

            //assert
            Assert.AreEqual(expected, actual);
            Assert.AreEqual(0, time, 1);
        }
示例#5
0
        public void BinaryGcd_minus20and31_1()
        {
            //arrange
            var expected = 1L;
            var time     = 0L;

            //act
            var actual = Evklid.BinaryGcd(-20, 31, out time);

            //assert
            Assert.AreEqual(expected, actual);
            Assert.AreEqual(0, time, 1);
        }
示例#6
0
        public void BinaryGcd_31and16_1()
        {
            //arrange
            var expected = 1L;
            var time     = 0L;

            //act
            var actual = Evklid.BinaryGcd(31, 16, out time);

            //assert
            Assert.AreEqual(expected, actual);
            Assert.AreEqual(0, time, 1);
        }
示例#7
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);
        }