Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <conio.h>
- #include <iostream>
- #include <string>
- using namespace std;
- void main()
- {
- int N, d, B[20], t = 0, temp, c;
- char *max;
- cin >> N;
- string result;
- do
- {
- result = (char)('0' + (N % 2)) + result;
- N = N / 2;
- } while (N > 0);
- char* str = new char[result.size() + 1];
- strcpy(str, result.c_str());
- for (int i = 0; i < result.size() + 1; i++)
- cout << str[i];
- cout << endl<<endl;
- max=str;
- for (int j=0;j<result.size();j++)
- {
- temp = str[result.size() - 1];
- for (int i = result.size()-1; i >= 0; i--)
- {
- str[i] = str[i - 1];
- }
- str[0] = temp;
- if (strcmp(str,max)>0)
- max=str;
- cout<<max;
- }
- for (int i = 0; i < result.size() + 1; i++)
- cout << max[i];
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement