Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void sisyphus1(int stone)
- {
- int sisyphus = stone;
- do {
- cout << sisyphus << endl;
- stone = sisyphus;
- int digits[10] = { 0 };
- int cnt = 0;
- while (sisyphus > 0) {
- digits[cnt++] = sisyphus % 10;
- sisyphus /= 10;
- }
- int even = 0, odd = 0;
- for (int i = 0; i < cnt; i++) {
- if (digits[i] % 2 == 0) {
- even++;
- } else {
- odd++;
- }
- }
- sisyphus = even * 100 + odd * 10 + cnt;
- } while (sisyphus != stone);
- }
- void sisyphus2(int stone)
- {
- int sisyphus = stone;
- do {
- cout << sisyphus << endl;
- stone = sisyphus;
- sisyphus = 0;
- int tmp = stone;
- while (tmp > 0) {
- sisyphus += (tmp % 2 == 0) ? 101 : 11;
- tmp /= 10;
- }
- } while (sisyphus != stone);
- }
- int main()
- {
- const int __STONE__ = 43005798;
- sisyphus1(__STONE__);
- cout << endl;
- sisyphus2(__STONE__);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement