```cpp
#include <iostream>
using namespace std;
int main(){
int n;
cin>>n;
int arr[n][2];
int i=0,j=0,k=1;
double m=0,p=0;
while(i<n){
while(j<2){
cin >> arr[i][j];
j++;
}
j=0;
i++;
}
m=arr[0][1]*(1.0)/arr[0][0];
while(k<n){
p=arr[k][1]*(1.0)/arr[k][0];
if(p-m > 0.05){
cout << "better" << endl;
}
if(p-m < -0.05){
cout << "worse" << endl;
}
if(p-m < 0.05&&p-m > -0.05){
cout << "same" << endl;
}
k++;
}
return 0;
}
```
by Laihaocheng @ 2024-10-26 22:17:46
你得`dyz`是个int啊
by shawn0618 @ 2024-10-26 22:18:40
@[michaelwanghaoyu](/user/1266484)
```
long long n,p,r;
cin>>n;
cin>>p>>r;
double v=r*1.0/p,tmp;
for (int i=0;i<n-1;i++){
cin>>p>>r;
tmp=r*1.0/p;
if (v-tmp>0.05) cout<<"worse"<<endl;
else if (tmp-v>0.05) cout<<"better"<<endl;
else cout<<"same"<<endl;
}
```
这么写,你的代码中
```
if (1.0*y/x-dyz>=0.05)//把等号去掉
{
cout<<"better"<<endl;
}
else if (dyz-1.0*y/x>=0.05) //把等号去掉
{
cout<<"worse"<<endl;
}
```
你代码里等号太多了
by shawn0618 @ 2024-10-26 22:22:58
@[shawn0618](/user/374443) 关注了
by michaelwanghaoyu @ 2024-10-26 22:25:03