数据结构所有代码C++实现

时间:2014-01-10 12:33:54
【文件属性】:

文件名称:数据结构所有代码C++实现

文件大小:164KB

文件格式:DOC

更新时间:2014-01-10 12:33:54

C C++ C/C++ 数据结构 算法

精心整理 一:线性表 1.单链表应用 例子一:尾插入创立单链表,并且删除相同元素,即表示一个集合 #include using namespace std; struct node { int num; struct node *next; }; node *head; void creat_list() { int N,i; cin>>N; node*temp,*tail; head=new node; tail=head; tail->next=NULL; for(i=0;i<=N-1;i++) { temp=new node; if(temp==NULL) { cout<<"memory allocate fail and exit"; exit(1); } cin>>temp->num; tail->next=temp; tail=temp; tail->next=NULL; } } void out_put_list() { node* a=head->next; while(a!=NULL) { cout<num<<" "; a=a->next; } cout<next; while(p) { q=p; while(q->next) { if((q->next)->num==p->num) { r=q->next; q->next=r->next; free(r); } else q=q->next; } p=p->next; } } int main(void) { creat_list(); out_put_list(); delete_list(); out_put_list(); return 0; }


网友评论

  • 很全面合理,谢谢
  • 有很多是C语言 分数太贵了T^T
  • 谢谢,整理的很全面,很好的资源
  • 很好的资源啊
  • c语言吧这是