B2965 90 求助

B2065 鸡尾酒疗法

LIUZHIYU1 @ 2023-03-15 20:12:39


#include<iostream>
using namespace std;
int a,b,c;
double ch;
double z(int x,int y){
    return y/(double)x;
}
int main(){
    cin>>a;
    cin>>b>>c;
    ch=z(b,c);
    for(int i=0;i<a-1;i++){
        cin>>b>>c;
        if(ch-z(b,c)>ch*0.05)cout<<"worse\n";
        else if(z(b,c)-ch>ch*0.05)cout<<"better\n";
        else cout<<"same\n";
    }
}

by coding_goat @ 2023-03-15 20:41:11

答: 1.第14行if(ch-z(b,c)>ch*0.05 改为if(ch-z(b,c)>0.05)

2.第15行else if(z(b,c)-ch>ch*0.05)改为else if(z(b,c)-ch>0.05)


by coding_goat @ 2023-03-15 20:43:29

@LIUZHIYU1


by LIUZHIYU1 @ 2023-03-15 20:45:12

@hzhHZH233 谢谢,已 AC


|