第二个if加个else
by a11223344 @ 2024-09-20 20:11:17
@[Urbosa](/user/1094739)
```cpp
#include <bits/stdc++.h>
using namespace std;
long double n, x, y, a, b;
int main() {
cin >> n;
cin >> a >> b;
x = b / a;
for (long long i = 1; i < n; i++) {
cin >> a >> b;
y = b / a;
if (y - x > 0.05) {
cout << "better\n";
}
else if (x - y > 0.05) {
cout << "worse\n";
} else {
cout << "same\n";
}
}
return 0;
}
``
by Yxy7952 @ 2024-09-20 20:11:33
第二个if前加个else
by a11223344 @ 2024-09-20 20:11:43
```
#include <bits/stdc++.h>
using namespace std;
long double n, x, y, a, b;
int main() {
cin >> n;
for (long long i = 1; i <= n; i++) {
cin >> a >> b;
if (i == 1) {
x = b / a;
}
if (i > 1) {
y = b / a;
if (y - x > 0.05) {
cout << "better\n";
}else if (x - y > 0.05) {
cout << "worse\n";
} else {
cout << "same\n";
}
}
}
return 0;
}
```
by a11223344 @ 2024-09-20 20:12:13