Thursday, March 16, 2017

uva problem Zapping-12468

problem link:
Discuss:
In this problem you have to find the minimum number of key press need to go desire channel.
You have only two button in your remote. firstly you just make the difference between the channel.
hence the channel from 0 to 99 and you can go backward so if the difference between channel more then or equal 50 then substitute it from 50.
to make difference between two channel you can use abs() function.


at first try yourself, if you can't then only see the code otherwise you can't increase your skill in programming


#include<stdio.h>
int main()
{
    int a,b,d,e;
    while(scanf("%d %d",&a,&b)==2&&a>=0&&b>=0)
    {
       d=abs(a-b);
       if(d>=50)
        d=100-d;
       printf("%d\n",d);
    }
    return 0;
}

No comments:

Post a Comment