Advertisement
a53

baze

a53
Apr 18th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int n,m,p,r,b,c,x[100],k;
  4.  
  5. int main()
  6. {
  7. cin>>n>>b>>c;
  8. //conversia lui n din baza b in baza 10 si se obtine m
  9. p=1;
  10. while(n!=0)
  11. {
  12. r=n%10;
  13. m=m+r*p;
  14. p=p*b;
  15. n=n/10;
  16. }
  17. //conversia lui m din baza 10 in baza c si se obtine n
  18. p=1;
  19. while(m!=0)
  20. {
  21. r=m%c;
  22. k++;
  23. x[k]=r;
  24. m=m/c;
  25. }
  26. for(int i=k;i>=1;i--)
  27. cout<<x[i];
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement