大神帮忙看看这个关于栈的程序的问题~~

#include"stdio.h"#include"malloc.h"#defineMAXSIZE100structStack{int*p;int*bottom;int*... #include "stdio.h"
#include "malloc.h"
#define MAXSIZE 100
struct Stack
{ int *p;
int *bottom;
int *top;
void StackInit();
int Pop();
void Push(int x);
};
void test1(int &sum);
void test(int &sum);
void main()
{

}
void test(int &sum)
{
int x;
scanf("%d",&x);
if (0==x)
{
sum=0;
}
else
{
test(sum);
sum+=x;
}
printf("%d\n",sum);
}

void test1(int &sum)
{

}

void struct Stack::StackInit()
{
p=(int*)malloc(MAXSIZE*sizeof(int));
bottom=p;
top=p;
}

void struct Stack::Push(int x)
{
*top=x;
top++;
}

int struct Stack::Pop()
{
int x=*top;
top--;
return x;
}

编译之后出现错误:
D:\我的程序\数据结构\链表.cpp(72) : fatal error C1004: unexpected end of file found

求指教!
展开
 我来答
濮方雅BX
2012-11-25 · TA获得超过4042个赞
知道大有可为答主
回答量:2482
采纳率:60%
帮助的人:2533万
展开全部
把这几个“struct”去掉试试
void struct Stack::Push(int x)
int struct Stack::Pop()
void struct Stack::StackInit()
猫猫一号脑
2012-11-25 · TA获得超过2739个赞
知道大有可为答主
回答量:1268
采纳率:50%
帮助的人:527万
展开全部
C++中使用结构体时不用再加struct关键字了,只有定义的时候需要加struct
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
asdnzhang623
2012-11-25
知道答主
回答量:7
采纳率:0%
帮助的人:1.1万
展开全部
#include "stdio.h"
#include "malloc.h"
#define MAXSIZE 100
struct Stack{
int *p;
int *bottom;
int *top;
void StackInit();
int Pop();
void Push(int x);
};
void test1(int &sum);

void test(int &sum);
void main(){
}void test(int &sum)
{
int x;
scanf("%d",&x);
if (0==x)
{
sum=0;
}
else
{
test(sum);
sum+=x;
}
printf("%d\n",sum);
}
void test1(int &sum)
{

}
void Stack::StackInit()
{ p=(int*)malloc(MAXSIZE*sizeof(int));
bottom=p;
top=p;
}
void Stack::Push(int x)
{
*top=x;

top++;
}
int Stack::Pop()
{
int x=*top;

top--;
return x;
}

现在编译没有问题 了
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式