_unlimited_thought @ 2021-06-13 19:48:03
#include<iostream>
using namespace std;
void pr(int a,int b,int c)
{
int p[3];
p[0]=a;
p[1]=b;
p[2]=c;
int sum=2;
for(int i=0;i<3;i++)
{
int j=0;
int k=1;
while(p[i]/k!=0)
{
k*=10;
j++;
}
if(j==0) j++;
if(p[i]<0) sum++;
sum+=j;
}
cout<<sum<<endl;
return ;
}
void add()
{
int a,b;
cin>>a>>b;
cout<<a<<'+'<<b<<'='<<a+b<<endl;
pr(a,b,a+b);
return ;
}
void sub()
{
int a,b;
cin>>a>>b;
cout<<a<<'-'<<b<<'='<<a-b<<endl;
pr(a,b,a-b);
return ;
}
void plu()
{
int a,b;
cin>>a>>b;
cout<<a<<'*'<<b<<'='<<a*b<<endl;
pr(a,b,a*b);
return ;
}
int main()
{
int n;
cin>>n;
char ch;
for(int i=0;i<n;i++)
{
if(cin.peek()=='\n') cin.get();
if(cin.peek()>='a'&&cin.peek()<='c')
{
cin>>ch;
}
switch(ch)
{
case 'a': add();break;
case 'b': sub();break;
case 'c': plu();break;
}
}
return 0;
}
by zhanghaiyu @ 2021-07-07 16:15:12
错了,输了几个就闪退