题解 | #数字颠倒#
数字颠倒
https://www.nowcoder.com/practice/ae809795fca34687a48b172186e3dafe
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 32 int main(){ int n, m; while(scanf("%d", &n) == 1){ char buf[MAX] = {0}; char new_buf[MAX] = {0}; sprintf(buf, "%d", n); int len = strlen(buf); int new_len = 0; for(int i = len-1; i>=0; i--){ new_buf[new_len++] = buf[i]; } new_buf[new_len] = '\0'; //m = atoi(new_buf); printf("%s", new_buf); } }