Page 1 of 1

12468 - Zapping

Posted: Wed May 22, 2013 10:14 pm
by shondhi
Can anyone plz tell me what's wrong in my code.

Code: Select all

 #include <iostream>
#include <cstdio>
#include <cstdlib>
int main()
{
   int a, b, c, d;
   while(scanf("%d %d", &a, &b) == 2)
   {
      if(a == -1 && b == -1)
      {
         break;
      }
      else
      {
         c = abs(a - b);
         if(a == 0)
         {
            d = abs(100 - b);
         }
         else
         {
            d = abs(100 - b) + a;
         }
      }
      if(c > d)
      {
         printf("%d\n", d);
      }
      else
      {
         printf("%d\n", c); 
      }
   }
return 0;
} 

Re: 12468 - Zapping

Posted: Wed May 22, 2013 11:13 pm
by brianfry713
Try input:

Code: Select all

99 1
-1 -1