题解 | #数字颠倒#
数字颠倒
https://www.nowcoder.com/practice/ae809795fca34687a48b172186e3dafe
#include <ctype.h> #include <stdio.h> int main() { int i = 0; int temp = 0, value = 0; int val[10]; scanf("%d", &value); while (value >= 0 && i < 10) { temp = value % 10; val[i++] = temp; if (value > 9) { value = (value - temp) / 10; }else { break; } } for (int j = 0; j < i; j++) { printf("%c", '0' + val[j]); } return 0; }