为啥我这样例全过但还是WA声一片

P1957 口算练习题

Yin_haoran233 @ 2021-11-10 21:27:17

#include <stdio.h>
struct result {
    int number1;
    int number2;
    int number3;
};
int main (void)
{
    int x;
    int a;
    int b;
    char c;
    int point=0;
    int sum=0;
    int numberpoint=0;
    int out=0; 
    struct result outen[100]={0,0,0};
    scanf("%d",&x);
    for (int i=0;i<x;i++){
        getchar();
        scanf("%c %d %d",&c,&a,&b);
    point=10;
    numberpoint=10;
if (c>='a'&&c<='d'){
            switch (c) {
                case 'a':
                out=1;
                    break;
                case 'b':
                out=2;
                    break;
                case 'c':
                out=3;
                    break;
                case 'd':
                out=0;
                    break;
            }
        }else{
            while(a/point!=0){
                point*=10;
            }
            a+=((int)c-48)*point;
        }
    outen[i].number1=a;
    outen[i].number2=b;
    outen[i].number3=out;
    }
for (int o=0;o<x;o++){
    sum=5;
    numberpoint=10;
    while(outen[o].number1/numberpoint!=0){
        numberpoint*=10;
        sum++;
    }
    numberpoint=10;
    while(outen[o].number2/numberpoint!=0){
        numberpoint*=10;
        sum++;
    }
    numberpoint=10;
switch (outen[o].number3) {
            case 1:
    while((outen[o].number1+outen[o].number2)/numberpoint!=0){
        numberpoint*=10;
        sum++;
    }
    if (outen[o].number1+outen[o].number2<0){sum++;}
    printf ("%d+%d=%d\n",outen[o].number1,outen[o].number2,outen[o].number1+outen[o].number2);
    printf ("%d\n",sum);
                break;
            case 2:
    while((outen[o].number1-outen[o].number2)/numberpoint!=0){
        numberpoint*=10;
        sum++;
    }
    if (outen[o].number1-outen[o].number2<0){sum++;}
    printf ("%d-%d=%d\n",outen[o].number1,outen[o].number2,outen[o].number1-outen[o].number2);
    printf ("%d\n",sum);
                break;
            case 3:
    while((outen[o].number1*outen[o].number2)/numberpoint!=0){
        numberpoint*=10;
        sum++;
    }
    if (outen[o].number1*outen[o].number2<0){sum++;}
    printf ("%d*%d=%d\n",outen[o].number1,outen[o].number2,outen[o].number1*outen[o].number2);
    printf ("%d\n",sum);
                break;
            case 0:
    while((outen[o].number1/outen[o].number2)/numberpoint!=0){
        numberpoint*=10;
        sum++;
    }
    if (outen[o].number1/outen[o].number2<0){sum++;}
    printf ("%d/%d=%d\n",outen[o].number1,outen[o].number2,outen[o].number1/outen[o].number2);
    printf ("%d\n",sum);
                break;
        }   
    }
return 0;
}

|