Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- long long perevod (long long znach, int osn_1)
- {
- long long result = 0;
- int shet = 0;
- long long znach_1 = znach;
- while (znach_1 > 0)
- {
- znach_1 = znach_1/10;
- shet++;
- }
- shet--;
- int n = pow(10, shet);
- while (znach > 0)
- {
- result += (znach/n)*(pow(osn_1, shet));
- znach = znach%n;
- shet--;
- n = pow(10, shet);
- }
- return result;
- }
- long long perevod_1(long long znach, int osn_1, int osn_2)
- {
- long long result = 0;
- int shet = 0, n = 0;
- znach = perevod(znach, osn_1);
- while(znach > 0)
- {
- n = pow(10, shet);
- result += (znach % osn_2)*n;
- znach = znach / osn_2;
- shet++;
- }
- return result;
- }
- int main()
- {
- long long znach;
- int osn_1, osn_2;
- cin >> znach >> osn_1 >> osn_2;
- znach = perevod_1(znach, osn_1, osn_2);
- cout << znach;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement