- 4
- 0
- 约 61页
- 2016-12-15 发布于河南
- 举报
c语言 数据结构代码(第一章)
//十进制数转换成八进制数convert.cpp
#includeiostream.h
#includeiomanip.h
#includemalloc.h
#includeconio.h
#includestdlib.h
#includestdio.h
typedef int Status;
typedef int SElemType;
#include stack.cpp
void conversion()
{SqStack *S;
SElemType e;
int n;
S-InitStack(S);
printf(输入十进制数:);cinn;
if(n0)
{ printf(\n数必须大于零!\n);
return;}
if(!n) S-Push(0);
while(n){
S-Push(n%8);n=n/8;}
printf(结果是:);
while(!S-StackEmpty()){
S-Pop(e);
printf(%d,e);}
}
void main()
{ printf(convert.cpp运行结果:\n);
conversion();
getch();}
convert.cpp运行结果:
输入十进制数:127
结果是:177
--------------------
原创力文档

文档评论(0)