满江红QAQ

B2065 鸡尾酒疗法

lzy13915136909 @ 2024-05-20 21:06:00

本蒟蒻的code......

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[1005],b[1005];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i];
    for(int i=0;i<n;i++)
    {
        if(a[i]-b[i]>0.05)
            cout<<"better"<<endl;
        else
        {
            if(b[i]-a[i]>0.05)
                cout<<"worse"<<endl;
            else
                cout<<"same"<<endl;
        }
    }
    return 0;
}

来自一个六年级蒟蒻的彷徨


by abc1234shi @ 2024-05-20 21:09:56

数组别在幂里定啊


by 红黑树 @ 2024-05-20 21:10:15

@lzy13915136909 是有效“率”哦,不是个数。


by 红黑树 @ 2024-05-20 21:10:58

@abc1234shi 数组在 main 里有啥问题吗?


by abc1234shi @ 2024-05-20 21:12:01

@红黑树 不然数组里会有随机数


by 红黑树 @ 2024-05-20 21:13:45

@abc1234shi 但是他会用读入冲掉。


by abc1234shi @ 2024-05-20 21:15:26

@lzy13915136909 1.你应该是输入完一个就输出一个答案。2.是效率差而不是两个数的差


by March7thDev @ 2024-05-20 21:17:27

#include <iostream>
using namespace std;
int main()
{
    int n, a[30][2];
    double x, y;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i][0] >> a[i][1];
    x = 1.0 * a[0][1] / a[0][0];
    for (int i = 1; i < n; i++)
    {
        y = 1.0 * a[i][1] / a[i][0];
        if (y - x > 0.05)
            cout << "better" << endl;
        else if (x - y > 0.05)
            cout << "worse" << endl;
        else
            cout << "same" << endl;
    }
    return 0;
}

by lzy13915136909 @ 2024-05-20 21:17:52

@abc1234shi @红黑树 ,还是没懂...... code

#include<bits/stdc++.h>
using namespace std;
int n,a[1005],b[1005];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i];
    for(int i=0;i<n;i++)
    {
        if(a[i]-b[i]>0.05)
            cout<<"better"<<endl;
        else
        {
            if(b[i]-a[i]>0.05)
                cout<<"worse"<<endl;
            else
                cout<<"same"<<endl;
        }
    }
    return 0;
}

by March7thDev @ 2024-05-20 21:18:00

同样六年级qaq


by abc1234shi @ 2024-05-20 21:19:11

@lzy13915136909 你第二个循环不要了,加到第一个循环里


| 下一页