zoukankan      html  css  js  c++  java
  • 第三次作业

     这是我和寝室的哥们关高磊合作结对一起编程的

      Form1的代码如下:

    uesing System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public static int count;
            public static int t=0;
            public static int shijian;
            public static int z;
            public static int right;
            public Form1()
            {
                InitializeComponent();
            }

            private void button1_Click(object sender, EventArgs e)
            {
                int m = int.Parse(textBox5.Text);
                int n = int.Parse(textBox6.Text);
                if(m>n)
                {
                    MessageBox.Show("亲,选择范围,需要第一个数字大于第二个哦");
                    textBox5.Text = "";
                    textBox6.Text = "";
                    //如果用户用户选择的取数范围不符合的话,则清空
                }
                textBox4.Text = t.ToString();
                timer1.Enabled = true;
                timer1.Interval = 1000;
                timer1.Start();
                Randomsj();


            }
            private void Randomsj()
            {
               
                int m = int.Parse(textBox5.Text);
                int n = int.Parse(textBox6.Text);
                Random sj = new Random();
                int x = sj.Next(m,n);
                int y = sj.Next(m,x);
                //这里让随机数第二个永远小于等于第一个,且获取用户输入的范围
                textBox1.Text = x.ToString();
                textBox2.Text = y.ToString();

                textBox7.Text = comboBox1.Text.ToString();
                textBox3.Text = "";
                count++;
            }

            private void timer1_Tick(object sender, EventArgs e)
            {
                t = t + 1;
                textBox4.Text = t.ToString();
            }

            private void textBox3_KeyDown(object sender, KeyEventArgs e)
            {
                int x = int.Parse(textBox1.Text);
                int y = int.Parse(textBox2.Text);
                string cb = comboBox1.Text;
                switch (cb)
                {
                    case "+":
                        z = x + y;
                        break;
                    case "-":
                        z = x - y;
                        break;
                    case "*":
                        z = x * y;
                        break;
                    case "/":
                        z = x / y;
                        break;
                }
                if(e.KeyCode==Keys.Enter)
                {
                    if(textBox3.Text==z.ToString())
                    right++;
                    Randomsj();
                   

          

                }
            }

            private void button2_Click(object sender, EventArgs e)
            {
                timer1.Enabled = false;
                textBox3.Enabled = false;
                shijian = int.Parse(textBox4.Text);
                //前面shi获取最初的时间,当点击停止时,jian获取现在的时间,shijian则就是form2的所用时间
                Form2 ff = new Form2();
                ff.ShowDialog();
                Form1 f = new Form1();
                f.Close();

           

        }

    }

    Form2的代码如下:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    namespace WindowsFormsApplication1
    {
        public partial class Form2 : Form
        {
            public Form2()
            {
                InitializeComponent();
            }

            private void button1_Click(object sender, EventArgs e)
            {
                this.Close();
            }

            private void Form2_Load(object sender, EventArgs e)
            {
                textBox1.Text = Form1.shijian.ToString();
                textBox2.Text = Form1.count.ToString();
                textBox3.Text = Form1.right.ToString();
                textBox4.Text = ((Form1.right / (double)(Form1.count)) * 100).ToString() + "%";
            }
        }
    }

  • 相关阅读:
    windows p12(pfx)个人证书安装过程
    OpenSSL库验证PKCS7签名
    Crypto库实现PKCS7签名与签名验证
    windows 系统中打开一个数字证书所经历的过程
    DBA不可不知的操作系统内核参数
    MySQL大表优化方案
    深入浅出Cache
    Git Stash用法
    Git服务器搭建全过程分步详解
    laravel 5.1 性能优化对比
  • 原文地址:https://www.cnblogs.com/liti/p/4886309.html
Copyright © 2011-2022 走看看