ZKX's LAB

数据结构的问题~ 利用顺序表的基本运算,实现删除顺序表l中多余的重复元素.

2021-04-08知识5

编写一个完整的程序,实现顺序表的建立、插入、删除、输出等基本运算. 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;}

(高分悬赏)谁可以帮我写一份C语言数据结构的课程设计?写完有加分 4,Search(BiTree t,ElemType x){ struct nodee;{BiTree pp;int tag;}s[100];int top;Bitree p;top=0;p=t;while(p。NULL&p->;p。NULL){while(p。NULL&p->;data。x){top+;s[top].pp=p;s[top].tag=0;p=p->;lchild;}if(p。NULL&p->;data=x){for(i=1;i;i+)printf(s[i].pp->;data);}elseif(top>;0&s[top].tag=1){top-;p=NULL;}elseif(top>;0){s[top].tag=1;p=s[top].pp;p=p->;rchild;}}}我就写一个吧zhidao,保证是对的,昨天刚考完数据结构,原题回,觉得太恶了,不想再敲程序答了

数据结构中有试写一算法,实现顺序表的就地逆置 链表吗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;}

#实现删除顺序表l中多余的重复元素.#利用顺序表的基本运算

随机阅读

qrcode
访问手机版