#include <bits/stdc++.h>
using namespace std;
int js(string a,string b);
string no1(string x);
int main(){
    string a;
    getline(cin,a);
    a=no1(a);
    if(a.find("+")>0 && a.find("+")<a.size()){
        cout<<js(a,"+");
    }else if(a.find("-")>0 && a.find("-")<a.size()){
        cout<<js(a,"-");
    }else if(a.find("*")>0 && a.find("*")<a.size()){
        cout<<js(a,"*");
    }else if(a.find("/")>0 && a.find("/")<a.size()){
        cout<<js(a,"/");
    }
    return 0;
}
string no1(string a){
    while(a.find(" ")>=0 && a.find(" ")<a.size()){
        a.replace(a.find(" "),1,"");
    }
    return a;
}
int js(string a,string b){
    int x = stoi(a.substr(0,a.find(b)));
    int y = stoi(a.substr(a.find(b)+1));
    if(b=="+"){
        return x+y;
    }if(b=="-"){
        return x-y;
    }if(b=="*"){
        return x*y;
    }if(b=="/"){
        return x/y;
    }
}

  

posted on 2023-11-17 19:59  黛玉醉打将门神  阅读(6)  评论(0编辑  收藏  举报