lzl3143688973 2015-10-15 08:32 采纳率: 50%
浏览 1596

数据结构 运行不了,求找出错误

#include "stdafx.h"
#define Maxsize 100

include

typedef int datatype;
typedef struct
{
int stack[Maxsize];
int top;
}SeqStack;
SeqStack*InitStack()
{
SeqStack * S;
S=(SeqStack *)(sizeof(SeqStack));
if(!S)
{
printf("空间不足");
return NULL;
}
else {
S->top=0;
return S;
}
}
SeqStack *push (SeqStack *S,int x)
{
if (S->top ==Maxsize)
{
printf("the stack is overflow!\n");
return NULL;
}
else
{
S->stack[S->top]=x;
S->top++;
return S;
}
}
int StackEmpty(SeqStack *S)
{
if (S->top==0)
return 1;
else
return 0;
}
int pop(SeqStack *S)
{
int y;
if (S->top==0)
{
printf("the stack is empty!\n");return 0;
}
else {
S->top--;
y=S->stack[S->top];
return y;
}
}
void conversion(int N,int r)
{
int x=N,y=r;
SeqStack *s;
s=InitStack();
while(N!=0)
{
push(s,N%r);
N=N/r;
}
printf("\n十进制数 %d所对应的 %d进制数是:" "x,y");
while(!StackEmpty(s))
printf("%d",pop(s));
printf("\n");
}

int main();
{
int n;
int r;
printf(" 请输入任意一个十进制整数及其所需转换的二至九间的任一进制数 :\n");
scanf("%d%d",&n,&r);
conversion(n,r);
}

  • 写回答

1条回答 默认 最新

  • threenewbee 2015-10-15 08:50
    关注
    评论

报告相同问题?

悬赏问题

  • ¥20 Html备忘录页面制作
  • ¥15 黄永刚的晶体塑性子程序中输入的材料参数里的晶体取向参数是什么形式的?
  • ¥20 数学建模来解决我这个问题
  • ¥15 计算机网络ip分片偏移量计算头部是-20还是-40呀
  • ¥15 stc15f2k60s2单片机关于流水灯,时钟,定时器,矩阵键盘等方面的综合问题
  • ¥15 YOLOv8已有一个初步的检测模型,想利用这个模型对新的图片进行自动标注,生成labellmg可以识别的数据,再手动修改。如何操作?
  • ¥30 NIRfast软件使用指导
  • ¥20 matlab仿真问题,求功率谱密度
  • ¥15 求micropython modbus-RTU 从机的代码或库?
  • ¥15 django5安装失败