简单模拟题,
输入时先排一个序就好了
Code
#include<stdio.h>
void process(double a,double b,double c,double d)
{
int result=0;
while(c>a)
{
c/=2;result++;
}
while(d>b)
{
d/=2;result++;
}
printf("%d\n",result);
}
int main()
{
double a,b,c,d,t;
while(scanf("%lf %lf %lf %lf",&a,&b,&c,&d)!=EOF)
{
if(a>b)
{
t=a;a=b;b=t;
}
if(c>d)
{
t=c;c=d;d=t;
}
process(a,b,c,d);
}
}
#include<stdio.h>
void process(double a,double b,double c,double d)
{
int result=0;
while(c>a)
{
c/=2;result++;
}
while(d>b)
{
d/=2;result++;
}
printf("%d\n",result);
}
int main()
{
double a,b,c,d,t;
while(scanf("%lf %lf %lf %lf",&a,&b,&c,&d)!=EOF)
{
if(a>b)
{
t=a;a=b;b=t;
}
if(c>d)
{
t=c;c=d;d=t;
}
process(a,b,c,d);
}
}