最大连续子数和问题-homework-03

一、说明

  这次的作业做的不好,一小点怨念ing·····

  首先向TA说明下,我的小伙伴“丢下”我后我不知道,以至于发现剩下我一个的时间有点晚,我机智地找到了一个3个人的小组,又叫到了一个小伙伴,但是悲剧的是他已经开始和那两个人一起做这次的作业了,,从下次开始和我结对,所以这次只能自己做了,从下次作业开始我将和新的小伙伴一起做!

二、程序思路

1、命令行和 GUI

  首先,我把判断命令行添加到程序的主入口点,同时在这里判断命令。

/// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main(string[] argv)
        {
            string path;
            int argc = argv.Length;
            int vflag = 0, hflag = 0, aflag = 0;
            switch (argc)
            {
                case 1:
                    Console.WriteLine("缺失参数!");
                    break;
                case 2:
                    path = argv[1];
                    Console.WriteLine("缺失文件前参数 " + path + " !");
                    break;
                case 3:
                    switch (argv[1][1])
                    {
                        case 'v':
                            vflag = 1;
                            break;
                        case 'h':
                            hflag = 1;
                            break;
                        case 'a':
                            aflag = 1;
                            break;
                        default:
                            Console.WriteLine("错误: " + argv[1]);
                            break;
                    }
                    path = argv[2];
                    break;

2、图形界面能同时显示多个数组的运算结果

  在这里,我是用程序的[STAThread]线程,只要GUI不关,该线程就不会停止,所以可以出现两个tab任意切换,每次启动程序都会新建一个tab

this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1.SuspendLayout();

3、GUI界面布局

  考虑到不会用别的空间输出内容,就用了button,使其失去点击的功能,就可以作为输出的背景,以便于出现不同的颜色,控制好button之间的布局,就可以形成类似表格的界面。

 this.tabControl1 = new System.Windows.Forms.TabControl();
            this.tabPage1.SuspendLayout();
            // 
            // tabControl1
            // 
            this.tabControl1.Controls.Add(this.tabPage1);
            this.tabControl1.Location = new System.Drawing.Point(3, 0);
            this.tabControl1.Name = "tabControl1";
            this.tabControl1.SelectedIndex = 0;
            this.tabControl1.Size = new System.Drawing.Size(779, 337);
            this.tabControl1.TabIndex = 0;
            // 
            // tabPage1
            // 
            this.tabPage1.Controls.Add(this.button1);
            this.tabPage1.Location = new System.Drawing.Point(5, 2);
            this.tabPage1.Name = "tabPage1";
            this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
            this.tabPage1.Size = new System.Drawing.Size(771, 311);
            this.tabPage1.TabIndex = 0;
            this.tabPage1.Text = argv[argv.Length-1];
            this.tabPage1.UseVisualStyleBackColor = true;



            for (int i = 0; i < row; i++)
            {
                for (int j = 0; j < col; j++)
                {
                    this.button1 = new System.Windows.Forms.Button();
                    this.SuspendLayout();
                    // 
                    // button1
                    // 
                    if (a[i][j][1] == 0)
                        this.button1.BackColor = System.Drawing.Color.Yellow;
                    else
                        this.button1.BackColor = System.Drawing.Color.White;
                    this.button1.Enabled = false;
                    this.button1.Location = new System.Drawing.Point(5+60*j, 30+30*i);
                    this.button1.Name = "button1";
                    this.button1.Size = new System.Drawing.Size(60, 30);
                    this.button1.TabIndex = 0;
                    this.button1.Text = a[i][j][0].ToString();
                    this.button1.UseVisualStyleBackColor = false;
                }
            }

引用上次作业的类,在需要的数据上做上标记,最后的时候重新读取一遍数据,遇到标记数时,将背景色改为黄色,同时,每个button的坐标刚好相隔一个button的长宽,就可以把图形连接起来!

原文地址:https://www.cnblogs.com/jun1022/p/3379715.html