大佬救命!!!测试数据都对,但就是全wa

P1957 口算练习题

misalianfeng @ 2023-12-12 16:59:37

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

char s[5465];
char s1[54684];
int main(){
    int n;
    char c;
    char wu;
    scanf("%d",&n);
    scanf("%c",&wu);
    for(int i=0;i<n;i++){
        gets(s);
        if(s[0]>='a'&&s[0]<='c'){
            int a,b;
            if(s[0]=='a'){
                sscanf(s,"%c %d %d",&c,&a,&b);
                printf("%d+%d=%d\n",a,b,a+b);
                printf("%d",sprintf(s1,"%d %d %d",a,b,a+b));
                if(i!=n-1)printf("\n"); 
            }
            if(s[0]=='b'){
                sscanf(s,"%c %d %d",&c,&a,&b);
                printf("%d-%d=%d\n",a,b,a-b);
                printf("%d",sprintf(s1,"%d %d %d",a,b,a-b));
                if(i!=n-1)printf("\n"); 
            }
            if(s[0]=='c'){
                sscanf(s,"%c %d %d",&c,&a,&b);
                printf("%d*%d=%d\n",a,b,a*b);
                printf("%d",sprintf(s1,"%d %d %d",a,b,a*b));
                if(i!=n-1)printf("\n"); 
            }
       }else{
        int a,b;
        sscanf(s,"%d %d",&a,&b);
        if(c=='a'){
        printf("%d+%d=%d\n",a,b,a+b);
        printf("%d",sprintf(s1,"%d %d %d",a,b,a+b));
        if(i!=n-1)printf("\n"); 
       }else if(c=='b'){
        printf("%d-%d=%d\n",a,b,a-b);
        printf("%d",sprintf(s1,"%d %d %d",a,b,a-b));
        if(i!=n-1)printf("\n"); 
        }else{
        printf("%d*%d=%d\n",a,b,a*b);   
        printf("%d",sprintf(s1,"%d %d %d",a,b,a*b));
        if(i!=n-1)printf("\n");         
           }
    }
 }
    return 0;
}

|