#include <iostream> #include <conio.h> using namespace std; int main() { int n, i = 0, x; int a[i]; cin >> n; while (n > 0) { i++; a[i] = n % 2; n = n / 2; } int l = i; x = a[4]; for (i; i >= 1; i--) { cout << a[i]; } cout << endl; for (i; i >= 2; i--) { a[i] = a[i - 1]; } a[1] = x; for (i; l >= 1; i--) { cout << a[i]; } _getch(); return 0; }
For some reason, the first element does not want to stand in the place of the last.
for (i; l >= 1; i--) { .. }
- withl >= 1
this is an infinite loop, for example. - Regent