#define MAXLENGTH 20 #define ok 1 #define error 0 #include <stdio.h> struct squenceList{ int data[MAXLENGTH]; int length; }; int intsert(squenceList * list,int index,int element){ if(list->length >= MAXLENGTH){ //线性表已满 return error; } if(index < 0 || index >= list->length + 1){ //index不在列表(数组下标)范围内时 return error; } if(index <= list->length){//若插入的位置不在表尾 for(int i = list->length - 1;i >= index;i--){ list->data[i+1] = list->data[i]; } list->length++; } } void main(){ insert(); } http://blog.csdn.net/lincyang/article/details/8606682
原文地址:http://it0855.blog.51cto.com/895703/1626773