范文无忧网公文文书入党入团

输入二组每组10个元素无序的整数用归并排序的思想将它们从小

01月20日 编辑 fanwen51.com

#include class node {public: long a; node *next; }; main() {node *head,*p,*s; s=new node; cin>>s->a; head=NULL; while (s->a) {if (head==NULL) head=s; else p->next=s; p=s; s=new node; cin>>s->a; } p->next=NULL; p=head; delete s; node *q,*h,*j,*r,*i; h=new node;s=new node; s->next = p; while (s->next!=NULL) { j = s; q = s->next; while (q->next!=NULL) { if (q->next->anext->a) { j = q; } q = q->next; } if (j != s) { i= j->next; j->next = i->next; i->next = s->next; s->next = i; } s = s->next; } p = h->next; p=head; while (p) {coutnext; } delete s,h; }

推荐阅读
图文推荐
栏目列表