60分求助

P1957 口算练习题

_Daniel_ @ 2023-07-31 13:32:28

代码

#include<iostream>
#include<iomanip>
#include<math.h>
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<map>
#define maxnum 9999999999999999999
#define minnum -999999999999999999
#define ll long long
#define endl "\n"
#define pi 3.1415926
using namespace std;
int main()
{
    char s,sy;
    string num1,num2,num3;
    int i,nu1,nu2,nu3;
    cin>>i;
    while(i--)
    {
        cin>>s>>nu1>>nu2;
        sy=s;
        switch(sy)
        {
            case 'a':
                nu3=nu1+nu2;
                num1=to_string(nu1);
                num2=to_string(nu2);
                num3=to_string(nu3);
                num1=num1+'+'+num2+'='+num3;
                cout<<num1<<endl;
                cout<<num1.size()<<endl;
                break;
            case 'b':
                nu3=nu1-nu2;
                num1=to_string(nu1);
                num2=to_string(nu2);
                num3=to_string(nu3);
                num1=num1+'-'+num2+'='+num3;
                cout<<num1<<endl;
                cout<<num1.size()<<endl;
                break;
            case 'c':
                nu3=nu1*nu2;
                num1=to_string(nu1);
                num2=to_string(nu2);
                num3=to_string(nu3);
                num1=num1+'*'+num2+'='+num3;
                cout<<num1<<endl;
                cout<<num1.size()<<endl;
                break;
        }
    }
    return 0;
}

by zcs_ @ 2023-08-09 10:10:08

您好象没有考虑没有字符a或b或c的情况


|