写一个C++程序,求一个整数的反序
时间: 2024-05-27 16:14:08 浏览: 53
#include <stdio.h>
int main() {
int num, reversed_num = 0;
printf("请输入一个整数:");
scanf("%d", &num);
while (num != 0) {
reversed_num = reversed_num * 10 + num % 10;
num /= 10;
}
printf("反序数为:%d", reversed_num);
return 0;
}
阅读全文