Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            textBox1.Text = string.Empty;
            int n = 0;

            int.TryParse(textBox2.Text, out n);
            PascalTriangle pascal = new PascalTriangle();
            Stopwatch      sw     = new Stopwatch();

            sw.Reset();
            sw.Start();
            pascal.CreatePascal_AnotherVersion(n, textBox1);
            sw.Stop();
            MessageBox.Show(string.Format("遞迴使用了{0}毫秒", sw.ElapsedMilliseconds.ToString()));
            sw.Reset();
            sw.Start();
            pascal.CreatePascal(n, textBox1);
            sw.Stop();
            MessageBox.Show(string.Format("矩陣使用了{0}毫秒", sw.ElapsedMilliseconds.ToString()));
        }