• 四则运算3.0版本


    最新要求:在线答题、答题结束后可以判断对错和保存结果

    预计时间:五小时

    实际时间:周四 第四第五节课

                    周五晚 18:30-20:00

                     周日  15:30-16:30

    #include<iostream.h>
    #include<stdlib.h>
    #include<time.h>
    void boom()
    {
    float x,y;
    int z,t;
    int first_num,second_num,third_num,fourth_num;
    srand(time(NULL));
    int n;
    float k;
    float d;
    float daan[100];
    int zq=0;
    int cw=0;
    cout<<"需要列出多少到数学题?"<<endl;
    cin>>n;
           for(int i=0;i<n;i++)
     {
          z=rand()%4;
          first_num=rand()%10;
          second_num=rand()%10;
          third_num=rand()%10;
          fourth_num=rand()%10;
       if (second_num==1)
       {
       x=(float)first_num;
       }
      else if(first_num>second_num)
      {
     t=first_num;
     first_num=second_num;
     second_num=t;
      }
    x=(float)first_num/second_num;
    if (fourth_num==1)
    {
    y=(float)third_num;
    }
    else if(third_num>fourth_num)
    {
    t=third_num;
    third_num=fourth_num;
    fourth_num=t;
    }
    y=(float)third_num/fourth_num;
    z=rand()%4;
         switch(z)
      {
          case 0:
            cout<<i+1<<"、 "<<first_num<<"/"<<second_num<<"+"<<third_num<<"/"<<fourth_num<<"="<<" ";
            daan[i+1]=x+y;
          break;
          case 1:
          cout<<i+1<<"、 "<<first_num<<"/"<<second_num<<"-"<<third_num<<"/"<<fourth_num<<"="<<" ";
          daan[i+1]=x-y;
          break;
          case 2:
          cout<<i+1<<"、 "<<first_num<<"/"<<second_num<<"*"<<third_num<<"/"<<fourth_num<<"="<<" ";
          daan[i+1]=x*y;
          break;
          case 3:
           if(y!=0)
        {
            cout<<i+1<<"、 "<<first_num<<"/"<<second_num<<"÷"<<third_num<<"/"<<fourth_num<<"="<<" ";
        }
           else
        {
             i=i-1;
        }
    daan[i+1]=(float)x/y;
    break;
    }
       if((i+1)%3==0)
       {
         for(int c=0;c<=1;c++)
      {
           cout<<endl;
      }
       }
       if((i+1)==n)
       {
         cout<<endl;
       }
        }
         for(i=1;i<=n;i++)
      {
           cout<<"请作答:"<<endl;
           cout<<i<<"、";
           cin>>d;
        if(d==daan[i])
     {
          cout<<"回答正确!"<<endl;
          cout<<endl;
          zq=zq+1;
     }
        else
     {
    cout<<"回答错误,正确答案为:"<<" "<<daan[i]<<endl;
    cout<<endl;
    cw=cw+1;
    }
    }
    k=(float)zq/n;
    cout<<"回答正确的数量为:"<<" "<<zq<<"个"<<endl;
    cout<<"回答错误的数量为:"<<" "<<cw<<"个"<<endl;
    cout<<"正确率为:"<<" "<<k<<endl;
    }
    int main()
    {
    boom();
    main();
    return 0;
    }

    缺点:有时候答案输入正确可能因为空格会报错如图,,还有就是出现了无难度的题目,就是分子是0时候的乘法题。需要加以改进。

    结果截图:

  • 相关阅读:
    单元测试利器 JUnit 4 Mr
    firefox插件介绍 Mr
    js函数使用技巧集合 Mr
    单点登录
    2.SilverLight动态加载控件
    3.如何获取动态生成的SL控件的NAME值(一)
    ASP.Net中控件的EnableViewState属性 【转】
    三种在ASP.NET中重写URL的方法
    SQLHelper.cs
    c# IS与AS的使用方法
  • 原文地址:https://www.cnblogs.com/miniarcher/p/9866034.html
Copyright © 2020-2023  润新知