Why is the test case is wrong?

#include
#include<math.h>
using namespace std;
void invertdigit(int n){
int i=0;
int temp=n;
int original=n;
while(temp>0){
temp=temp/10;
i++;
}
int j=0;
int invertno=0;

while(j<i){
	int t=n%10;
	if(i-1==j && t==9){
		invertno+=(t*pow(10,j));
		break;
	}
	if(9-t<t){
		// if(j==i-1 && t==9){}
		// else
		t=9-t;
	}
	invertno+=(t*pow(10,j));
	n=n/10;
	j++;
	
}
cout<<invertno;

}
int main() {
int n;
cin>>n;
invertdigit(n);
return 0;
}

check out this code
you have make the things complex

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.