90pts求调

P1957 口算练习题

NullPointerExpection @ 2024-07-12 22:02:57

#include <bits/stdc++.h>
using namespace std;

char opt, in[4];
int n, a, b;
int main() {
    cin >> n;
    while(n--) {
        cin >> in;
        if(in[0] >= 'a' && in[0] <= 'c') {
            opt = in[0];
            cin >> a >> b;
        }
        else {
            sscanf(in, "%d", &a);
            cin >> b;
        }
        char ans[18];
        switch(opt) {
            case 'a': {
                sprintf(ans, "%d+%d=%d", a, b, a + b);
                break;
            }
            case 'b': {
                sprintf(ans, "%d-%d=%d", a, b, a - b);
                break;
            }
            case 'c': {
                sprintf(ans, "%d*%d=%d", a, b, a * b);
                break;
            }
        }
        cout << ans << '\n';
        cout << strlen(ans) << '\n';
    }
    return 0;
}

by NullPointerExpection @ 2024-07-13 07:47:02

此帖结


by yangzezhao12345 @ 2024-07-18 11:19:33


|