题解 | #数字颠倒#
数字颠倒
https://www.nowcoder.com/practice/ae809795fca34687a48b172186e3dafe
#include <stdio.h> #include <string.h> int main() { //法一 /*char s[30]; scanf("%s",&s); int l=strlen(s); int i=l-1; for(i;i>=0;i--) printf("%c",s[i]);*/ //法二 int n; scanf("%d", &n); if (n == 0) printf("0\n"); else { while (n > 0) { printf("%d", n % 10); n /= 10; } } return 0; }