文章

37

粉丝

67

获赞

3

访问

9.2k

头像
表达式的转换 题解:代码来了
P1063
发布于2024年3月7日 23:33
阅读数 213

#include<iostream>
#include<algorithm>
#include<stack>
#include<string>
using namespace std;
struct oper {
    char ch;
    int priority;//运算符优先级
};

int ans[100], flag[100]{ 0 }, cnt = 0;//用于输出的

void getOper(char ch) {
    flag[cnt] = 1;//代表此位为符号
    if (ch == '+') {
        ans[cnt] = 0;
    }
    else if (ch == '-') {
        ans[cnt] = 1;
    }
    else if (ch == '*') {
        ans[cnt] = 2;
    }
    else if(ch=='/') {
        ans[cnt] = 3;
    }
    else {
        ans[cnt] = 4;
    }
    cnt++;
}

//计算
void cal() {
    ...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发