#include
#include
using namespace std;
int main(){
long long int n,ans;
cin>>n;
int base=1;
while(n>0){
int r=n%10;
if(9-r<r){
r=9-r;
}
ans=ans+r*base;
base=base*10;
n=n/10;
}
cout<<ans;
}
#include
#include
using namespace std;
int main(){
long long int n,ans;
cin>>n;
int base=1;
while(n>0){
int r=n%10;
if(9-r<r){
r=9-r;
}
ans=ans+r*base;
base=base*10;
n=n/10;
}
cout<<ans;
}
Hello @shikharskj
is have corrected your code but this appraoch i dont think it will pass all test cases.
because the test cases here are very large.
your code which i have corrected : https://ide.codingblocks.com/s/387895
and the correct code which you can submit:
https://ide.codingblocks.com/s/387892
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.