#include
using namespace std;
int main() {
char a[100];
cin>>a;
int i=0;
if(a[0]==‘9’){ cout<<a[0];i++; }
for(;a[i]!=0;i++)
{
int digit=a[i]-‘0’;
if(digit>=5)
cout<<(9-digit);
else cout<<digit;
}
return 0;
}
Chewbacca 2nd case failed
1 Like
Hy harshit your code was correct in it’s logic the only problem was u didn’t put iostream after #include and u were using back ticks in spite of single quotes
After correcting these issues it got submitted properly
#include<iostream>
using namespace std;
int main() {
char a[100];
cin>>a;
int i=0;
if(a[0]=='9'){ cout<<a[0];i++; }
for(;a[i]!=0;i++)
{
int digit=a[i]-'0';
if(digit>=5)
cout<<(9-digit);
else cout<<digit;
}
return 0;
}