解题思路:
注意事项:
参考代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll jiafa (ll x,ll y,char z)
{
if(z=='+')
{
return x+y;
}
}
ll jianfa (ll x,ll y,char z)
{
if(z=='-')
{
return x-y;
}
}
ll chengfa (ll x,ll y,char z)
{
if(z=='*')
{
return x*y;
}
}
ll chufa (ll x,ll y,char z)
{
if(z=='/')
{
return x/y;
}
}
ll quyu (ll x,ll y,char z)
{
if(z=='%')
{
return x%y;
}
}
int main()
{
int a,b;
char c;
cin>>a>>c>>b;//符号是两个整数中间一个字符
if(c=='+')
{
cout<<jiafa(a,b,c);
}
if(c=='-')
{
cout<<jianfa(a,b,c);
}
if(c=='*')
{
cout<<chengfa(a,b,c);
}
if(c=='/')
{
cout<<chufa(a,b,c);
}
if(c=='%')
{
cout<<quyu(a,b,c);
}
return 0;
}
0.0分
0 人评分