c鸡尾酒疗法
鸡尾酒疗法的有效率为 x,新疗法的有效率为 y,
如果 y-x 大于 5%,则效果更好,
如果 x-y 大于 5%,则效果更差,
否则称为效果差不多。
给出 n 组临床对照实验,其中第一组采用鸡尾酒疗法,其他 n-1 组为各种不同的改进疗法。
输入:
第一行为整数 n(1<n<=20);其余 n 行每行两个整数,第一个整数是临床实验的总病例数(小于等于 10000),第二个疗效有效的病例数。这 n 行数据中,第一行为鸡尾酒疗法的数据,其余各行为各种改进疗法的数据。
输出:
有 n-1 行输出,分别表示对应改进疗法的效果:如果效果更好,输出 better;如果效果更差,输出 worse;否则输出 same。
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char *argv[]){
int n=0,a=0,b=0;
double reference=0;
scanf("%d",&n);
scanf("%d %d",&a,&b);
reference=(double)b/a;
n--;
while(n!=0){
scanf("%d %d",&a,&b);
if(((double)b/a-reference)>0.05){
printf("better ");
}else if((reference-(double)b/a)>0.05){
printf("worse ");
}else{
printf("same ");
}
n--;
}
return 0;
}