将数字逆序
如:输入:7631,反转后为:1367
#include <iostream>
using namespace std;
int main()
{
int in;
cout << "请输入反转的数字:";
cin >> in;
int sum = 0;
int temp = in;
while (true)
{
if (temp == 0)
{
break;
}
sum = sum*10 + temp % 10;
temp /= 10;
}
cout << "原数: " << in << endl;
cout << "反转后的数: " << sum << endl;
system("pause");
return 0;
}