Time:09-16
CodePudding user response:
bother to write from beginning to end
Quote: refer to 1st floor 00:15 am response: Bother to write from beginning to end Could you tell me the original poster is singly linked lists to create your own? Or you can use c + + standard library of?
Bother to write from beginning to end
#include#include using namespace std; Int main () {Int * p=new int [50]. int n; While (cin> N) {* p=n; + + p; } P -=50; Int * m=new int [50]. Int q; While (cin> Q) {* m=q; + + m; } Q -=50; Forward_list & lt; Int> * first=new forward_list & lt; Int>; Forward_list & lt; Int> * second=new forward_list & lt; Int>; for(int i=1; I<=50; + + + + p, q) {First - & gt; Insert_after (first - & gt; Before_begin (), * p); Second - & gt; Insert_after (second - & gt; Before_begin (), * q); } Sort (first - & gt; Before_begin () + 1, first - & gt; The end ()); Sort (second - & gt; Before_begin () + 1, the second - & gt; The end ()); Forward_list & lt; Int> * new_one=new forward_list & lt; Int> (* first); for(int i=0; I<=second - & gt; The size (), + + I) {Auto point=second - & gt; Before_begin () + 1 + I; For (int p=0; p<=new_one - & gt; The size (), + + p) {Auto pointer=first - & gt; Before_begin () + 1; If pointer==(* * point) {New_one - & gt; Insert_after (pointer, * point); break; } If (pointer==first - & gt; The end ()) New_one - & gt; Insert_after (pointer, * point); } } For (const auto& A: * new_one) CoutThe delete [] p; The delete [] q; Delete the first; Delete the second; The delete new_one; return 0; } Rewrite the following (written and in multiple function) line
Page link:https//www.codepudding.com/Backend/1435.html