首先,你的代码没有注释,这会给想解答你的问题的人觉得无从下手。下次提问时请务必加注释来指出你**某个变量的作用或是某行的作用**,这可以让看到你提问的人尽快知道你的方法从而快速找你的问题。
第二,如我说的,我并没有看懂你的代码除了while循环以外的部分在干什么。但我肯定你的代码中有许多无用的地方,以下是我将你的代码删去无用部分并更改后AC的代码:
```cpp
#include<bits/stdc++.h>
using namespace std;
int main(){
double s{};
double x{};
cin >> s >>x;
double rate = 7;
double t = 0;
double y = 0;
// if (s < x &&s>0) {
// if (s + x / 2 > rate) {
// cout << 'y' << endl;
// }
// else {
// cout << 'n' << endl;
// }
// }
// if (s <= 0) {
// if (x + s > rate) {
// cout << 'y' << endl;
// }
// else {
// cout << 'n' << endl;
// }
// }
while (y < s-x) {
y = y + rate;
rate *= 0.98;
}
// if (y > s) {
// // rate /= 0.98;
// // t = (y - s) / rate;
if (y+rate > s+x) {
cout << 'n' << endl;
}
else {
cout << 'y' << endl;
}
// }
// else {
// if (y-(rate * 0.98) < x-s) {
// cout << 'y' << endl;
// }
// else {
// cout << 'n' << endl;
// }
// }
system("pause");
return 0;
}
```
希望我的帮助能让你学会如何提问。
by sunningyi @ 2023-08-28 23:59:10
以及如果你想知道更多提问的技巧,可以找时间看看[这篇文章](https://www.luogu.com.cn/blog/StudyingFather/how-to-ask-questions-the-smart-way-luogu-edition)。
by sunningyi @ 2023-08-29 00:07:08
@[sunningyi](/user/816689) 非常感谢!
by Fate_money @ 2023-08-30 23:07:15