V106 @ 2023-06-30 09:48:07
#include<stdio.h>
int operat(int a, int b, char c)
{
if(c == 'a') return a + b;
else if(c == 'b') return a - b;
else if(c == 'c') return a * b;
}
int main()
{
char c, op, d;
int res = 0, n, cnt = 0, a, b;
scanf("%d", &n);
getchar();
while(n --)
{
cnt = 0;
c = getchar();
a = 0, b = 0;
if(c >= '0' && c <= '9')
{
a = c - '0'; cnt ++;
}
else
{
op = c;
getchar();
}
while((c = getchar()) != ' ')
{
a = 10 * a + c - '0'; cnt ++;
}
while((c = getchar()) != '\n')
{
b = 10 * b + c - '0'; cnt ++;
}
res = operat(a, b, op);
int t = res;
if(t < 0) cnt ++;
while(t = t / 10)
{
cnt ++;
}
if(op == 'a') d = '+';
else if(op == 'b') d = '-';
else d = '*';
printf("%d%c%d=%d\n", a, d, b, res);
printf("%d\n", cnt + 3);
}
return 0;
}
1
a 99 999
99+999=1098
11
by yw15912527693 @ 2023-06-30 16:16:30
我也一样啊,全是WA,但是第一个答案和题目案例输出是一样的啊