#include <iostream>
using namespace std ;
#define MAXSIZE 1000
#define OK true #define ERROR falsetypedef int ElemType ;
typedef bool Status ;typedef struct
{ ElemType data ; int cur ;}Component,StaticLinkList[MAXSIZE];Status InitStaticLinkList(StaticLinkList space)
{ for(int i = 0 ; i < MAXSIZE-1;i++) space[i].cur = i+1 ; space[MAXSIZE-1].cur = 0 ; return OK ;}int Malloc_SLL(StaticLinkList space )
{ int i = space[0].cur ; if(space[0].cur) space[0].cur = space[i].cur; return i ;}int ListLength(StaticLinkList space )
{ int len = 0 ; int i = space[MAXSIZE-1].cur; while(i) { len++ ; i = space[i].cur ; } return len ;}Status ListInsert(StaticLinkList space , int i , ElemType e ){ if( i < 1 || i > ListLength(space)+1) return ERROR ; int j = Malloc_SLL(space); if(j) { space[j].data = e ; int k = MAXSIZE-1 ;//k是最后一个元素的下标 for(int l = 1 ; l <= i -1 ;l ++ ) k = space[k].cur; space[j].cur = space[k].cur; space[k].cur = j ; return OK ; } return ERROR ;}void Free_SLL(StaticLinkList space , int k ){ space[k].cur = space[0].cur ; space[0].cur = k ;}Status ListDelete(StaticLinkList space , int i ){ if( i < 1 || i > ListLength(space)) return ERROR ; int k = MAXSIZE -1 ; int j = 0 ; for( ; j <= i-1 ; j ++) k = space[k].cur ; j = space[k].cur ; space[k].cur = space[j].cur ; Free_SLL(space , j); return OK;}