数据结构中有试写一算法,实现顺序表的就地逆置 链表吗node*reverse(node*head){node*p1,*p2,*p3;if(head=NULL|head->;next=NULL)return head;p1=head;p2=p1->;next;while(p2){p3=p2->;next;p2->;next=p1;p1=p2;p2=p3;}head->;next=NULL;head=p1;return head;}
编写一个完整的程序,实现顺序表的建立、插入、删除、输出等基本运算. elem;int length;int listsize;} Sqlist;status Create_sq(Sqlist*L,int n){int i;L->;elem=(int*)malloc(100*sizeof(int));if。L->;elem)return 0;for(i=0;i;i+)scanf(\"%d\",&(L->;elem[i]));L->;length=n;L->;listsize=100;return 1;}status Listinsert_sq(Sqlist*L,int i,int e){int*q,*p,*newbase;if(i|i>;L->;length+1)return 0;if(L->;length>;=L->;listsize){newbase=(int*)realloc(L->;elem,(L->;listsize+10)*sizeof(int));if。newbase)exit(-2);L->;elem=newbase;L->;listsize+10;}q=(L->;elem[i-1]);for(p=(L->;elem[L->;length-1]);p>;=q;p)(p+1)=*p;q=e;L->;length;return 1;}int main(){Sqlist L1;int n,a;int i,e;printf(\"\\n please input the number of data:\\n\");scanf(\"%d\",&n);if(Create_sq(&L1,n)=1){scanf(\"%d%d\",&i,&e);a=Listinsert_sq(&L1,i,e);if(a=1)printf(\"insert success\\n\");else printf(\"insert false\\n\");printf(\"the list elements are:\\n\");for(i=1;i;i+){printf(\"%d\\t\",L1.elem[i-1]);}}return 0;}
实现顺序表的插入删除运算的完整程序#include<;stdio.h>;#include<;stdlib.h>;#define LIST_INIT_SIZE 100#define LISTINCREMENT 10typedef int status;typedef int ElemType;。