题目大意:
给四个数,每两个一组,分别代表图片的长和宽,可以旋转。问把第一张图片缩小长和宽,使得均小于第二张图片,比例是多少
解题思路:
先把长边对长边,短边对短边,然后算比例即可
代码如下:
#include<iostream>
int main()
{
int a,b,c,d;
int tmp;
double x1,x2;
while(scanf("%d%d%d%d",&a,&b,&c,&d))
{
if(a==0&&b==0&&c==0&&d==0)
{
break;
}
if((a>=b)&&(c<=d))
{
tmp=c;
c=d;
d=tmp;
}
else if((a<=b)&&(c>=d))
{
tmp=a;
a=b;
b=tmp;
}
x1=a*1.0/c;
x2=b*1.0/d;
if(x1>=x2)
{
tmp=(int)((c*1.0/a)*100);
}
else
{
tmp=(int)((d*1.0/b)*100);
}
if(tmp>=100)
printf("100%%\n");
if(tmp<100&&tmp>1)
printf("%d%%\n",tmp);
if(tmp<=1)
printf("1%%\n");
}
return 0;
}