⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 convert.c

📁 数据结构 c语言 教程
💻 C
字号:
#include<stdio.h>
#include<malloc.h>
#include<conio.h>

typedef int SElemType;

#include "stack.h"

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 !");
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -