SHARE
TWEET

Untitled

a guest Feb 19th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #define dim 1001
  4.  
  5. using namespace std;
  6. ifstream fin("conversie_b_10.in");
  7. ofstream fout("conversie_b_10.out");
  8.  
  9. struct Stiva{
  10. int st[dim];
  11. int top;
  12. int Empty(){
  13. return top==-1;
  14. }
  15. int Full(){
  16. return top == dim - 1;
  17. }
  18. void Init(){
  19. top=-1;
  20. }
  21. void Push10(int x, int p){
  22. if(!Full())
  23. st[++top] =x*p;
  24. }
  25. void Pushc(int x,int c){
  26. if(!Full())
  27.   st[++top] =x%c;
  28. }
  29. void Pop(){
  30. if(!Empty())
  31.     top--;
  32. }
  33.  
  34. int Front(){
  35. return st[top];
  36. }
  37. };
  38.  
  39. int n,p, suma=0,b,c;
  40. int main(){
  41. Stiva s;
  42. cin >> n;
  43. cin >> b;
  44. cin >> c;
  45.  
  46. s.Init();p=1;
  47. while(n >0){
  48. s.Push10(n % 10,p);
  49. p=p*b;
  50. n/=10;
  51. }
  52.  
  53. while (!s.Empty()){
  54. suma+=s.Front();
  55. s.Pop();
  56. }  cout << suma;
  57. while(suma)
  58. {
  59.     s.Pushc(suma,c);
  60.     suma/=c;
  61. }
  62. while(!s.Empty()){
  63.     cout<<s.Front();
  64.     s.Pop();
  65. }
  66. return 0;
  67. }
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