- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
int naive_show_int(int x) {
char buf[32];
char *p = buf + sizeof(buf);
*--p = 0;
int negative = 0;
if (x < 0) {
x = -x;
negative = 1;
}
while (x > 0) {
if (x <= 0)
return -1;
int digit = '0' + x % 10;
if (digit < '0' || digit >= '9')
return -1;
*--p = digit;
x /= 10;
}
if (negative)
*--p = '-';
puts(p);
return 0;
}
Follow us!