hhb200808 @ 2023-11-07 15:36:02
#include<bits/stdc++.h>
using namespace std;
string s,d,y;
int main()
{
int a,m,n,t1=1;
char pd;
cin>>a;
getline(cin,s);
for(int i=1;i<=a;i++)
{
getline(cin,s);
if(s[0]>='a'&&s[0]<='c')
{
if(s[0]=='a')
{
bool t=0;
for(int f=2;f<s.size();f++)
{
if(s[f]==' ')
t=1;
if(t==0&&s[f]!=' ')
d+=s[f];
if(t)
y+=s[f];
}
m=atoi(d.c_str());
n=atoi(y.c_str());
cout<<m<<"+"<<n<<"="<<m+n<<endl;
for(int f=10;(m+n)/f!=0;f*=10)
{
t1++;
}
cout<<s.size()+t1-1<<endl;
pd=s[0];
}
else if(s[0]=='b')
{
bool t=0;
for(int f=2;f<s.size();f++)
{
if(s[f]==' ')
t=1;
if(t==0&&s[f]!=' ')
d+=s[f];
if(t)
y+=s[f];
}
m=atoi(d.c_str());
n=atoi(y.c_str());
cout<<m<<"-"<<n<<"="<<m-n<<endl;
for(int f=10;(m-n)/f!=0;f*=10)
{
t1++;
}
if(m-n<0)
cout<<s.size()+t1+1-1<<endl;
else
cout<<s.size()+t1-1<<endl;
pd=s[0];
}
else if(s[0]=='c')
{
bool t=0;
for(int f=2;f<s.size();f++)
{
if(s[f]==' ')
t=1;
if(t==0&&s[f]!=' ')
d+=s[f];
if(t)
y+=s[f];
}
m=atoi(d.c_str());
n=atoi(y.c_str());
cout<<m<<"*"<<n<<"="<<m*n<<endl;
for(int f=10;(m*n)/f!=0;f*=10)
{
t1++;
}
cout<<s.size()+t1-1<<endl;
pd=s[0];
}
}
else
{
if(pd=='a')
{
bool t=0;
for(int f=0;f<s.size();f++)
{
if(s[f]==' ')
t=1;
if(t==0&&s[f]!=' ')
d+=s[f];
if(t)
y+=s[f];
}
m=atoi(d.c_str());
n=atoi(y.c_str());
cout<<m<<"+"<<n<<"="<<m+n<<endl;
for(int f=10;(m+n)/f!=0;f*=10)
{
t1++;
}
cout<<s.size()+t1+1<<endl;
}
else if(pd=='b')
{
bool t=0;
for(int f=0;f<s.size();f++)
{
if(s[f]==' ')
t=1;
if(t==0&&s[f]!=' ')
d+=s[f];
if(t)
y+=s[f];
}
m=atoi(d.c_str());
n=atoi(y.c_str());
cout<<m<<"-"<<n<<"="<<m-n<<endl;
for(int f=10;(m-n)/f!=0;f*=10)
{
t1++;
}
if(m-n<0)
cout<<s.size()+t1+1+1<<endl;
else
cout<<s.size()+t1+1<<endl;
}
else if(pd=='c')
{
bool t=0;
for(int f=0;f<s.size();f++)
{
if(s[f]==' ')
t=1;
if(t==0&&s[f]!=' ')
d+=s[f];
if(t)
y+=s[f];
}
m=atoi(d.c_str());
n=atoi(y.c_str());
cout<<m<<"*"<<n<<"="<<m*n<<endl;
for(int f=10;(m*n)/f!=0;f*=10)
{
t1++;
}
cout<<s.size()+t1+1<<endl;
}
}
d="";
y="";
t1=1;
}
}
by hhb200808 @ 2023-11-08 19:37:24
https://www.luogu.com.cn/discuss/690650
题解
by penghao_love_dxl @ 2023-11-08 21:17:22
这都不会,自己想!
#include<bits/stdc++.h>
using namespace std;
int main()
{
return 0
}