#include #include using namespace std; int main(){ cout << "请输入一个算式,包含加减乘除乘方括号:" << endl; string s; cin >> s; vector num; vector symbol; for (auto x:s){ if((x>47)&&(x<58)){ if(symbol.begin()==symbol.end()){//判断字符栈是否为空 num.push_back(x-'0'); }elif(*(symbol.end()-1)=='46'){ *(num.end()-1)=atof((to_string(*num.end()-1)).c_str()+x); } } } for (double a:num){ cout << a << endl; } return 0; }