denis_andrei10

baza b to baza 10

Dec 18th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.25 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int x10=0, xb, b, pb=1;
  6.     cin>>xb>>b;
  7.     while(xb)
  8.     {
  9.         int cifra=xb%10;
  10.         x10=x10+cifra*pb;
  11.         pb*=b;
  12.         xb=xb/10;
  13.     }
  14.     cout<<x10;
  15.     return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment