#include <iostream>
#include <cstring>
#include <map>
using namespace std;
int sum(int a,int b){
return a+b;
}
int mul(int a,int b){
return a*b;
}
int sub(int a,int b){
return a-b;
}
int Div(int a,int b){
return (int)(a/b);
}
map <char,int> m ;
int (*f[5])(int ,int);
int suan(int a,int b,int (*p)(int,int)){
return p(a,b);
}
int main(){
m['+']=0;
m['-']=1;
m['*']=2;
m['/']=3;
f[0]=sum;
f[1]=sub;
f[2]=mul;
f[3]=Div;
int a,b;
char c;
cin>>a>>c>>b;
cout<<suan(a,b,f[m[c]])<<endl;
}
加减乘除
最新推荐文章于 2018-08-10 11:51:07 发布