求助!!!

B2065 鸡尾酒疗法

YUANSHEN101478 @ 2024-10-14 12:39:53

#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    for(int i=1;i<=n;i++){
        double  x,y;
        cin>>x>>y;
        if(y-x>x*0.05){
            cout<<"better"<<endl;   
        }
        if(x-y>y*0.05){
            cout<<"worse"<<endl;
        }
        else{
            cout<<cout<<"same";
        }
    }
    return 0;
}

by fifast @ 2024-10-19 15:48:54

@YUANSHEN101478

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n][2];
    for(int i=0;i<n;i++){
        for(int j=0;j<2;j++)cin>>a[i][j];
    }
    for(int i=1;i<n;i++){
        if(((a[i][1]*1.0/a[i][0]*100)-(a[0][1]*1.0/a[0][0]*100))>5)cout<<"better"<<endl;
        else{
            if(((a[0][1]*1.0/a[0][0]*100)-(a[i][1]*1.0/a[i][0]*100))>5)cout<<"worse"<<endl;
            else cout<<"same"<<endl;
        }
    }
    return 0;
}

求关!


|