denis_andrei10

baza 10 to baza b cu vectori

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