下列算法实现在顺序表 L 的第 i ( 1 ≤ i ≤ L->length+1 )个结点的位置上插入值为 t 的元素,其中 listsize成员 为顺序表 L 的容量,表中第 1 个结点的数据存放在数组元素 L->elem[0] 中。下列选项中能完成此功能的语句序列为( )。 void InsertList(SeqList *L ,int i ,ElemType e) {// 将 e 插入顺序表 L 的第 i 个结点的位置上 int j; if (i<1||i>L->length+1) {printf(" 插入位置错 ");return(ERROR);} if (L->length>=L->listsize) {printf(" 表满不能插入 ");exit( OVERFLOW );} else { for(j=L->length-1;j>=i-1;j--) 1 // 结点依次后移 2 // 插入 t 3 // 表长加 1 } }
A.
①L->elem[j-1]=L->elem[j]; ②L->elem[i]=e; ③L->length+1;
B.
①L->elem[j-1]=L->elem[j]; ②L->elem[i-1]=e; ③L->length++;
C.
①L->elem[j+1]=L->elem[j]; ②L->elem[i-1]=e; ③L->length++;
D.
①L->elem[j+1]=L->elem[j];②L->elem[i]=e; ③L->length+1;