主函数如下:
#include "stdafx.h"
#define _CRTDBG_MAP_ALLOC
#include "linkStack.h"
#include "windows.h"
#include "iostream.h"
#include
#include
int main(int argc, char* argv[])
{LStack *LS;int m=2;
initialStack(LS);
pushStack(LS,m);
return 0;
}
linkStack.h文件如下:
#include
#include "stdio.h"
typedef int elementType;
#include "iostream.h"
typedef struct LNode
{
elementType data;
struct LNode *next;
} node, *linkStack;
typedef struct{
node *L;
node *top;
int max;
}LStack;
void initialStack(LStack *LS)
{int x;
cout>x;
LS=new LStack;
LS->L=new node;
LS->L->next=NULL;
LS->top=LS->L;
LS->max=x;
coutL->next;
while(p!=NULL)
{
len++;
p=p->next;
}
return len;
}
void pushStack(LStack *LS,elementType x)
{node *p;
if(stackLength(LS)==LS->max)coutdata=x;
p->next=NULL;
LS->top->next=p;
LS->top=p;cout#includeusing namespace std;int main(){int fun(int x,int y);//这里只是在Main函数里声明了有一个叫int fun(int,int)的函数,但并没有定义,里面的int x,inty可简写为int,int,而x,y并没有在Main函数里声明或定义。cin>>x>>y;//而这里想将输入值输入到x,y,这时还没定义或声明x,y,所以得到'x' ,'y': undeclared identifier的错误int x,y,z;//这里才真正声明定义了x,y.z=fabs(x-y);return(z
|