1397:简单算术表达式求值

#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<math.h>
using namespace std;
int work(int a,char b,int c)
{
    if(b=='+')return (a+c);
    else if(b=='-')return (a-c);
    else if(b=='*')return (a*c);
    else if(b=='%')return (a%c);
    else if(b=='/')return (a/c);
}
int main()
{
    int x,y,s;
    char z;
    scanf("%d%c%d",&x,&z,&y);
    s=work(x,z,y);
    printf("%d",s);
    return 0;
}100'
 

猜你喜欢

转载自blog.csdn.net/qq_42552468/article/details/81151538