主题:不看此题非好汉!
为吗通不过?兄弟姐妹们帮帮忙吧!多谢!
#include <iostream.h>
#include <malloc.h>//#define Maxsize 18;//#define Icreat 4;//typedef k int ;//k yu int bie fang fan le
typedef struct//pin xie;
{
int *base,*top,length;
}stack;
void initStack(stack &L);
void display(stack L);
void inputstack(stack &L,int A[],int n);
void main()
{
stack L;
int A[5];
cout<<"Please input the data:"<<endl;
for(register j=0;j<5;j++)
{
cin>>A[j];
}
initStack(L);
inputstack(L,A,5);
display( L);
}
void initStack(stack &L)
{
L.base=(int*)malloc(14*sizeof(int));//
if(!L.base) cout<<"erro"<<endl;//
else
L.base=L.top;
L.length=18;
cout<<"The new emputy stack has been builded."<<endl;
}
void inputstack(stack &L,int A[],int n)
{
if(n>L.length)
{
L.base=(int*)calloc(22,sizeof(int));//
}
if(!L.base) cout<<"Fail"<<endl;
else
{
int* p=L.base;
for(register m=0;m<n;m++)
{
*p++=A[m];
}
}
cout<<"The empty has been inputed datas."<<endl;
}
void display(stack L)
{
cout<<"The stack is:"<<endl;
while(L.base!=L.top)
{
cout<<*L.base++<<' ';
}
}
#include <iostream.h>
#include <malloc.h>//#define Maxsize 18;//#define Icreat 4;//typedef k int ;//k yu int bie fang fan le
typedef struct//pin xie;
{
int *base,*top,length;
}stack;
void initStack(stack &L);
void display(stack L);
void inputstack(stack &L,int A[],int n);
void main()
{
stack L;
int A[5];
cout<<"Please input the data:"<<endl;
for(register j=0;j<5;j++)
{
cin>>A[j];
}
initStack(L);
inputstack(L,A,5);
display( L);
}
void initStack(stack &L)
{
L.base=(int*)malloc(14*sizeof(int));//
if(!L.base) cout<<"erro"<<endl;//
else
L.base=L.top;
L.length=18;
cout<<"The new emputy stack has been builded."<<endl;
}
void inputstack(stack &L,int A[],int n)
{
if(n>L.length)
{
L.base=(int*)calloc(22,sizeof(int));//
}
if(!L.base) cout<<"Fail"<<endl;
else
{
int* p=L.base;
for(register m=0;m<n;m++)
{
*p++=A[m];
}
}
cout<<"The empty has been inputed datas."<<endl;
}
void display(stack L)
{
cout<<"The stack is:"<<endl;
while(L.base!=L.top)
{
cout<<*L.base++<<' ';
}
}