c++为什么不让我输完

B2065 鸡尾酒疗法

Zjh_abcdbt_rnfmabj @ 2023-08-23 18:08:41

#include<bits/stdc++.h>
using namespace std;
int main() {
    int n,ans,sum;
    int x,y;
    cin>>x>>y;
    cin>>n;
    ans=y*1.0/x;
    for(int i=2;i<=n;i++){
        cin>>x>>y;
        sum=y*1.0/x;
        if(sum/ans>0.05) cout<<"better"<<endl;
        else if(ans/sum>0.05) cout<<"worse"<<endl;
        else cout<<"same"<<endl; 
    }
    return 0; 
}
悬赏:一个关注

by CQ_Bob @ 2023-08-23 18:11:31

@zhnagjiahan123 删掉第6行


by pragma_GCC @ 2023-08-23 18:11:43

cin>>x>>y;
cin>>n;

这两行调换一下

by CQ_Bob @ 2023-08-23 18:12:12

@zhnagjiahan123 然后放到cin>>n后面


by lzx0 @ 2023-08-23 18:15:29

x,y与n的输入换一下


by Zjh_abcdbt_rnfmabj @ 2023-08-23 18:19:11

谢谢,全部关注了


by FurippuWRY @ 2023-08-23 18:20:01

@zhnagjiahan123 你这代码会爆RE啊


by lzx0 @ 2023-08-23 18:20:03

还有sum和ans应该是-吧


by lzx0 @ 2023-08-23 18:26:36

@zhnagjiahan123 int换成double


by LZMkingNB @ 2023-08-23 18:38:31

学c++,赢


by Zjh_abcdbt_rnfmabj @ 2023-08-24 11:57:31

谢谢,大家


|