怎么構(gòu)造一個(gè)空的線性表?
#include<stdio.h>
#define MAXSIZE 100
struct List
{
int L[MAXSIZE];
int top;
};
int Init()//top指針初始化為0
{
int top;
top=0;
return top;
}
void Input(struct List *t,int p,int n)//輸入n個(gè)數(shù)據(jù)
{
if(n==0||n>=MAXSIZE)printf("空隊(duì)列\(zhòng)n");
else
for(p=0;p<n;p++)
scanf("%d",&t->L[p]);
}
void Output(struct List *s,int i,int m)//輸出m(=n)個(gè)數(shù)據(jù)哈
{
if(m==0||m>=MAXSIZE)printf("無(wú)法輸出\n");
else
for(i=0;i<m;i++)
printf("%d ",s->L[i]);
}
void main()
{
struct List r;
int n,m;
scanf("%d",&n);
m=Init();
Input(&r,m,n);
Output(&r,0,n);
}