#include<stdio.h>
#include<string.h>
#include<stdlib.h>
typedef int DataType;
#define MAXSIZE 100
typedef struct 
{
    DataType data[MAXSIZE];
    int top;        
}seqstack;//顺序栈
int main()
{
     int N,r;
     DataType x;
     scanf("%d%d",&N,&r);
     seqstack *s;
     s=(seqstack *)malloc(sizeof(seqstack));
     s->top=-1;
     while(N)
     {
         if(s->top!=MAXSIZE-1)
         {
              s->top++;
              s->data[s->top]=N%r;//入栈
              N=N/r;
         }
     }
     while(s->top!=-1)
     {
          x=s->data[s->top];
          printf(" %d",x);
          s->top--;//出栈
     }
     printf("\n");
     system("pause");
     return 0;
}
posted on 2011-05-10 16:52  枫叶飘泪  阅读(426)  评论(0编辑  收藏  举报