Requirements:
(1) Convert the inputted 3-digit integer, the single digit to a hundred digit, and the hundreds digit to a single digit, and generate a new inverted number from the converted 3 digits.
(2) Arbitrary 3-digit integers are input by keyboard.
(3) When outputting the result, the required form is: original number: converted number.
#include <iostream>
using namespace std;
int main()
{
int num,rev = 0;
cout<<"Enter a Number: ";
cin>>num;
while (num > 0)
{
rev = (rev * 10) + (num % 10);
num = num / 10;
}
cout<<rev<<endl;
return 0;
}
Comments
Leave a comment