#include <iostream>
using namespace std;
int main()
{
char temp[256];
cin>>temp;
int rst=0;
int ad=0;
char smb='+';
int i=-1;
do
{
i++;
if(temp[i]<=47||temp[i]=='\0')
{
switch (smb)
{
case '+':rst=rst+ad;break;
case '-':rst=rst-ad;break;
case '*':rst=rst*ad;break;
case '/':if (ad==0) {cout<<rst<<endl;return 0;} else {rst=rst/ad;} ;break;
default: break;
}
smb=temp[i];
ad=0;
}
else
{
int ii=temp[i]-48;
ad=ad*10+ii;
}
}while (temp[i]!='\0');
cout<<rst<<endl;
return 0;
}
不考虑优先级的加减乘除
最新推荐文章于 2021-05-25 10:30:52 发布