#include <iostream>
using namespace std;
#define Maxsize 100
typedef int ElemType;
typedef struct
{
ElemType data;//数字域
int next;//游标域
}StaticList[Maxsize];
void CreateList(StaticList L, ElemType a[], int n)
{
L[0].next=1;
for(int i=1;i<=n;i++)
{
L[i].data=a[i-1];
L[i].next=i+1;
}
L[n].next=0;
}
void Display(StaticList L) //此处是L,而不同于单链表的创建时用的*L(L为链表头结点指针),此处类似于数组标记直接用L(???)
{
int i=0;
while(L[i].next!=0)
{
i=L[i].next;//将游标域值传递给i,直到next为0结束
cout<<i<<":"<<L[i].data<<","<<L[i].next<<endl;
}
}
int main()
{
StaticList L;
ElemType a[10]={1,2,3,4,5,6,7,8,9,10};
int n=sizeof(a)/sizeof(ElemType);
CreateList(L,a,n);
Display(L);
system("pause");
return 0;
}