Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 03 / example 3 - reverse and increment.cpp
blob: e096f0bb2f13c7745ccae65aa6c233aa4e03acbb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
using namespace std;

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

	while (n != 0)
	{
		int lastDigit = n % 10;
		(reversed *= 10) += lastDigit;

		n /= 10;
	}

	reversed++;
	cout << reversed << endl;
}