51.从键盘上输入任意两个数和一个运算符(+、-、*、/),根据输入的运算符对两个数计算,并输出结果
#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; }
posted on 2014-08-09 15:40 Ji_xiaowu 阅读(5055) 评论(0) 编辑 收藏 举报