daily pastebin goal
16%
SHARE
TWEET

Untitled

a guest Feb 19th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int n,b,c,u,sum,p,i,a[100];
  5. int main()
  6. {
  7.     cin>>n>>b>>c;
  8.     sum=0;
  9.     p=1;
  10.     while(n!=0)
  11.     {
  12.         u=n%10;
  13.         sum=sum+u*p;
  14.         p=p*b;
  15.         n=n/10;
  16.     }
  17.     p=0;
  18.     while(sum!=0)
  19.     {
  20.         u=sum%c;
  21.         p++;
  22.         a[p]=u;
  23.         sum=sum/c;
  24.     }
  25.     for(i=p;i>=1;i--)cout<<a[i];
  26.  
  27.     return 0;
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top