Visual C++ - Rotate Number
The source code for rotating a Number in the bits is given on this page.
Source Code
void main()
{
int x = 12345678;
int p = x;
std::cout << "Rotating Number: " << p << "\n";
while(1)
{
int m = p % 10;
int n = p / 10;
p = n;
int numdigits = log10((double)n) + 1;
p = p + pow((double)10, numdigits) * m;
std::cout << p << "\n";
if(p == x)
break;
}
return ;
}
Output
Rotating Number:
12345678
81234567
78123456
67812345
56781234
45678123
34567812
23456781
12345678
Press any key to continue . . .
|