0
I need to invert a sequence of numbers, for example, if 1234 is inserted, I print 4321. The code is working, but for Type 0123 or Type 1230 entries the zero is simply "deleted", but I needed the zero also to be displayed on the screen. I couldn’t think or find a solution to this, someone can help me?
int main()
{
long n;
long inverso;
scanf("%ld",&n);
do
{
inverso=n%10;
printf("%ld",inverso);
n/=10;
}while(n>0);
printf("\n");
return 0;
}
n
need to be long? 0 the left will always be ignored for long, this is normal. 0123 is the same thing as 123. The same happens with 1230, initially 0 is there, because it is 1.230, after reversing the same happens and it happens to be 321.– George Wurthmann
For me, with the ticket
1230
worked perfectly. To0123
, in fact, 0 is ignored for the reason explained above.– Woss
yes it needs to be long, this is a lot of URI, number 1984, for those who know the URI...
– soAna
Statement: https://www.urionlinejudge.com.br/judge/en/problems/view/1984
– Woss
If you ask as input a number can not have a 0 at the beginning.
– Maniero