SDUT 2131 数据结构实验之栈一:进制转换

 1 #include<stdio.h>
2 int main()
3 {
4 int n,m,i,r,top = 0;
5 char stack[100];
6 scanf("%d%d", &n,&m);
7 while(n)
8 {
9 top++;
10 stack[top] = n%m;
11 n = n/m;
12 }
13 while(top!=0)
14 {
15 printf("%d", stack[top]);
16 top--;
17 }
18 printf("\n");
19 return 0 ;
20 }

 

posted @ 2012-02-11 19:07  _雨  阅读(242)  评论(0编辑  收藏  举报