​#include<iostream>
using namespace std;

int main()
{
    int x,y;
    char a;
    cout<<"please input two numbers: "<<endl;
    cin>>x>>y;
    cout<<"please input an operational character:"<<endl;
    cin>>a;

    switch(a)//switch函数的参数还可用字符
    {
        case '+': cout<<"x+y="<<x+y;break;
        case '-': cout<<"x-y="<<x-y;break;
        case '*': cout<<"x*y="<<x*y;break;
        case '/': cout<<"x/y="<<x/y;break;
        default : break;
    }

    return 0;
}

 

相关文章:

  • 2021-10-07
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-04
  • 2021-11-04
相关资源
相似解决方案