/*
*Copyright (c) 2016,烟台大学计算机学院
*All rights reserved.
*文件名称:text.cpp
*作者:汤善晔
*完成日期:2016年8月23日
*版本号:v1.0
*/
#include <iostream>
#include<ctime>#include<cstdlib>
int qa();
using namespace std;
int main()
{
int sum=0;
for(int i=0; i<10; i++)
{
cout<<"第"<<i+1<<"题:"<<endl;
sum+=qa();
cout<<endl;
}
cout<<"共答对了"<<sum<<"道题,得分"<<sum*10<<endl;
return 0;
}
int qa()
{
srand(time(0));
int a,b,c,d,t;
a=rand()%100+1;
b=rand()%100+1;
c=rand()%4;
if(a<b&&(c==1||c==3))
{
d=a;
a=b;
b=d;
}
if(c==3)
a=(a/b)*b;
switch(c)
{
case 0:
d=a+b;
cout<<a<<"+"<<b<<"=";
break;
case 1:
d=a-b;
cout<<a<<"—"<<b<<"=";
break;
case 2:
d=a*b;
cout<<a<<"×"<<b<<"=";
break;
case 3:
d=a/b;
cout<<a<<"÷"<<b<<"=";
break;
}
cin>>t;
if(t==d)
cout<<" right! ";
else
cout<<" wrong! ";
return t==d;
}