ciel and A-b problem;why my solution is wrong

#include<stdio.h>
int main()
{
int A,B,c;
scanf("%d%d",&A,&B);
c=A-B;
if(c%10==0)
{
c=c+1;

}
else
{
	c=c-1;
}
printf("%d",c);

}

All you need to do is change the line - if(c % 10 == 0) to if(c % 10 != 9).

Check this link -> https://discuss.codechef.com/questions/67239/ciel-a-b-problem

It will answer your question.

Consider this test case:
A = 5891 and B = 5890

You code will output ‘0’.

I suppose correct answer will be 2 as a single ‘0’ can be counted as a leading zero and as per the constraints Leading zeros are not allowed.

Here is your AC solution: https://www.codechef.com/viewsolution/15383641

Hope this helps!

import java.lang.*;
class sub
{

   int a,b,res;
   void getdata(int A,int B)
     {
        a=A;
	b=B;
     }
   void show()
     {
        res=a-b;
        res=res-1;
        System.out.println(res);  
     }
}



class sample
{

  public static void main(String args[])
   {

        sub s=new sub();
        s.getdata(5858,1234);
        s.show();
   }
}

whats wrong in that???

Your logic seems fine to me, make sure while submitting your solution you’re selecting language(c (gcc6.3)

You are allowed to vary answer by only 1 digit. Say you got res=a-b=100. Then res-1=99 vaires on all 3 digits instead of just 1.