栈问题?
#include<iostream>
using namespace std;
const int MAXSIZE=100;
typedef struct
{
int data[MAXSIZE];
int top;
}SqStack;
void Initstack(SqStack &sq)
{
sq.top=-1;
}
void Changerstack(int m, int n, SqStack &sq)
{
int c=0;
while(m)
{
c=m%n;
sq.top++;
sq.data[sq.top]=c;
m=m/n;
if(m<n)
{
sq.top++;
sq.data[sq.top]=m;
}
}
}
int Getnumber(SqStack sq)
{
int x=sq.top;
return x;
}
void Pop(SqStack &sq, int &y)
{
y=sq.data[sq.top];
sq.top--;
}
int main(void)
{
SqStack sqs;
Initstack(sqs);
int i,j,l,sa;
cout<<"please input two number"<<endl;
cin>>i>>j;
Changerstack(i,j,sqs);
const int k=32;
int aa[k]={0};
sa=Getnumber(sqs);
for(l=sa; l>=0; l--)
{
Pop(sqs,aa[l]);
}
for(int bb=sa; bb>=0; bb--)
{
cout<<aa[bb]<<" ";
}
cout<<endl;
return 0;
}这个程序怎么输不出正确结果啊!望高人指点。