#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; }