Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #define dim 1001
- using namespace std;
- ifstream fin("conversie_b_10.in");
- ofstream fout("conversie_b_10.out");
- struct Stiva{
- int st[dim];
- int top;
- int Empty(){
- return top==-1;
- }
- int Full(){
- return top == dim - 1;
- }
- void Init(){
- top=-1;
- }
- void Push10(int x, int p){
- if(!Full())
- st[++top] =x*p;
- }
- void Pushc(int x,int c){
- if(!Full())
- st[++top] =x%c;
- }
- void Pop(){
- if(!Empty())
- top--;
- }
- int Front(){
- return st[top];
- }
- };
- int n,p, suma=0,b,c;
- int main(){
- Stiva s;
- cin >> n;
- cin >> b;
- cin >> c;
- s.Init();p=1;
- while(n >0){
- s.Push10(n % 10,p);
- p=p*b;
- n/=10;
- }
- while (!s.Empty()){
- suma+=s.Front();
- s.Pop();
- } cout << suma;
- while(suma)
- {
- s.Pushc(suma,c);
- suma/=c;
- }
- while(!s.Empty()){
- cout<<s.Front();
- s.Pop();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement