Answer to Question #47557 in C++ for Naresh
Write a class called reverse to reverse an unsigned integer. For
example, 8602 should be written as 2068
1
2014-10-06T12:48:33-0400
#include <iostream>
#include <string>
using namespace std;
class revers
{
public:
unsigned int reverse(unsigned int num)
{
string rev = to_string(num);
std::reverse(rev.begin(), rev.end());
return unsigned int(atoll(rev.c_str()));
}
};
int main()
{
unsigned int n = 8602;
revers r;
cout << r.reverse(n);
cin.get();
cin.get();
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++
Comments
Leave a comment