#include
#include<math.h>
using namespace std;
int main() {
unsigned long long int num, sum=0, num_copy;
int count=0;
cin>>num;
num_copy = num;
while(num>0)
{
if((num%10)>4){ sum = sum+(9-num%10)*pow(10, count);}
else { sum = sum+(num%10)*pow(10,count);}
count++;
num = num/10;
}
if(sum>0){cout<<sum<<endl;}
else {cout<<num_copy<<endl;}
return 0;
}
Few test cases failing
No, this is a different question. The first time I posted a doubt for this.
ohhh ok sorry got confused let me check your code for this one
also please mark that one resolved if that one was clear
@varun.saxena what if 9 comes in first place for example 9555 input
your code gives 444 while it should be 9444 as leading zeroes are not allowed
Oh ok. Now i understand. I didn’t understand that part properly.
I thought it meant that it shouldn’t print something like “0444”.
Now, I understand. I will give it another shot.
And regarding the marking the issues as resolved, I am new to the portal so didn’t missed out on it, I have gone to my previous doubts and marked them as resolved. Thank you.
yes sure give it another try
ya ok no problem 