Next time you shouldn't make arbitrary rules. No one said it was going to be stored in a single integer. Look at the first example and you can see it's been split into digits. Furthermore, you can decode it just fine if you store the length of the number. Hey, if you get to make up your own rules to prove your point, I get to do the same.
Code:
int enc(int *data){
int res=0,x=*data,num;
int len = 0;
while( x ){
++len;
res*=10;
num=x%10;
res+=(num+7)%10;
x/=10;
}
*data=res;
return len;
}
int dec(int *data, int len){
int res=0,x=*data,num;
while( len-- ){
res*=10;
num=x%10;
res+=(num+3)%10;
x/=10;
}
*data=res;
return 0;
}
Did I ever mention you write ugly code, which is ... bad? I can't figure out what on earth is going through your head when you write most of it. Anyway, that works just fine. Store the length. See? My made up rules say your made up rules are wrong.
Quzah.