#include<stdio.h>
int main()
{
int a,b,count1,count2,l1,l2,sub,temp;
while(scanf("%d%d",&a,&b)==2)
{
if((a==-1)&&(b==-1))
break;
count1=0;
count2=0;
if(b<a)
{
temp=a;
a=b;
b=temp;
}
count1=b-a;
for(l1=a;l1!=b;l1--)
{
if(l1==-1)
{ l1=99;
if(b==99)
break;
}
count2=count2+1;
}
if(count1<count2)
printf("%d\n",count1);
else
printf("%d\n",count2);
}
return 0;
}
http://uva.onlinejudge.org/external/124/12468.html
int main()
{
int a,b,count1,count2,l1,l2,sub,temp;
while(scanf("%d%d",&a,&b)==2)
{
if((a==-1)&&(b==-1))
break;
count1=0;
count2=0;
if(b<a)
{
temp=a;
a=b;
b=temp;
}
count1=b-a;
for(l1=a;l1!=b;l1--)
{
if(l1==-1)
{ l1=99;
if(b==99)
break;
}
count2=count2+1;
}
if(count1<count2)
printf("%d\n",count1);
else
printf("%d\n",count2);
}
return 0;
}
http://uva.onlinejudge.org/external/124/12468.html
No comments:
Post a Comment