等我打完程序叫你。。
by 百里亦守约 @ 2019-03-27 16:56:29
推荐数据:
3 2 + ? = 3
by 百里亦守约 @ 2019-03-27 17:17:02
首先,你那代码是超界,不是超时;其次,扩大之后变成了WA,所以你这个本身有问题。
by 三生万物 @ 2019-03-27 17:17:32
代码:
```cpp
#include<bits/stdc++.h>
using namespace std;
string st;
long long xst,fh,jz;
int w;
long long x[100];
int main()
{
getline(cin,st);
st+='=';
for(int i=0;i<st.size();i++)
if(st[i]>='0' && st[i]<='9')
xst=xst*10+(st[i]-'0');
else if (st[i]=='?' || st[i]=='-' || st[i]=='+' || st[i]=='=')
{
if(st[i]=='+') fh=1;
if(xst!=0)
{
w++;
x[w]=xst;
xst=0;
}
if(st[i]=='?')
{
jz=w+1;
w++;
}
}
if(jz==1 && fh==1) cout<<x[3]-x[2];
else if(jz==2 && fh==0) cout<<x[1]-x[3];
else if(jz==2 && fh==1) cout<<x[3]-x[1];
else if(jz==1 && fh==0) cout<<x[3]+x[2];
else if(jz==1 && fh==0) cout<<x[1]-x[3];
else if(jz==3 && fh==1) cout<<x[1]+x[2];
else cout<<x[1]-x[2];
return 0;
}
```
by 百里亦守约 @ 2019-03-27 17:17:33
@[scp6919](/space/show?uid=160208)
by 百里亦守约 @ 2019-03-27 17:19:02
@[百里亦守约](/space/show?uid=150354)
getline(cin, )//不是需要加长度吗?
求讲该函数用法(百度上未发现您的用法
)
by cfjm @ 2019-11-01 19:51:10