Wrong Bill Calculation


In Ciel's restaurant, a waiter is training. Since the waiter isn't good at arithmetic, sometimes he gives guests wrong change. Ciel gives him a simple problem. What is A-B (A minus B) ? Surprisingly, his answer is wrong. To be more precise, his answer has exactly one wrong digit. Can you imagine this? Can you make the same mistake in this problem? Input An input contains 2 integers A and B. Output Print a wrong answer of A-B. Your answer must be a positive integer containing the same number of digits as the correct answer, and exactly one digit must differ from the correct answer. Leading zeros are not allowed. If there are multiple answers satisfying the above conditions, anyone will do. The correct answer of 5858-1234 is 4624. So, for instance, 2624, 4324, 4623, 4604,4625 and 4629 will be accepted, but 0624, 624, 5858, 4624 and 04624 will be rejected. Test Case 1 Input (stdin) 5858 1234 Expected Output 4625 Test Case 2 Input (stdin) 321 165 Expected Output 157

Program :

#include <iostream>
using namespace std;
int main()
{int a;
  int b;
  int difference = abs(a - b);
  //printf("\ncorrect is %d-%d=%d", a, b, difference);
  int last_digit = difference % 10;
  //printf("\nlast digit is %d\n", last_digit);
  if(last_digit != 9) {
  } else {
  return 0;