⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 快速排序与最长公共子序列算法(Visual C++)
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Algorithm
{
    
    public partial class Form1 : Form
    {
        private int[] a=new int [8];
        private int p = 0, r = 0;
        private char[] x;
        private char[] y;
        private int m, n;

        public Form1()
        {
            InitializeComponent();
        }

        private void SortNum_digui_TextChanged(object sender, EventArgs e)
        {

        }

        private void NumInput_digui_KeyPress_1(object sender, KeyPressEventArgs e)
        {
            if ((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8)
            {
                e.Handled = true;
            }
        }

        private void NumInput_digui_0_TextChanged(object sender, EventArgs e)
        {
            if (NumInput_digui_0.Text != "")
                a[0] = Int32.Parse(NumInput_digui_0.Text.ToString());
            else a[0] = 0;
        }

        private void NumInput_digui_1_TextChanged(object sender, EventArgs e)
        {
            if (NumInput_digui_1.Text != "")
                a[1] = Int32.Parse(NumInput_digui_1.Text.ToString());
            else a[1] = 0;
        }

        private void NumInput_digui_2_TextChanged(object sender, EventArgs e)
        {
            if (NumInput_digui_2.Text != "")
                a[2] = Int32.Parse(NumInput_digui_2.Text.ToString());
            else a[2] = 0;
        }

        private void NumInput_digui_3_TextChanged(object sender, EventArgs e)
        {
            if (NumInput_digui_3.Text != "")
                a[3] = Int32.Parse(NumInput_digui_3.Text.ToString());
            else a[3] = 0;
        }

        private void NumInput_digui_4_TextChanged(object sender, EventArgs e)
        {
            if (NumInput_digui_4.Text != "")
                a[4] = Int32.Parse(NumInput_digui_4.Text.ToString());
            else a[4] = 0;
        }

        private void NumInput_digui_5_TextChanged(object sender, EventArgs e)
        {
            if (NumInput_digui_5.Text != "")
                a[5] = Int32.Parse(NumInput_digui_5.Text.ToString());
            else a[5] = 0;
        }

        private void NumInput_digui_6_TextChanged(object sender, EventArgs e)
        {
            if (NumInput_digui_6.Text != "")
                a[6] = Int32.Parse(NumInput_digui_6.Text.ToString());
            else a[6] = 0;
        }

        private void NumInput_digui_7_TextChanged(object sender, EventArgs e)
        {
            if (NumInput_digui_7.Text != "")
                a[7] = Int32.Parse(NumInput_digui_7.Text.ToString());
            else a[7] = 0;
        }

        private void pInput_digui_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((e.KeyChar < 48 || e.KeyChar > 55) && e.KeyChar != 8)
            {
                e.Handled = true;
            }
        }

        private void pInput_digui_TextChanged(object sender, EventArgs e)
        {
            if (pInput_digui.Text != "")
                p = Int32.Parse(pInput_digui.Text.ToString());
            else p = 0;
        }

        private void rInput_digui_TextChanged(object sender, EventArgs e)
        {
            if (rInput_digui.Text != "")
                r = Int32.Parse(rInput_digui.Text.ToString());
            else r = -1;
            if (p > r)
            {
                rInput_digui.Text = "";
                MessageBox.Show("   输入错误!\n提示:p应小于等于r");
                r = 0;
                return;
            }
        }

        private void Sort_digui_Click(object sender, EventArgs e)
        {
            int i=0;
            for (i = 0; i <= 7; i++)
                if (a[i] < 0)
                {
                    MessageBox.Show("数列输入有错!请重新输入。");
                    return;
                }
            if(p<0||r<0)
                if (a[i] < 0)
                {
                    MessageBox.Show("p或r输入有错!请重新输入。");
                    return;
                }
            DiGui.QuickSort(a, p,r);
            NumOutput_digui_0.Text = a[0].ToString ();
            NumOutput_digui_1.Text = a[1].ToString ();
            NumOutput_digui_2.Text = a[2].ToString ();
            NumOutput_digui_3.Text = a[3].ToString ();
            NumOutput_digui_4.Text = a[4].ToString ();
            NumOutput_digui_5.Text = a[5].ToString ();
            NumOutput_digui_6.Text = a[6].ToString ();
            NumOutput_digui_7.Text = a[7].ToString ();

        }

        private void ListA_dongtaiguihua_TextChanged(object sender, EventArgs e)
        {
            char[] temp;
            int len=0;
            temp = ListA_dongtaiguihua.Text.ToCharArray();
            m = ListA_dongtaiguihua.Text.Length;
            x = new char[m + 1];
            x[0] = '0';
            for (len = 0; len < m; len++)
                x[len + 1] = temp[len];

        }

        private void ListB_dongtaiguihua_TextChanged(object sender, EventArgs e)
        {
            char[] temp;
            int len = 0;
            temp = ListB_dongtaiguihua.Text.ToCharArray();
            n = ListB_dongtaiguihua.Text.Length;
            y = new char[n + 1];
            y[0] = '0';
            for (len = 0; len < n; len++)
                y[len + 1] = temp[len];

        }

        private void Go_dongtaiguihua_Click(object sender, EventArgs e)
        {
            int len = 0;
            int [,] c=new int[m+1,n+1];
            char[,] b = new char[m + 1, n + 1];
            if (m <= n) len = m;
            else len = n;
            char[] LCSString = new char[len];
            DongTaiGuiHua.LCSLength(m, n, y, x, c, b,LCSString);
            string str = new String(LCSString);
            ListAB_dongtaiguihua.Text =str ; 
        }

       

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -