80分,求助dalao
查看原帖
80分,求助dalao
614944
fish_golden楼主2023/7/11 22:50
#include <bits/stdc++.h>
using namespace std;
int n;
int a, b;
string op, pre_op;
int main()
{
    scanf("%d", &n);
    while (n--)
    {
        cin >> op;
        string ans;
        if (op == "a")
        {
            cin >> a >> b;
            ans = to_string(a) + "+" + to_string(b) + "=" + to_string(a + b);
        }
        else if (op == "b")
        {
            cin >> a >> b;
            ans = to_string(a) + "-" + to_string(b) + "=" + to_string(a - b);
        }
        else if (op == "c")
        {
            cin >> a >> b;
            ans = to_string(a) + "*" + to_string(b) + "=" + to_string(a * b);
        }
        else
        {
            a = atoi(op.c_str());
            cin >> b;
            if (pre_op == "a")
                ans = to_string(a) + "+" + to_string(b) + "=" + to_string(a + b);
            else if (pre_op == "b")
                ans = to_string(a) + "-" + to_string(b) + "=" + to_string(a - b);
            else
                ans = to_string(a) + "*" + to_string(b) + "=" + to_string(a * b);
        }
        cout << ans << endl
             << ans.size() << endl;
        pre_op = op;
    }
    return 0;
}

dalao们帮我看看为什么有2个点WA了。

2023/7/11 22:50
加载中...