本喵的计算检测器(高级版)

Kinghero King of the summit 2022-07-10 10:41:57 2023-08-29 13:27:38 0
#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;
    }
{{ vote && vote.total.up }}

共 5 条回复

CPP 刷题王

主要是:干嘛一次就出一道题?

CPP 刷题王

评分9.9

CPP 刷题王

满分一百五

Even226 逗比

评分:9.9分

Kinghero King of the summit

大家评价一下