?#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; }
51.从键盘上输入任意两个数和一个运算符(+、-、*、/),根据输入的运算符对两个数计算,并输出结果
时间: 2024-10-16 21:21:45