题解 | #数字颠倒#
数字颠倒
https://www.nowcoder.com/practice/ae809795fca34687a48b172186e3dafe
#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> #include<assert.h> #include<string.h> void Down(char* str)//这里是正常打印 因为是倒置的放置 { assert(str != NULL); int len = strlen(str); for (int i = 0; i < len; i++) { printf("%c", *(str+i)); } } void Conversion(char str[], int n)//转换到数组里面 初始化数组 { int i = 0; do { str[i++] = n % 10 + '0'; n /= 10; } while (n > 0); } int main() { int n = 0; char str[1000] = { 0 }; scanf("%d", &n); Conversion(str, n); Down(str); return 0; }