/*
*烟台大学计算机学院
*文件名称:main.cpp
*作 者:王者健
*完成日期:2016年6月11日
*版 本 号:codeblocks 16.01
*/
#include <iostream>
using namespace std;
#include<ctime>
#include<cstdlib>
int main()
{
int i,sum,right=0,num=1,n;
int x,y;
for(i=0;i<10;i++)
{
x=rand()%100;
y=1+rand()%100;
if(x<y)
{
n=x;
x=y;
y=n;
}
cout<<"第"<<num<<"题:";
srand(time(0));
switch(x%4)
{
case 0:
{
cout<<x<<"+"<<y<<"=";
cin>>sum;
if(sum==(x+y))
{
cout<<"right"<<endl;
right++;
}
else
cout<<"wrong"<<endl;
break;
}
case 1:
{
cout<<x<<"-"<<y<<"=";
cin>>sum;
if(sum==(x-y))
{
cout<<"right"<<endl;
right++;
}
else
cout<<"wrong"<<endl;
break;
}
case 2:
{
cout<<x<<"*"<<y<<"=";
cin>>sum;
if(sum==(x*y))
{
cout<<"right"<<endl;
right++;
}
else
cout<<"wrong"<<endl;
break;
}
case 3:
{
cout<<x<<"/"<<y<<"=";
cin>>sum;
if(sum==(x/y))
{
cout<<"right"<<endl;
right++;
}
else
cout<<"wrong"<<endl;
break;
}
}
num++;
}
cout<<"做对了:"<<right<<"道题,得分为:"<<right*10;
return 0;
};
设计十道随机问题
最新推荐文章于 2022-06-29 14:56:06 发布