Rewrite requirement 1: Rewrite the above program to fit an extra-long integer
Rewrite requirement 2: Rewrite the above program to fit the extra-long sequence
Rewrite requirement 3: N nodes starting at the specified position m in the sequence are re-sorted in descending order
Overwrite requirement 4: Output an extra-long integer of n nodes starting at the specified position m
#include <cstdlib>#include<iostream>#include<string>using namespacestd;structlongintegernode{ Short intdata; Longintegernode*next;};structlinknode{Longintegernode*Plongintegernode; Linknode*next;};classlist{ Public: structlongintegernode* creat (stringstr); structlinknode* Add (linknode* head,longintegernode*phead); structlinknode* Sortpart (linknode* Head,intMintN); voidOutput (linknode*Head) {Linknode*p; P=head->Next; Longintegernode*Q; while(p) {Q=p->plongintegernode->Next; while(q) {cout<<q->data; Q=q->Next; } cout<<Endl; P=p->Next; } } voidShow (linknode* Head,intN) {Linknode*p; P=Head; Longintegernode*Q; while(n) {q=p->plongintegernode->Next; while(q) {cout<<q->data; Q=q->Next; } cout<<Endl; P=p->Next; N--; } } }; Linknode* List::add (linknode* node,longintegernode*phead) {Linknode* newlinknode=NewLinknode; Newlinknode->next=NULL; Newlinknode->plongintegernode=Phead; Node->next=Newlinknode; Node=Newlinknode; returnnode;} Longintegernode* List::creat (stringstr) { stringS=STR.SUBSTR (0,1); intI=1; Longintegernode* phead=NewLongintegernode; Phead->next=NULL; Longintegernode*p; P=Phead; while(S.length ()) {Longintegernode* newlongintegernode=NewLongintegernode; Newlongintegernode->next=NULL; Newlongintegernode->data=atoi (S.c_str ()); P->next=Newlongintegernode; P=Newlongintegernode; if(S.length () <1) returnPhead; S=str.substr (I,1); I=i+1; } returnPhead;} Linknode* List::sortpart (linknode* Head,intMintN) { intx=m; inty=N; inttemp; Linknode* p=head->Next; Linknode*Q; Longintegernode* t,*s; while(x) {p=p->Next; X--; } q=p; while(y) { for(t=p->plongintegernode;t!=null;t=t->next) { for(s=t->next;s!=null;s=s->next) { if(t->data<s->data) {Temp=t->data; T->data=s->data; S->data=temp; } }} p=p->Next; Y--; } returnq;}intMainintargcChar*argv[]) {List List; Linknode* head=NewLinknode; Head->next=NULL; Linknode*sort; Linknode*tail; Tail=Head; stringstr; CIN>>str; while(str!="Exit") {Longintegernode*Phead; Phead=list.creat (str); Tail=List.add (Tail,phead); CIN>>str; } Sort=list.sortpart (Head,1,2); List.output (Head); cout<<"outputs the specified sort sequence"<<Endl; List.show (Sort,2); System ("PAUSE"); returnexit_success;}
C + + Programming Practice Guide 1.6 The Order of n number in the super-long series is implemented by rewriting