• 大小: 66.05 KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2024-09-25
  • 语言: ASP
  • 标签:

资源简介

C# asp.net系统 用于随机产生 指定范围 指定数量的四则运算试题

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Text;

namespace Examination
{
    class Exam
    {
        private Random ra = new Random();
        private int _value1 _value2 _operator _answer _range _stAnswer = -1;

       

        /// 
        /// 构造函数
        /// 

        /// 题目范围
        public Exam(int range)
        {
            Range = range;
        }

        /// 
        /// 构造函数
        /// 

        /// 题目范围
        /// 是否自动生成题目
        public Exam(int range bool isAuto)
        {
            Range = range;
            GenRandomOperator();
            switch (Operator)
            {
                case 1:
                    GenAddExam();
                    break;
                case 2:
                    GenSubstractionExam();
                    break;
                case 3:
                    GenMultiplicationExam();
                    break;
                default:
                    GenDividerExam();
                    break;
            }
        }

        /// 
        /// 生成加法
        /// 

        public void GenAddExam()
        {
            Value1 = ra.Next(1 Range);
            Value2 = ra.Next(1 Range - Value1 + 1);
            Answer = Value1 + Value2;
        }

        /// 
        /// 生成减法
        /// 

        public void GenSubstractionExam()
        {
            Value1 = ra.Next(1 Range + 1);
            Value2 = ra.Next(1 Value1 + 1);
            Answer = Value1 - Value2;
        }

        /// 
        /// 生成乘法
        /// 

        public void GenMultiplicationExam()
        {
            Value1 = ra.Next(1 Range + 1);
            Value2 = ra.Next(1 Convert.ToInt32(Range / Value1) + 1);
            Answer = Value1 * Value2;
        }

        /// 
        /// 生成除法
        /// 

        public void GenDividerExam()
        {
            Value2 = ra.Next(1 Range + 1);
            Answer = ra.Next(1 Convert.ToInt32(Range / Value2) + 1);
            Value1 = Value2 * Answer;
        }

        /// 
        /// 生成随机的操作符
        /// 

        public void GenRandomOperator()
        {
            Operator = ra.Next(1 5);
        }

        /// 
        /// 获得操作符字符
        /// 

        /// 操作符字符
        public string GetOperator()
        {
            switch (Operator)
            {
                case 1:
                    return “+“;
                case 2:
                    return “-“;
                case 3:
                    return “ד;
                default:
                    return “÷“;
            }
        }

        /// 
        /// 打印函数
        /// 

        /// 

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

     文件        922  2009-04-02 08:09  Examination1\Examination.sln

    ..A..H.     15872  2009-05-03 08:44  Examination1\Examination.suo

     文件       4324  2009-06-08 11:28  Examination1\Examination\Exam.cs

     文件       3623  2009-04-09 14:56  Examination1\Examination\Examination.csproj

     文件      23298  2009-04-09 15:08  Examination1\Examination\Form1.cs

     文件      49829  2009-04-09 14:54  Examination1\Examination\Form1.Designer.cs

     文件       5814  2009-04-09 14:54  Examination1\Examination\Form1.resx

     文件        588  2009-04-09 15:04  Examination1\Examination\FormScore.cs

     文件       2318  2009-04-09 15:04  Examination1\Examination\FormScore.Designer.cs

     文件       5814  2009-04-09 15:04  Examination1\Examination\FormScore.resx

     文件        470  2009-04-02 08:09  Examination1\Examination\Program.cs

     文件      45056  2009-05-03 08:43  Examination1\Examination\bin\Debug\Examination.exe

     文件      83456  2009-05-03 08:43  Examination1\Examination\bin\Debug\Examination.pdb

     文件       5632  2005-12-08 14:51  Examination1\Examination\bin\Debug\Examination.vshost.exe

     文件        339  2009-05-03 08:44  Examination1\Examination\obj\Examination.csproj.FileList.txt

     文件        904  2009-04-10 10:06  Examination1\Examination\obj\Debug\Examination.csproj.GenerateResource.Cache

     文件      45056  2009-05-03 08:43  Examination1\Examination\obj\Debug\Examination.exe

     文件        180  2009-04-09 14:54  Examination1\Examination\obj\Debug\Examination.Form1.resources

     文件        180  2009-04-09 15:04  Examination1\Examination\obj\Debug\Examination.FormScore.resources

     文件      83456  2009-05-03 08:43  Examination1\Examination\obj\Debug\Examination.pdb

     文件        180  2009-04-09 14:54  Examination1\Examination\obj\Debug\Examination.Properties.Resources.resources

     文件        762  2009-04-16 20:10  Examination1\Examination\obj\Examination.csproj.FileListAbsolute.txt

     文件       1170  2009-04-02 08:09  Examination1\Examination\Properties\AssemblyInfo.cs

     文件       2876  2009-04-02 08:09  Examination1\Examination\Properties\Resources.Designer.cs

     文件       5612  2009-04-02 08:09  Examination1\Examination\Properties\Resources.resx

     文件       1094  2009-04-02 08:09  Examination1\Examination\Properties\Settings.Designer.cs

     文件        249  2009-04-02 08:09  Examination1\Examination\Properties\Settings.settings

     目录          0  2009-04-16 13:23  Examination1\Examination\obj\Debug\Refactor

     目录          0  2009-04-16 13:23  Examination1\Examination\obj\Debug\TempPE

     目录          0  2009-04-16 13:23  Examination1\Examination\bin\Debug

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

评论

共有 条评论

相关资源