标题:c#编写一个窗体出题的题,代码有误,希望帮看看
取消只看楼主
紫小念
Rank: 1
来 自:山东
等 级:新手上路
帖 子:27
专家分:0
注 册:2013-5-14
结帖率:60%
已结贴  问题点数:20 回复次数:1 
c#编写一个窗体出题的题,代码有误,希望帮看看
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Pro67
{
    public partial class Form1 : Form
    {
        int x = 1, op1, op2, op, re1, re2, re3, re4, re5, right = 0, error = 0, score = 0;
        string ss;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            label1.Text = ct(out re1);//re1...第一个式子的正确结果
            label2.Text = ct(out re2);
            label3.Text = ct(out re3);
            
        }
        public String tj(String  s,int r) {
            if (int.Parse(s) == r)
            {
                right += 1;
                return "正确";

            }
            else {
                error += 1;
                return"错误";
            }
        
        }


        private void Form1_Load(object sender, EventArgs e)
        {
            
        }

        private void 简单ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            x = 1;
        }

        private void 中等ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            x = 2;
        }

        private void 极难ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            x = 3;
        }
        public String ct(out int re) {
            Random rad = new Random();
            op = rad.Next(0, 3) + 1;
            if(x==1){
                op1 = rad.Next(0,9) + 1;
                op2 = rad.Next(0, 9) + 1;

            }
            else if (x == 2)
            {
                Random rnd = new Random();
                op1 = rnd.Next(9, 19) + 1;
                op2 = rnd.Next(9, 19) + 1;
                op = rnd.Next(0, 3) + 1;  //[1,4]
            }
            else {
                Random rnd = new Random();
                op1 = rnd.Next(19, 29) + 1;      
                op2 = rnd.Next(19, 29) + 1;
                op = rnd.Next(0, 3) + 1;   
            }
            switch (op)
            {
                case 1: re = op1 + op2;
                    ss = op1.ToString() + "+" + op2.ToString() + "="; break;
                case 2: re = op1 - op2;
                    ss = op1.ToString() + "-" + op2.ToString() + "="; break;
                case 3: re = op1 * op2;
                    ss = op1.ToString() + "*" + op2.ToString() + "="; break;
                case 4: re = op1 / op2;
                    ss = op1.ToString() + "/" + op2.ToString() + "="; break;
            }
            re = 1;
            return ss;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            label4.Text = tj(textBox1.Text,re1);
            label5.Text = tj(textBox2.Text,re2);
            label6.Text = tj(textBox3.Text,re3);
            richTextBox1.Text += DateTime.Now.Year + "年" + DateTime.Now.Month + "月" + DateTime.Now.Day + "日  ,做的题是:"
            + label1.Text + textBox1.Text + label4.Text + "," + label2.Text + textBox2.Text + label5.Text + "," + label3.Text + textBox3.Text + label6.Text + ",成绩" + score;
        }

    }
}
出的题都一样,而且给出正确答案,还是说是错的,怎么回事?
搜索更多相关主题的帖子: private public 
2013-06-23 11:08
紫小念
Rank: 1
来 自:山东
等 级:新手上路
帖 子:27
专家分:0
注 册:2013-5-14
得分:0 
回复 4楼 lxb932979339
是课程设计
2013-06-26 16:58



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-415859-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.059648 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved