×

include<stdio.h>

using namespace std;

int main() {

int a , b;

scanf("%d%d",&a,&b);

int c = a-b;

c= (c/10)*10 + (c%10 + 1)%10;

printf("%d\n",c);
return 0;


}

I AM JUST CHANGING LAST DIGIT OF CODE TO INCREMENT BY 1 , IF THE LAST DIGIT IS 9 THEN IT IS REPLACED BY 0

115
accept rate: 0%

 0 I think your code is failing for the following test case : 10 1  Your code will give 0 as the answer while 0 can't be. You can simply do it like, find the difference and if the difference%10 is 9, then print diff-1 else print diff+1. answered 25 Jan '15, 11:56 3★damn_me 2.6k●2●13●36 accept rate: 24%
 0 yeahhh got you !!!! answered 25 Jan '15, 12:00 1●1●5 accept rate: 0%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×856
×135
×10
×8
×2

question asked: 25 Jan '15, 11:43

question was seen: 981 times

last updated: 28 May '16, 21:49