个人项目3
Posted zzy0823
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了个人项目3相关的知识,希望对你有一定的参考价值。
char get_oper(int n)
{
switch(n)
{
case 0:return ‘+‘;
case 1:return ‘-‘;
case 2:return ‘*‘;
case 3:return ‘/‘;
}
}
{
switch(n)
{
case 0:return ‘+‘;
case 1:return ‘-‘;
case 2:return ‘*‘;
case 3:return ‘/‘;
}
}
int main()
{
int num1=0,num2=0,count=0;
float user_answer=0,right_answer=0;
int operators=0; //0:+ 1:- 2:* 3:/
{
int num1=0,num2=0,count=0;
float user_answer=0,right_answer=0;
int operators=0; //0:+ 1:- 2:* 3:/
for(int i=1;i<=HOW;i++)
{
num1=rand();
num2=rand();
operators=rand()%4;
{
num1=rand();
num2=rand();
operators=rand()%4;
if(operators==3)num1=num2*(rand()%100);
cout<<i<<":? "<<num1<<get_oper(operators)<<num2<<"=";
cin>>user_answer;
switch(operators)
{
case 0:right_answer=num1+num2;break;
case 1:right_answer=num1-num2;break;
case 2:right_answer=num1*num2;break;
case 3:right_answer=num1/num2;
}
if(right_answer==user_answer)
{
cout<<"RIGHT"<<endl;
count++;
}
else
cout<<"WRONG"<<endl;
}
cout<<"Right:"<<count<<"? Wrong:"<<HOW-count<<""<<count<<"/"<<HOW<<"="<<count/HOW;
return 0;
}
}
以上是关于个人项目3的主要内容,如果未能解决你的问题,请参考以下文章