:: ~LinkList() p=p->next ; {} Node *q; cout< *p; } p=first; void main() while(p) {{ int " /> :: ~LinkList() p=p->next ; {} Node *q; cout< *p; } p=first; void main() while(p) {{ int " />

全文预览

数据结构各章复习题

上传者:叶子黄了 |  格式:docx  |  页数:67 |  大小:0KB

文档介绍
next=s; p=first->next; } while(p != NULL) }{ template<class T> cout<<p->data<<" "; LinkList<T> :: ~LinkList() p=p->next ; {} Node<T> *q; cout<<endl; Node<T> *p; } p=first; void main() while(p) {{ int n; A.PrintList(); cout<<" 请输入单链表需要输入的数据元素的 cout<<" 颠倒之后的数据元素依次为: "<<" ";个数:"; cin>>n; LinkList<int> A(n);} cout<<"A 的数据元素为:"; 4 .请写一个算法将顺序存储结构的线性表( a 1 ...a n )逆置为(a n ...a 1) ,要求使用最少的附加空间。 Status ListReplace_Sq(SqList &L,int n) { If(n<1||n>L.length+1) return ERROR; if(L.length>=L.listsize) { Newbase=(ElemType *)realloc(L.elem,(L.listsize+LISTINCREMENT)*sizeof(ElemType)); If(!newbase) exit(OVERFLOW); L.elem=newbase; L.listsize+=LISTINCREMENT; } for(i=0;i<n;i++) { 计算机学院甘士成 Copyright ? 1992 - 2012 Gane Cheng . All Rights Reserved . 10 / 21 temp=a[n-i-1]; a[n-i- 1]=a[i]; a[i]=temp; } return OK; }

收藏

分享

举报
下载此文档