C语言经典例题--对任意位数的正整数进行逆置

对任意位数的正整数进行逆置

#include <stdio.h>

int main()
{
	int x;
	scanf("%d", &x);
	int digit;
	int ret = 0;

	while (x > 0)
	{
		digit = x % 10;
		ret = ret * 10 + digit;
		x /= 10;
	}
	printf("%d", ret);
	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_42386328/article/details/81173782
今日推荐