1.现将数字n对10取余
2.再将数字n对10取整
3.循环第一,二步即可
#include <iostream>
using namespace std;
int main(void)
{
int n,right_digit;
cout<<"Enter the number:";
cin>>n;
cout<<"The number in reverse order is ";
do
{
right_digit = n%10;
cout <<right_digit;
n/=10;
}
while(n!=0);
cout<<endl;
}
调试结果: