解题思路:
没啥说的,水一发
注意事项:
参考代码:
#include<bits/stdc++.h> using namespace std; int add(int x, int y) { return x+y; } int sub(int x, int y) { return x-y; } int mul(int x, int y) { return x*y; } int div1(int x, int y) { return x/y; } int main() { char op; int x,y; cin>>op>>x>>y; int ans; switch(op) { case '+': ans = add(x,y); break; case '-': ans = sub(x,y); break; case '*': ans = mul(x,y); break; case '/': ans = div1(x,y); break; } cout<<ans<<endl; return 0; }
0.0分
7 人评分