在线IDE的结果和本地一样吗
by lightningZ @ 2021-08-18 16:14:14
@[电弧Z](/user/456787) 在线运行这样的:
0.000
1458730656
by Aheaddd @ 2021-08-18 16:17:44
@[Aheaddd](/user/549907) `s[i]` 是 char 类型,您应当把它强制转换成 int,可以通过 `(int) s[i]` 转换
另,您的方法并不对,hack:
```plain
input
a:=1;a:=2
output
2 0 0
```
by 阿丑 @ 2021-08-18 16:18:24
~~可以输出中间变量~~
by 阿丑 @ 2021-08-18 16:18:56
@[阿丑](/user/364963) 我不是转换了嘛
by Aheaddd @ 2021-08-18 16:37:14
@[Aheaddd](/user/549907) 输出的时候
by 阿丑 @ 2021-08-18 18:40:55
@[阿丑](/user/364963) 没用,我试了
by Aheaddd @ 2021-08-18 20:48:24
```cpp
#include<iostream>
#include<string>
using namespace std;
string s;
int main()
{
cin >> s;
for (int i = 0; i < s.length()-1; i++)
{
if (s[i] == '=')
if (s[i + 1] >= '0'&&s[i + 1] <= '9')s[i - 2] = (int)(s[i + 1] - '0');
else s[i - 2] = s[0 + ((int)s[i + 1] - 97) * 5];
}
cout << (int) s[0] << " " << (int) s[5] << " " << (int) s[10];
return 0;
}
```
`using namespace std` 应该写在 `string s` 前面。
另,您的方法并不对,对于这组数据:
```plain
input
a:=1;a:=2;
output
2 0 0
```
您可以通过输出中间变量的方式来检查您的程序是否符合预期
by 阿丑 @ 2021-08-18 21:24:06
@[Aheaddd](/user/549907)
by 阿丑 @ 2021-08-18 21:24:46
@[阿丑](/user/364963) ok谢谢啦
by Aheaddd @ 2021-08-18 22:44:16