救命!!!!!!!!!全红了!!!!!
查看原帖
救命!!!!!!!!!全红了!!!!!
1046223
a_blue_fool楼主2023/11/29 13:52

救救孩子吧……

#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

struct simple
{
    int a , b;
    char tmp;
};

int main()
{
    char tool[100] , ou[100];
    int n , t;
    scanf("%d" , &n);
    simple list[n];

    cin.get();

    for (int i = 0 ; i < n ; i++)
    {
        fgets(tool , sizeof(tool) , stdin);
        if (tool[0] > '9')
        {
            sscanf(tool , "%c%d%d" , &list[i].tmp , &list[i].a , &list[i].b);
        }
        else
        {
            list[i].tmp = list[i-1].tmp;
            sscanf(tool , "%d%d" , &list[i].a , &list[i].b);
        }

        if (list[i].tmp == 'a' || list[i].tmp == '+')
        {
            list[i].tmp = '+';
            t = list[i].a + list[i].b;
        }
        else if (list[i].tmp == 'b' || list[i].tmp == '-')
        {
            list[i].tmp = '-';
            t = list[i].a - list[i].b;
        }
        else
        {
            list[i].tmp = '*';
            t = list[i].a * list[i].b;
        }

        sprintf(ou , "%d%c%d=%d" , list[i].a , list[i].tmp , list[i].b , t);
        printf("%s\n%d\n" , ou , strlen(ou));
    }

    return 0;
}

好人抽卡不歪!!!

2023/11/29 13:52
加载中...