My code is failing for some of the test cases

#include
#include
using namespace std;
int main() {
char ch[20];
int a[20],flag=0,count=0;
cin>>ch;
int n=strlen(ch);
for(int i=0;i<n;i++)
{
if(ch[i]-‘0’>‘9’-ch[i])
a[i]=‘9’-ch[i];
else
a[i]=ch[i]-‘0’;
}
for(int i=0;i<n;i++)
{
if(a[i]!=0)
flag=1;
if(a[i]==0)
count++;
if(a[i]==0 && flag==0)
continue;
else
{
if(count==n)
cout<<‘0’;
else
cout<<a[i];

	}
	
}
return 0;

}

Hi @namangarg31,
try modifying ur code.
if input is like 9 , 99, 9999 , etc. ur code gives no output whereas output should be 9 , 99 , 9999
Hope dis help.
if u still find any difficulty, feel free to post ur doubt here.