zhazhaqi77 @ 2022-10-07 22:27:16
#include<stdio.h>
int main()
{
int j1,j2,n1,n2;
int i=1,n;
double sub=0;
int k[100];//n个,从1开始有n-1个,(0到n-1
k[0]=0;
scanf("%d",&n);
scanf("%d %d",&j1,&j2);//j1总病例,j2有效病例,
double x=(double)j2/(double)j1;//鸡尾酒有效率
for(i;i<n;i++){
scanf("%d %d",&n1,&n2);
double y=(double)n2/(double)n1;//新疗法的有效率
sub=y-x;//sub>0.05,or sub<-0.05
k[i]=sub;
}
for(i=1;i<n;i++){
if(k[i]>0.05){
printf("better\n");
}else
if(k[i]<-0.05){
printf("worse\n");
}else{
printf("same\n");
}
}
return 0;
}
为啥我断点调试的时候(145 99)sub是正确的,但是数组里头就是存不进去???
by jnyz2021109122116 @ 2022-10-08 09:11:19
@zhazhaqi77 数组要开double,float也够了
float k[100];
by zhazhaqi77 @ 2022-10-08 14:35:34
@jnyz2021109122116 谢谢!! 人麻了