2. The three-digit reverse

topic:

Three-digit number, it is isolated from the hundreds, tens and ones, the inverted output.

Sample input:

127

Sample output:

721

 

Ideas:

Using the result is an integer of characteristics other integer,

1. The first three digits divided by 100, the resulting figure is one hundred.

2. will take more than three digits of 100, get a double-digit, and then the double digits divided by 10, the resulting figure is ten.

3. Direct will take more than three digits to 10, the resulting number is the number of bits.

Provided one hundred, ten, respectively, with variable bit high, mid, low FIG.

Provisions high = n / 100;

     mid = n % 100 / 10;

     low = n % 10;

Code:

#include <iostream>
using namespace std;

int main()
{
int n = 0;
cin >> n;

int high = n / 100;
int mid = n % 100 / 10;
int low = n % 10;

cout << low << mid << high << endl;

return 0;
}

Guess you like

Origin www.cnblogs.com/Hello-Nolan/p/12109118.html