//初始化
Status InitList(Sqlist& L){
L.elem =(Elemtype*)malloc(sizeof(Elemtype)*MAXSIZE);if(!L.elem)return(overflow);
L.listsize = MAXSIZE;return OK;}
//创建顺序表
Status CreateList(Sqlist &L){if(!L.elem)return ERROR;printf("Please Create the SQlist\nplease input the number ");printf("末尾以0结束");int i=0;system("cls");scanf_s("%d",&L.elem[i]);system("cls");while(L.elem[i]!=0){
L.length++;++i;scanf_s("%d",&L.elem[i]);system("cls");}printf("\a the SQlist has been initialized successfully!\n");return OK;}
intmain(){printf("welcome to the Sqlist system\n");printf("let's create a SQlist now\nplease print 1");int para;scanf_s("%d",¶);int stat;if(para ==1){
Sqlist L;
stat =InitList(L);if(stat ==1){system("cls");printf("the SQlist has been initialized successfully!\n");printf("**********************************************************************************\n");}elseexit(0);printf("现在开始赋值,以0为结束");
stat =CreateList(L);int* p;if(stat ==1){printf("创建完毕");
p = L.elem;for(; p < L.elem + L.length; p++){printf("%d\t",*p);}}elseexit(0);int loc, val;char m;//人机交互*****************************************while(1){printf("\n插入请按A,删除值请按B,查找请安C");//system("cls");
cin >> m;switch(m){case'A':printf("开始插入,请输入插入值和位置");scanf_s("%d,%d",&val,&loc);
stat =InsertList(L, loc, val);break;case'B':printf("开始删除,请输入删除位置");scanf_s("%d",&loc);
stat =DeleteList(L, loc);break;case'C':printf("当前数组值如下");
p = L.elem;for(; p < L.elem + L.length; p++){printf("%d\t",*p);}break;default:exit(0);}}}}