For example if we have 12345 it will return 54321
So here is the code I wrote:
#include "stdafx.h"
#include <iostream>
using namespace std;
unsigned Revert (unsigned number)
{
unsigned result=0,i;
while (number> 0)
{
i = number%10;
result = result * 10 + i;
number = number / 10;
}
return result;
}
int _tmain(int argc, _TCHAR* argv[])
{
unsigned numb;
cout<<"Input number\n";
cin>> numb;
cout<<Revert(numb)<<endl;
return 0;
}
No comments:
Post a Comment