• 大小: 34.33 KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2024-09-29
  • 语言: C#
  • 标签: c#  四则运算  Wingdows  

资源简介

简易四则运算练习系统设计:
设计要求每次出一道题,用户回答,并把题目和结果显示出来。用户可以选择做加减运算和乘除运算,答题有时间限制,并且能够计算用户答题正确率。

资源截图

代码片段和文件信息

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

namespace 进制转换
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        Random rd = new Random();
        Random rd2 = new Random();
        int oper1 oper2;
        char Operation;
        int time=40;
        int counterAll=0 counterRight=0;

        public int GenerateRan()
        {
            
            int a = rd.Next(0 1000);
            return a;
        }
        public int GenRan()
        {
            Random rd2 = new Random();
            int a = rd.Next(0 100);
            return a;
        }

        public char GenerateOper()
        {
           double dou= rd.NextDouble();
           if (dou > 0.5)
               return ‘+‘;
           else return ‘-‘;
        }
        public char GenerateOper2()
        {
            double dou = rd.NextDouble();
            if (dou > 0.5)
                return ‘*‘;
            else return ‘/‘;
        }

       public int GenerateKey(int oper1char operationint oper2)
        {
            switch (operation)
            {
                case ‘+‘:
                    return oper1 + oper2;
                   
                case ‘-‘:
                    return oper1 - oper2;
                    
                case ‘*‘:
                    return oper1 * oper2;
                    
                case ‘/‘:
                    return oper1 / oper2;
                default:
                    return 0;
                   
            }
        }

        private void Form1_Load(object sender EventArgs e)
        {
            radioButton1.Checked = true;
            button2.Enabled = false;
            textBox1.ReadOnly = true;
            lblTime.Text = “剩余时间:“;
            timer1.Enabled = false;
            timer1.Interval = 1000;
           

            
        }

        private void button1_Click(object sender EventArgs e)
        {
            if (radioButton1.Checked == true)
            
                Operation = GenerateOper();
            
            else
                Operation = GenerateOper2();
            oper1=GenerateRan();
            oper2 = GenRan();
            
            textBox1.Text=oper1.ToString()+Operation+oper2.ToString()+“=“;
            button2.Enabled = true;
          
            timer1.Enabled = true;
            

        }

        private void button2_Click(object sender EventArgs e)
        {
            if (textBox2.Text.Trim() == string.Empty)
            {
                MessageBox.Show(“您尚未答题“ “提示“ MessageBoxButtons.OK MessageBoxIcon.Information);
                return;
            }
            counterAll++;
            if (textBox2.Text == GenerateKey(oper1 Operation ope

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       3231  2009-03-22 09:44  进制转换\进制转换.csproj

     文件        471  2009-03-22 09:17  进制转换\Program.cs

     文件       8997  2009-06-15 10:15  进制转换\Form1.Designer.cs

     文件       6008  2009-06-15 10:15  进制转换\Form1.resx

     文件       4080  2009-06-15 10:17  进制转换\Form1.cs

     文件        303  2009-06-15 13:25  进制转换\obj\进制转换.csproj.FileList.txt

    ..A.SHR         8  2009-05-09 17:52  进制转换\obj\Desktop_1.ini

     文件        180  2009-06-15 10:15  进制转换\obj\Debug\进制转换.Form1.resources

     文件        180  2009-03-22 09:44  进制转换\obj\Debug\进制转换.Properties.Resources.resources

     文件      24576  2009-06-15 11:11  进制转换\obj\Debug\进制转换.exe

    ..A.SHR         8  2009-05-09 17:52  进制转换\obj\Debug\Desktop_1.ini

     文件      28160  2009-06-15 11:11  进制转换\obj\Debug\进制转换.pdb

     文件        842  2009-06-15 10:15  进制转换\obj\Debug\进制转换.csproj.GenerateResource.Cache

    ..A.SHR         8  2009-05-09 17:52  进制转换\obj\Debug\TempPE\Desktop_1.ini

    ..A.SHR         8  2009-05-09 17:52  进制转换\bin\Desktop_1.ini

     文件       5632  2005-12-08 14:51  进制转换\bin\Debug\进制转换.vshost.exe

     文件      24576  2009-06-15 11:11  进制转换\bin\Debug\进制转换.exe

     文件      28160  2009-06-15 11:11  进制转换\bin\Debug\进制转换.pdb

    ..A.SHR         8  2009-05-09 17:52  进制转换\bin\Debug\Desktop_1.ini

     文件       5612  2009-03-22 09:17  进制转换\Properties\Resources.resx

     文件        249  2009-03-22 09:17  进制转换\Properties\Settings.settings

     文件       1196  2009-03-22 09:17  进制转换\Properties\AssemblyInfo.cs

     文件       2878  2009-03-22 09:17  进制转换\Properties\Resources.Designer.cs

     文件       1095  2009-03-22 09:17  进制转换\Properties\Settings.Designer.cs

    ..A.SHR         8  2009-05-09 17:51  进制转换\Properties\Desktop_1.ini

     目录          0  2009-06-15 13:21  进制转换\obj\Debug\Refactor

     目录          0  2009-06-15 13:21  进制转换\obj\Debug\TempPE

     目录          0  2009-06-15 13:21  进制转换\obj\Debug

     目录          0  2009-06-15 13:21  进制转换\bin\Debug

     目录          0  2009-06-15 13:21  进制转换\obj

............此处省略6个文件信息

评论

共有 条评论