12468 - Zapping

All about problems in Volume 124. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
shondhi
New poster
Posts: 25
Joined: Tue Oct 02, 2012 5:24 pm
Location: Chittagong
Contact:

12468 - Zapping

Post by shondhi » Wed May 22, 2013 10:14 pm

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;
} 

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 12468 - Zapping

Post by brianfry713 » Wed May 22, 2013 11:13 pm

Try input:

Code: Select all

99 1
-1 -1
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 124 (12400-12499)”