denis_andrei10

baza 10 to baza b

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