I took the input in long long int, still two of my test cases aren't passing

#include
#include
using namespace std;
int main() {
long long int n;
cin>>n;
vector v;
int len=0,p=n;
while(p!=0)
{
long long int l_term=p%10;
p=p/10;
v.push_back(l_term);
len++;
}
bool zero=true;
for(int i=len-1;i>=0;i–)
{
if(v[i]>=5)
{
v[i]=9-v[i];
}
if(zero&&v[i]==0)
{
v[i]=9-v[i];
}
zero=false;
cout<<v[i];

}
return 0;

}

@Rohanaggarwal8590
Input :
999554

Expected Output :
900444

Your Output :
444000

No, my output is coming 900444.

Code: #include #include using namespace std; int main() { long long int n; cin>>n; vector v; int len=0,p=n; while(p!=0) { long long int l_term=p%10; p=p/10; v.push_back(l_term); len++; } bool zero=true; for(int i=len-1;i>=0;i–) { if(v[i]>=5) { v[i]=9-v[i]; } if(zero&&v[i]==0) { v[i]=9-v[i]; } zero=false; cout<<v[i]; } return 0; }

@Rohanaggarwal8590
Share it using ide.codingblocks.com please. The formatting of the code changes if you copy-paste it here and hence it may have caused some other changes. Share it using the IDE so I can have a a proper look at your code.

Here: https://ide.codingblocks.com/s/113706

@Rohanaggarwal8590
Your code gives wrong answers for input larger than 10 digits.
Input :
999944316438

Expected Output :
900044313431

Your Output :
-7-8-30-6-3-5-30

The problem seems be because of storage capacity only. Use long long int for all variables rather than just n and the problem is solved.