hexuchen @ 2023-06-12 17:08:42
#include <bits/stdc++.h>
using namespace std;
int sum(int a){
int s=0;
while(a!=0){
s++;
a/=10;
}
return s;
}
int main(){
long long n,a,b,base=1;
string s;
char c;
cin>>n;
for(int i=1;i<=n;i++){
cin>>s;
if(isalpha(s[0])){
c=s[0];
cin>>a>>b;
switch(c){
case 'a':printf("%d+%d=%d\n%d\n",a,b,a+b,sum(a)+sum(b)+sum(a+b)+2);break;
case 'b':printf("%d-%d=%d\n%d\n",a,b,a-b,sum(a)+sum(b)+sum(a-b)+2);break;
case 'c':printf("%d*%d=%d\n%d\n",a,b,a*b,sum(a)+sum(b)+sum(a*b)+2);break;
}
}
else{
base=1;
a=0;
for(int i=s.size()-1;i>=0;i--){
a+=(s[i]-'0')*base;
base*=10;
}
cin>>b;
switch(c){
case 'a':printf("%d+%d=%d\n%d\n",a,b,a+b,sum(a)+sum(b)+sum(a+b)+2);break;
case 'b':printf("%d-%d=%d\n%d\n",a,b,a-b,sum(a)+sum(b)+sum(a-b)+2);break;
case 'c':printf("%d*%d=%d\n%d\n",a,b,a*b,sum(a)+sum(b)+sum(a*b)+2);break;
}
}
}
return 0;
}
我下载了测试点发现自己也没有错误啊?
by Rosaya @ 2023-06-12 17:29:17
负数长度多一个 -,咱就是说你这个能过样例吗?
by Rosaya @ 2023-06-12 17:30:24
而且 0 的长度是 1 啊,你这也太离谱了。
by hexuchen @ 2023-06-13 17:20:35
@Rosaya 修改了,谢谢大神指导!