首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

用栈实现进制转换,该如何处理

2012-02-08 
用栈实现进制转换怎么有点错误帮忙改一下改成可以运行的#include stdio.h#include malloc.h#include

用栈实现进制转换
怎么有点错误   帮忙改一下   改成可以运行的
#include <stdio.h>
#include <malloc.h>
#include <conio.h>
typedef   int   SElemType;
Status   visit(SElemType   *   e)
{
  printf( "   %d     ",   *e);
}

void   conversion()
{
  pSqStack   S;
  SElemType   e;

  int   n;
  InitStack(&S);
  printf( "Input   a   number   to   convert   to   OCT:\n ");
  scanf( "%d ",&n);

  if(n <0)
      {
          printf( "\nThe   number   must   be   over   0. ");
          return;
      }
  if(!n)   Push(S,0);

  while(n){
      Push(S,n%8);
      n=n/8;
  }

  printf( "the   result   is:                 ");
  while(!StackEmpty(*S)){
      Pop(S,&e);
      printf( "%d ",e);
  }
}

main()
{
    printf( "\n\n\n\n ");
    conversion();
    getch();
    printf( "\n\nWelcome   to   visit   http://zmofun.yeah.net   ! ");
}

[解决办法]
这样补程序也太……
那函数至少实现什么功能得告诉大家吧!

热点排行