社区讨论
求第五个点的数据,我把能想到的情况都想到了,还是90分
P1957口算练习题参与者 3已保存回复 6
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 6 条
- 当前快照
- 1 份
- 快照标识符
- @lo20t5j6
- 此快照首次捕获于
- 2023/10/23 06:08 2 年前
- 此快照最后确认于
- 2023/11/03 06:31 2 年前
如果有更简洁的代码我会去看题解的,现在我认为我这个代码应该是没什么问题的。把第五个点的数据找出来再修改一下应该就过了。
Ps:是屎山代码,慎看
CPP#include<bits/stdc++.h>
using namespace std;
int main(){
string c;
char s;
int a,b,len=2,n,b0=0,d=1;
cin>>n;
for(int i=1;i<=n;i++){
int x;
cin>>c>>a;
if(c[0]=='a'){
s=c[0];
cin>>b;
x=a+b;
cout<<a<<"+"<<b<<"="<<x<<endl;
}else if(c[0]=='b'){
s=c[0];
cin>>b;
x=a-b;
cout<<a<<"-"<<b<<"="<<x<<endl;
}else if(c[0]=='c'){
s=c[0];
cin>>b;
x=a*b;
cout<<a<<"*"<<b<<"="<<x<<endl;
}else{
int lens=c.length(),j=0;
while(j<lens){
for(int i=c.length()-1;i>j;i--) d*=10;
b0=b0+(c[j]-'0')*d;
d=1;
j++;
}
b=b0;
if(s=='a'){x=a+b;cout<<b<<"+"<<a<<"="<<x<<endl;}
if(s=='b'){x=b-a;cout<<b<<"-"<<a<<"="<<x<<endl;}
if(s=='c'){x=a*b;cout<<b<<"*"<<a<<"="<<x<<endl;}
}
if(x<0){len++;x=abs(x);}
if(x==0){len++;}
while(a!=0){len++;a/=10;}
while(b!=0){len++;b/=10;}
while(x!=0){len++;x/=10;}
cout<<len<<endl;
len=2;
b0=0;
}
return 0;
}
回复
共 6 条回复,欢迎继续交流。
正在加载回复...