为什么全WA

P1957 口算练习题

2672434062xzl @ 2023-07-28 22:55:14

#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
const int N=210;
int main() {
    string s;
    int n,cl;
    cin>>n;
    getchar();
    for(int i=1;i<=n;i++)
    {
        s.clear();
        getline(cin,s);
        int number=0,num[2]={0,0};
        for(int j=0;j<s.length();j++)
        {
            if(s[j]==' ')
            {
                number++;
                continue;
            }
            if(s[j]>='a')
            {
                number--;
                cl=s[j]-'a';
            }
            else
                num[number]=num[number]*10+s[j]-'0';
        }
        if(cl==0)printf("%d+%d=%d\n%d\n",num[0],num[1],num[0]+num[1],(int)log10(num[0]+num[1])+(int)log10(num[0])+(int)log10(num[1])+5);
        if(cl==1)printf("%d-%d=%d\n%d\n",num[0],num[1],num[0]-num[1],(num[0]==num[1]?1:(num[0]>num[1]?(int)log10(num[0]-num[1]):(int)log10(num[1]-num[0])+1))+(int)log10(num[0])+(int)log10(num[1])+5);
        if(cl==2)printf("%d*%d=%d\n%d\n",num[0],num[1],num[0]*num[1],(int)log10(num[0]*num[1])+(int)log10(num[0])+(int)log10(num[1])+5);
    }
}

by 2672434062xzl @ 2023-07-28 22:56:54

样例过了 测试点也过了


|