#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int computer1,computer2,user,i=1,k,s,m=0;
float aver;
srand((unsigned)time(0));
cout<<"如果想要结束程序,请输入-1112"<<endl;
for(;;++i)
{
k=rand()%3;
if(0==k)
{
computer1=rand()%100+1;
computer2=rand()%100+1;
s=computer1+computer2;
cout<<computer1<<"+"<<computer2<<"=";
}
if(2==k)
{
for(;;)
{
computer1=rand()%100+1;
computer2=rand()%100+1;
if(computer1>computer2)
break;
}
s=computer1-computer2;
cout<<computer1<<"-"<<computer2<<"=";
}
if(1==k)
{
computer1=rand()%100+1;
computer2=rand()%100+1;
s=computer1*computer2;
cout<<computer1<<"*"<<computer2<<"=";
}
}
cin>>user;
if(-1112==user)
break;
if(user==s)
{
cout<<"Right!"<<endl<<endl<<endl;
m++;
}
else
cout<<"Wrong!"<<endl<<endl<<endl;
aver=m/(i-1);
if(aver<0.4)
cout<<"你得加油!";
if(aver>=0.4&&aver<=0.9)
cout<<"较棒!";
if(aver>0.9)
cout<<"太棒了!";
system("pause");
return 0;
}
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
int computer1,computer2,user,i=1,k,s,m=0;
float aver;
srand((unsigned)time(0));
cout<<"如果想要结束程序,请输入-1112"<<endl;
for(;;++i)
{
k=rand()%3;
if(0==k)
{
computer1=rand()%100+1;
computer2=rand()%100+1;
s=computer1+computer2;
cout<<computer1<<"+"<<computer2<<"=";
}
if(2==k)
{
for(;;)
{
computer1=rand()%100+1;
computer2=rand()%100+1;
if(computer1>computer2)
break;
}
s=computer1-computer2;
cout<<computer1<<"-"<<computer2<<"=";
}
if(1==k)
{
computer1=rand()%100+1;
computer2=rand()%100+1;
s=computer1*computer2;
cout<<computer1<<"*"<<computer2<<"=";
}
}
cin>>user;
if(-1112==user)
break;
if(user==s)
{
cout<<"Right!"<<endl<<endl<<endl;
m++;
}
else
cout<<"Wrong!"<<endl<<endl<<endl;
aver=m/(i-1);
if(aver<0.4)
cout<<"你得加油!";
if(aver>=0.4&&aver<=0.9)
cout<<"较棒!";
if(aver>0.9)
cout<<"太棒了!";
system("pause");
return 0;
}