|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 未来大神! 于 2021-10-13 22:44 编辑
- #include<stdio.h>
- #include<math.h>
- #define MaxSize 100
- typedef struct
- {
- ElemType data[MaxSize];
- int top;
- } SqStack;
- void InitStack(SqStack &st)
- {
- st.top=-1;
- }
- void DestoryStack(SqStck st)
- {}
- int Push(SqStack &st,ElemType x)
- {
- if (st.top==MaxSize-1)
- return 0;
- else
- {
- st.top++;
- st.data[st.top]=x;
- return 1;
- }
- }
- int GetTop(SqStack st,ElemType &x)
- {
- if(st.top==-1)
- return 0;
- else
- {
- x=st.data[st.top];
- return 1;
- }
- }
- int StackEmpty(SqStack st)
- {
- if(st.top==-1)
- return 1;
- else
- return 0;
- }
- void main()
- {
- SqStack st;//定义一个顺序栈
- ElemType e;
- InitStack(st);
- GetTop(st,e);
- printf("请输入整数:n\n");
- scanf("%d",&n);
- int n,a,sum=0,i=0;
- while(n)
- {
- a=n%8;
- n=n/8;
- sum+=a*pow(10,i);
- i++;
- }
- printf("八进制输出为:%d\n",sum);
- }
复制代码
有好多错误,第一个是ElemType data[MaxSize];编译器显示ElemType不能定义类型,为什么?该怎样修改?
还有其他好多错误,还请大神帮忙修改。谢谢了!!!
|
|