当前位置:   article > 正文

测试四则运算

jmeter 四则运算

我这次测试的为取值范围

分别取都为正数 负数 正负数都有 已经到10000取值是是否正确

  1 #include<iostream.h>
  2 #include<stdlib.h>
  3 #include<time.h>
  4 int main()
  5 {
  6     srand(time(NULL));
  7     int a, b, c,d,f,g,h,p,q,r,s;
  8     cout<<"请输入计算的数值范围(min):";
  9         cin>>p;
 10     cout<<"请输入计算的数值范围(max):";
 11         cin>>q;
 12     cout<<"请输入题目数量i= ";
 13         cin>>d;
 14     cout<<"是否需要乘除法1/0 :";
 15         cin>>f;
 16     cout<<"是否需要加入括号1/0:";
 17         cin>>g;
 18         if (f==1)
 19     {
 20         if(g==1)
 21             for(int i = 1; i <= d; i++)
 22             {
 23              a = rand() % (q-p+1)+p;
 24              b = rand() % (q-p+1)+p;
 25              h = rand() % (q-p+1)+p;
 26              c = rand() % 6;
 27                 switch (c)
 28              {
 29             case 0:
 30                 cout<< a << "+" << b << "=" << endl;
 31                 break;
 32             case 1:
 33                 cout<< a << "-" << b << "=" << endl;
 34                 break;
 35             case 2:
 36                 cout<< a << "*" << b << "=" << endl;
 37                 break;
 38             case 3:
 39                 cout<< a << "/" << b << "=" << endl;
 40                 break;
 41             case 4:
 42                 cout<<"("<<a<<"+"<<b<<")"<<"-"<<h<<"="<<endl;
 43                 break;
 44             case 5:
 45                 cout<<"("<<a<<"-"<<b<<")"<<"+"<<h<<"="<<endl;
 46              }
 47             }
 48         else
 49             for(int i = 1; i <= d; i++)
 50             {
 51              a = rand() % (q-p+1)+p;
 52              b = rand() % (q-p+1)+p;
 53              c = rand() % 4;
 54                 switch (c)
 55              {
 56             case 0:
 57                 cout<< a << "+" << b << "=" << endl;
 58                 break;
 59             case 1:
 60                 cout<< a << "-" << b << "=" << endl;
 61                 break;
 62             case 2:
 63                 cout<< a << "*" << b << "=" << endl;
 64                 break;
 65             case 3:
 66                 cout<< a << "/" << b << "=" << endl;
 67                 break;
 68              }
 69             }
 70     }
 71     else
 72         if(g==1)
 73         for(int i = 1; i <= d; i++)
 74         {
 75         a = rand() % (q-p+1)+p;
 76         b = rand() % (q-p+1)+p;
 77         h = rand() % (q-p+1)+p;
 78         c = rand() % 4;
 79         switch (c)
 80         {
 81             case 0:
 82               cout<< a << '+'<< b << "=" << endl;
 83               break;
 84             case 1:
 85               cout<< a << "-" << b << "=" << endl;
 86               break;
 87             case 2:
 88                 cout<<"("<<a<<"+"<<b<<")"<<"-"<<h<<"="<<endl;
 89                 break;
 90             case 3:
 91                 cout<<"("<<a<<"-"<<b<<")"<<"+"<<h<<"="<<endl;
 92         }
 93         }
 94         else
 95             for(int i = 1; i <= d; i++)
 96             {
 97              a = rand() % (q-p+1)+p;
 98              b = rand() % (q-p+1)+p;
 99              c = rand() % 2;
100              switch (c)
101              {
102             case 0:
103               cout<< a << "+" << b << "=" << endl;
104               break;
105             case 1:
106               cout<< a << "-" << b << "=" << endl;
107               break;
108              }
109             }
110         return 0;
111 }

 此次测试全部正确 没有出现错误。就这样。。。

转载于:https://www.cnblogs.com/gaiiiiiiii/p/4345676.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/在线问答5/article/detail/830127
推荐阅读
相关标签
  

闽ICP备14008679号