题解 | #数字颠倒#
数字颠倒
https://www.nowcoder.com/practice/ae809795fca34687a48b172186e3dafe
#include <stdio.h>
#include <malloc.h>
#include<string.h>
int main() {
long int n;
scanf("%ld",&n);
char ret[1000];
sprintf(ret, "%d", n);//将整形转为字符串
int len=strlen(ret);
int high=len-1;
int low=0;
while(high>low)//交换他们的位置
{
char flag=ret[low];
ret[low]=ret[high];
ret[high]=flag;
low++;
high--;
}
printf("%s",ret);
}
