List of Top 5 issues

Source: Internet
Author: User

  #include <iostream> #include <assert.h> #include <string>using namespace std; Struct node{int x;node *next;node (int a) {x=a;}}; Class link{public :node *head;link (int *a) {  int n=5;head=new node (a[0 ]); Node *p=head;while (--n)  {  node *add=new node (A[n]);   p->next= Add;  p=p->next; }}void comfive (link & l) { int n=10; int  state=1; int t; int state2=1; node *p=head; node *lp=l.head; while (P->next)  {      p=p->next;  }while (LP) {Node *add =new node (lp->x); lp=lp->next;p->next=add;p=p->next;}  p->next=l.head; p=head;node *q=p->next;while (n--&&state)  {p=head;q=p-> Next;  while (q)   {   if (p->x < q->x) { t=p->x;p->x=q->x; q->x=t;state=0;}    p=p->next;   q=q->next;  } if (state==1) break;    state=1; }n=1;p=head;q=p->next;/*****************/while (N&LT;5&AMP;&AMP;STATE2) {    q=p->next; if (p->x==q->x);  else n++; p=p->next;   / /cout<< "No five" <<endl;break;}  //to dealt with two kinds stutation ,same and not same  if (q->next->x==q->x) q->next->next=null;else q->next=null;/*****************/  }  ~link () {   delete head;} Void print () { node *p=head;   while (P) {cout<<p->x<< " ";p =p- >next;} cout<<endl;}};/ The original   all the code   in the eyes are can be broken    of course, different industries    are not cutting a look at the    on the same as the forecast    not very good    has not been fully implemented   For example   there is a processing thought that has no previous   fiveThe road is in the process of judging the list of different numbers there are several   such as M to control the loop   and print out the former m name is not n name **************************/int main () {int a1[5]={ 1,2,3,4,5};int a2[5]={7,7,7,9,10};int a3[5]={1,2,3,4,5};int a4[5]={7,7,7,9,10};int a5[5]={ 6,7,8,9,10};CLASS&NBSP;LINK&NBSP;L1 (A1); class link l2 (A2); CLASS&NBSP;LINK&NBSP;L3 (A3);class  Link l4 (A4); Class link l5 (A5);/*l1.print (); L2.print (); L3.print (); L4.print (); L5.print ();*/   l1.comfive (L2);// l1.print ();// l2.print ();   l1.comfive (L3);// l1.print ();//  l3.print ();  l1.comfive (L4);// l1.print ();// l5.print ();    l1.comfive (L5); L1.print ();//l5.print (); return 0;} /*********************head= (  (head->x)  >  ((l.head)->x)? head:l.head; node * Cur=head; node *p=head->next; node *q=l.head;if (head->x==l.head->x)   {  head->next=l.head;cur=l.head;q=l.head->next;n--;}  9 7 5 3 8 6 4 2 while (--n)   {    if (p->x == q- >x) { //n++;bug//cur->next=p;cur=cur->next; cur->next=q;cur=cur->next;  }     else   {    if (p->x > q->x)  { cur->next=p; p=p->next;}     else            {  Cur->next=p; q=q->next;}    }//    cout<<n;//3  }}************************/

List of Top 5 issues

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.