Luke Skywalker gave Chewbacca an integer number x. Chewbacca isn’t good at numbers but he loves inverting digits in them. Inverting digit t means replacing it with digit 9 - t. Help Chewbacca to transform the initial number x to the minimum possible positive number by inverting some (possibly, zero) digits. The decimal representation of the final number shouldn’t start with a zero
#include
#include
using namespace std;
int check(int a)
{
int number1, sum = 0, i = 0;
while (a != 0)
{
number1 = a % 10;
if (number1 > 4)
{
number1 = 9 - number1;
}
sum += (number1*pow(10, i));
i++;
a = a / 10;
}
return sum;
}
int main()
{
long long int number, p;
cin >> number;
p = check(number);
cout << p;
return 0;
}