首页 > 编程语言 > 详细

用C++实现简单的生成随机数目的四则运算的题目的程序

时间:2018-10-07 18:24:36      阅读:267      评论:0      收藏:0      [点我收藏+]

        private void button1_Click(object sender, EventArgs e)
        {
            double n = Convert.ToDouble(textBox3.Text);
            double m = Convert.ToDouble(textBox2.Text);
            double q = Convert.ToDouble(textBox1.Text);
            richTextBox1.Text = "";
            double[] a = new double[2 * (int)q];
            Random r = new Random();
            for (int i = 0; i < 2 * q; i++)
            {
                double temp = r.Next((int)m, (int)n);
                a[i] = temp;
            }
            for (int i = 0; i < q; i++)
            {
                string c = "+";
                double b = a[i] + a[i + (int)q];
                if (b <= (int)n / 2)
                c = "*";
                if (b > (int)n / 2 && b <= (int)n)
                c = "+";
                if (b > (int)n && b <= (int)n * 1.5)
                c = "/";
                if (b > (int)n * 1.5 && b <= (int)n * 2 && a[i] > a[i + (int)q])
                c = "-";
                richTextBox1.AppendText(a[i].ToString() + (c) + a[i + (int)q].ToString() + ("=") + System.Environment.NewLine);
            }
        }
    }
}技术分享图片技术分享图片

用C++实现简单的生成随机数目的四则运算的题目的程序

原文:https://www.cnblogs.com/lwan/p/9750806.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!