#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<ctime>
using namespace std;
int Addtest(int a,int b)
{
return (a+b);
}
int jiantest(int a,int b)
{
return (a-b);
}
int chengtest(int a,int b)
{
return (a*b);
}
int chutest(int a,int b)
{
int c=a/b;
return c;
}
int main()
{
int a,b,i,Add,jian,cheng,chu;
int count=0;
int right=0;
int q[10];
char str[4]={'+','-','*','/'};
while(1)
{
srand((unsigned)time(NULL));
a=rand()%10+1;
b=rand()%10+1;
i=rand()%4+1;
Add=Addtest(a,b);
jian=jiantest(a,b);
cheng=chengtest(a,b);
chu=chutest(a,b);
switch(i)
{
case 1:
count++;
cout<<a<<"+"<<b<<"=";
cin>>q[i];
if(q[i]==Add)
{
cout<<"Right!"<<endl;
right++;
}
else
cout<<"Not correct!"<<endl;
break;
case 2:
if(a>b)
{
cout<<a<<"-"<<b<<"=";
count++;
cin>>q[i];
if(q[i]==jian)
{
cout<<"Right!"<<endl;
right++;
}
else
cout<<"Not correct!"<<endl;
}
break;
case 3:
count++;
cout<<a<<"x"<<b<<"=";
cin>>q[i];
if(q[i]==cheng)
{
cout<<"Right!"<<endl;
right++;
}
else
cout<<"Not correct!"<<endl;
break;
case 4:
if(a%b==0&&a>b)
{
count++;
cout<<a<<"/"<<b<<"=";
cin>>q[i];
if(q[i]==chu)
{
cout<<"Right!"<<endl;
right++;
}
else
cout<<"Not correct!"<<endl;
break;
}
}
if(count==10)
{
cout<<"做对题数:"<<right<<";做错题数:"<<10-right<<e
c 1-10的加减乘除 来自淘豆网m.daumloan.com转载请标明出处.