wuxiangtianbei @ 2022-11-30 14:41:54
#include<stdio.h>
int main()
{
int i,j;
double n,a,b;
double x,y;
int c[20];
int d[20];
scanf("%lf",&n);
scanf("%lf%lf",&a,&b);
x=b/a;
for(i=1;i<n;i++)
{scanf("%d%d",&c[i],&d[i]);
}
for(j=1;j<n;j++)
{
y=d[j]/c[j];
if(y-x<0.05)printf("better\n");
else if(x-y<0.05)printf("worse\n");
else if((x-y)>=0.05&&(y-x)<0.05)printf("same\n");
}
}
by jason_sun @ 2022-11-30 15:58:25
#include<stdio.h>
int main()
{
int i,j;
double n,a,b;
double x,y;
int c[20];
int d[20];
scanf("%lf",&n);
scanf("%lf%lf",&a,&b);
x=b/a;
for(i=1;i<n;i++)
{scanf("%d%d",&c[i],&d[i]);
}
for(j=1;j<n;j++)
{
y=1.0*d[j]/c[j];
if(y-x>0.05)printf("better\n");
else if(x-y>0.05)printf("worse\n");
else printf("same\n");
}
}
by jason_sun @ 2022-11-30 15:58:44
@wuxiangtianbei
by wuxiangtianbei @ 2022-11-30 20:42:36
@jason_sun 感谢,已改正,请问为什么y=1.0*d[j]/c[j]; 的1.0一定要放在最前面呢,我放在最后运行错误了
by jason_sun @ 2022-11-30 22:26:06
@wuxiangtianbei int转换成double