Oral calculator

From , 4 Years ago, written in C++, viewed 62 times.
URL https://pastebin.vip/view/05a5cf06
  1. #include<iostream>
  2. #include<iomanip>
  3. #include<ctime>
  4. using namespace std;
  5. int add_test(){
  6.         int x,y,z,f,c=0,score=0;
  7.         time_t t;
  8.         srand(time(&t));
  9.         f=rand()%51;
  10.         cout<<"加法测验(共 n 题)"<<endl;
  11.         for(int i=0;i<=f;i++){
  12.                 c++;
  13.                 x=rand()%21;
  14.                 y=rand()%21;
  15.                 cout<<c<<"、"<<setw(2)<<x<<" + "<<setw(2)<<y<<" = ";
  16.                 cin>>z;
  17.                 if(x+y==z)
  18.                         score += 10;
  19.         }
  20.         return score;
  21. }
  22. int sub_test(){
  23.         int x,y,z,f,c=0,score=0;
  24.         time_t t;
  25.         srand(time(&t));
  26.         f=rand()%31;
  27.         cout<<"减法测验(共 n 题)"<<endl;
  28.         for(int i=0;i<=f;i++){
  29.                 c++;
  30.                 x=rand()%51;
  31.                 y=rand()%21;
  32.                 cout<<c<<"、"<<setw(2)<<x<<" - "<<setw(2)<<y<<" = ";
  33.                 cin>>z;
  34.                 if(x-y==z)
  35.                         score += 10;
  36.         }
  37.         return score;
  38. }
  39. int chn_test(){
  40.         int x,y,z,f,c=0,score=0;
  41.         time_t t;
  42.         srand(time(&t));
  43.         f=rand()%21;
  44.         cout<<"乘法测验(共 n 题)"<<endl;
  45.         for(int i=0; i<=f;i++){
  46.                 c++;
  47.                 x=rand()%21;
  48.                 y=rand()%11;
  49.                 cout<<c<<"、"<<setw(2)<<x<<" * "<<setw(2)<<y<<" = ";
  50.                 cin>>z;
  51.                 if(x*y==z)
  52.                         score += 10;
  53.         }
  54.         return score;
  55. }
  56. int chu_test(){
  57.         int x,y,z,f,c=0,score=0;
  58.         time_t t;
  59.         srand(time(&t));
  60.         f=rand()%11;
  61.         cout<<"除法测验(共 n 题)"<<endl;
  62.         for(int i=0;i<=f;i++){
  63.                 c++;
  64.                 x=rand()%51;
  65.                 y=rand()%11;
  66.                 cout<<c<<"、"<<setw(2)<<x<<" ÷ "<<setw(2)<<y<<"="<<" ";
  67.                 cin>>z;
  68.                 if(x/y==z)
  69.                         score += 10;
  70.         }
  71.         return score;
  72. }
  73.  

Reply to "Oral calculator"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website