你 倒 是 发 代 码 呀
by WINDOWSareC @ 2022-12-02 10:23:43
你
by ZWH1029384756 @ 2022-12-03 16:14:42
代
by ZWH1029384756 @ 2022-12-03 16:14:54
码
by ZWH1029384756 @ 2022-12-03 16:15:10
呢
by ZWH1029384756 @ 2022-12-03 16:15:22
做法很精妙,但是你似乎忘了ans存储的是**有几个**100元,而不是**几百元**
```cpp
#include <bits/stdc++.h>
using namespace std;
int now,need,ans;
int main()
{
for (int i = 1; i <= 12; i++)
{
cin >> need;
now += 300;
if (now < need)
{
cout << "-" << i << endl;
return 0;
}
now -= need;
ans += now / 100;
now %= 100;
}
ans *= 120;//更改在此,此处应该计算有几百元,而不是几个100元
cout << now + ans << endl;
return 0;
}
```
这样应该就没问题了
by Earth_Studio @ 2022-12-19 15:51:03
说没发代码的一定没仔细看XD
by Earth_Studio @ 2022-12-19 15:51:44
@[Earth_Studio](/user/247605) 更改处实际就是乘以100,1.2×100=120,这样就可以计算出正确的存钱数目
by Earth_Studio @ 2022-12-19 15:53:27