下载此文档

C语言 顺序栈实现十进制转换为二进制,八进制,十六进制.docx


文档分类:IT计算机 | 页数:约3页 举报非法文档有奖
1/3
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/3 下载此文档
文档列表 文档介绍
运行结果: 代码: #include <> #include <> #define MAX 20 typedef struct { int data[MAX]; int top; }SeqStack; SeqStack* Init() { SeqStack *s; s= (SeqStack *)malloc(sizeof(SeqStack)); s->top = -1; return s;} void Destroy(SeqStack *s) { free(s); } bool IsFull(SeqStack *s) { return (s->top == MAX - 1)? true : false; } bool IsEmpty(SeqStack *s) { return (s->top == -1) ? true : false; } void Push(SeqStack *s, int a) { if (IsFull(s)) { printf("The stack is full, failed to push!\n"); return; } s->top++; s->data[s->top] =a; } int Pop(SeqStack *s) { int e; if (IsEmpty(s)) { printf("The stack is empty, failed to pop!\n"); return NULL; }e= s->data[s->top]; s->top--; return e; } int ReadTop(SeqStack *s) { return s->data[s->top]; } void Print(SeqStack *s) { int temp = s->top; if (IsEmpty(s)) { printf("The stack is empty!\n"); return; } printf(" 转换后的结果:\n"); while (temp >= 0) { if (s->data[temp]<10) printf("%d ", s->data[temp]); else { if (s->data[temp] = 10)printf("a"); else if (s->data[temp] = 11)printf("b"); else if (s->data[temp] = 12)printf("c"); else if (s->data[temp] = 13)printf("d"); else if (s->data[temp] = 14)printf("e"); else printf("f"); } temp--; } printf("\n

C语言 顺序栈实现十进制转换为二进制,八进制,十六进制 来自淘豆网m.daumloan.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数3
  • 收藏数0 收藏
  • 顶次数0
  • 上传人gyzhluyin
  • 文件大小0 KB
  • 时间2016-07-08