#include <bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c;
char s;
srand(time(0)); a = rand ()% 100;
b = rand ()% 100; cout<<"客官,请输入您要计算的符号,本喵要给客官出题:"<<endl;
cout<<"这里有五个符号可以给到客官,分别是"<<"+ "<<"- "<<"x "<<"/ "<<"%"<<",可供选择.";
cin>>s;
switch(s)
{
case '+':
{
cout<<a<<"+"<<b<<"=";
cin>>c;
if(a + b == c)
{
cout<<"客官回答正确,您是计算小能手";
break;
}
else
{
cout<<"错误,再转动下您的大脑";
break;
}
}
case '-':
{
if(a > b)
{
cout<<a<<"-"<<b<<"=";
cin>>c;
if(a - b == c)
{
cout<<"客官回答正确,您是计算小能手";
break; cout<<a<<"+"<<b<<"=";
}
else
{
cout<<"错误,再转动下您的大脑";
break;
}
}
else
{
cout<<b<<"-"<<a<<"=";
cin>>c;
if(b - a == c)
{
cout<<"客官回答正确,您是计算小能手";
break;
}
else
{
cout<<"错误,再转动下您的大脑";
break;
}
}
}
case 'x':
{
cout<<a<<"x"<<b<<"=";
cin>>c;
if(a * b == c)
{
cout<<"客官回答正确,您是计算小能手";
break;
}
else
{
cout<<"错误,再转动下您的大脑";
break;
}
}
case '/':
{
if(b = 0)
{
b++;
}
cout<<"只用回答整数部分就可以了"<<endl;
cout<<a<<"/"<<b<<"=";
cin>>c;
if(a / b == c)
{
cout<<"客官回答正确,您是计算小能手";
break;
}
else
{
cout<<"错误,再转动下您的大脑";
break;
}
}
case '%':
{
if(b == 0)
{
b++;
}
cout<<a<<"%"<<b<<"=";
cin>>c;
if(a % b == c)
{
cout<<"客官回答正确,您是计算小能手";
break;
}
else
{
cout<<"错误,再转动下您的大脑";
break;
}
}
default:
{
cout<<"客官输入的符号本喵不太懂,我要去看喵氏百科全书,喵!";
}
}
return 0;
}
共 5 条回复
主要是:干嘛一次就出一道题?
评分9.9
满分一百五
评分:9.9分
大家评价一下