#2WA 90分求助:(

P1957 口算练习题

wwwww99 @ 2023-10-27 22:12:43

我真的要疯了 看不出来哪里出问题了啊qwq

#include<stdio.h>
#include<string.h>
int main()
{
    int i,j,x,y,z,x1,y1,z1,z2=0,x2=0,y2=0;
    char n,m,h;
    scanf("%d",&i);

    for(j=0;j<i;j++)
    {
        getchar();
        getchar();
        h=getchar();
        if(h>=97&&h<=99)
    {
        scanf("%d %d",&x,&y);
        switch(h)
        {
            case'a':
            m=h;
            x1=x;
            y1=y;
            z=x+y;
            z1=z;
            if(x1<=0)
            x2++;
            if(y1<=0)
            y2++;
            if(z1<=0)
            z2++;
            while (x1)
            {
                x2++;
                x1/=10;
            }
            while (y1)
            {
                y2++;
                y1/=10;
            }
            while (z1)
            {
                z2++;
                z1/=10;
            }
            printf("%d+%d=%d\n",x,y,z);
            printf("%d\n",2+x2+y2+z2);
            z2=x2=y2=0;
            break;
        case 'b':
            m=h;
            x1=x;
            y1=y;
            z=x-y;
            z1=z;
            if(x1<=0)
            x2++;
            if(y1<=0)
            y2++;
            if(z1<=0)
            z2++;
            while (x1)
            {
                x2++;
                x1/=10;
            }
            while (y1)
            {
                y2++;
                y1/=10;
            }
            while (z1)
            {
                z2++;
                z1/=10;
            }
            printf("%d-%d=%d\n",x,y,z);
            printf("%d\n",2+x2+y2+z2);
            z2=x2=y2=0;
            break;
        default:
            m=h;
            x1=x;
            y1=y;
            z=x*y;
            z1=z;
            if(x1<=0)
            x2++;
            if(y1<=0)
            y2++;
            if(z1<=0)
            z2++;
            while (x1)
            {
                x2++;
                x1/=10;
            }
            while (y1)
            {
                y2++;
                y1/=10;
            }
            while (z1)
            {
                z2++;
                z1/=10;
            }
            printf("%d*%d=%d\n",x,y,z);
            printf("%d\n",2+x2+y2+z2);
            z2=x2=y2=0;
            break;

        }
    }

    else
    {
        h=h-'1'+1;
        scanf("%d %d",&x,&y);
        int a,s=0;
    while(x!=0)
    {
        a=x%10;
        x=x/10;
        s=10*s+a;
    }
    s=s*10+h;
    while(s!=0)
    {
        a=s%10;
        s=s/10;
        x=10*x+a;
    }
    switch(m)
        {
            case'a':

            x1=x;
            y1=y;
            z=x+y;
            z1=z;
            if(x1<=0)
            x2++;
            if(y1<=0)
            y2++;
            if(z1<=0)
            z2++;
            while (x1)
            {
                x2++;
                x1/=10;
            }
            while (y1)
            {
                y2++;
                y1/=10;
            }
            while (z1)
            {
                z2++;
                z1/=10;
            }
            printf("%d+%d=%d\n",x,y,z);
            printf("%d\n",2+x2+y2+z2);
            z2=x2=y2=0;
            break;
        case 'b':
            x1=x;
            y1=y;
            z=x-y;
            z1=z;
            if(x1<=0)
            x2++;
            if(y1<=0)
            y2++;
            if(z1<=0)
            z2++;
            while (x1)
            {
                x2++;
                x1/=10;
            }
            while (y1)
            {
                y2++;
                y1/=10;
            }
            while (z1)
            {
                z2++;
                z1/=10;
            }
            printf("%d-%d=%d\n",x,y,z);
            printf("%d\n",2+x2+y2+z2);
            z2=x2=y2=0;
            break;
        default:
            x1=x;
            y1=y;
            z=x*y;
            z1=z;
            if(x1<=0)
            x2++;
            if(y1<=0)
            y2++;
            if(z1<=0)
            z2++;
            while (x1)
            {
                x2++;
                x1/=10;
            }
            while (y1)
            {
                y2++;
                y1/=10;
            }
            while (z1)
            {
                z2++;
                z1/=10;
            }
            printf("%d*%d=%d\n",x,y,z);
            printf("%d\n",2+x2+y2+z2);
            z2=x2=y2=0;

        }
    }}}

by lan_chance @ 2023-10-27 22:33:09

2输入是

50
c 2620 6343
a 216 1149
b 7761 5655
7168 3961
a 9755 3461
9303 1617
2644 274
c 5959 5822
727 2106
8801 6103
1074 7558
c 5311 3362
9831 8685
8323 7534
b 2274 3201
6879 1691
b 4615 5358
7179 5712
5079 7186
2942 1540
a 7365 5932
6106 4150
6029 3705
a 7933 3773
1744 9199
3392 7815
407 7594
5261 5569
7124 4780
a 6210 6762
2655 3559
c 9982 8521
6779 7285
3922 406
b 5968 5627
c 4878 831
2946 7129
4251 1035
7269 6391
c 7681 1516
a 3246 2563
8045 3370
5908 8263
c 9022 6608
b 3980 1593
1904 3328
b 7330 7777
a 8796 8261
8602 274
3869 7732

输出是:

2620*6343=16618660
18
216+1149=1365
13
7761-5655=2106
14
7168-3961=3207
14
9755+3461=13216
15
9303+1617=10920
15
2644+274=2918
13
5959*5822=34693298
18
727*2106=1531062
16
8801*6103=53712503
18
1074*7558=8117292
17
5311*3362=17855582
18
9831*8685=85382235
18
8323*7534=62705482
18
2274-3201=-927
14
6879-1691=5188
14
4615-5358=-743
14
7179-5712=1467
14
5079-7186=-2107
15
2942-1540=1402
14
7365+5932=13297
15
6106+4150=10256
15
6029+3705=9734
14
7933+3773=11706
15
1744+9199=10943
15
3392+7815=11207
15
407+7594=8001
13
5261+5569=10830
15
7124+4780=11904
15
6210+6762=12972
15
2655+3559=6214
14
9982*8521=85056622
18
6779*7285=49385015
18
3922*406=1592332
16
5968-5627=341
13
4878*831=4053618
16
2946*7129=21002034
18
4251*1035=4399785
17
7269*6391=46456179
18
7681*1516=11644396
18
3246+2563=5809
14
8045+3370=11415
15
5908+8263=14171
15
9022*6608=59617376
18
3980-1593=2387
14
1904-3328=-1424
15
7330-7777=-447
14
8796+8261=17057
15
8602+274=8876
13
3869+7732=11601
15

为大佬提供案例


|