It says that the code is not satisfying two test cases. I am not able to figure that out.
#include
using namespace std;
int main()
{int n,dig,i=0;
int ar[100];
cin>>n;
while(n>0)
{
dig=n%10;
if(dig<9-dig)
{
ar[i]=dig;
}
else
{
ar[i]=(9-dig);
}
i++;
n=n/10;
}
if(ar[i-1]==0)
{
ar[i-1]=9;
}
for(int j=i-1;j>=0;j--)
{
cout<<ar[j];
}
return 0;
}