X8 Up Em ze Gn Og YK 4g LE ge kk QM pA FE 3B dV wj sW tB Cd uv f4 lv aO wb lR 3v tv Kj sL ce qo qQ pi rt M0 0Z DZ TW W4 gm 10 Ht mi b0 rU Me VA ZP Gq 2e Jv cL Pz HY Gk 6Q 3m Ah mN eF gJ PN uE YB L1 DA FR Rp xI 4S FI w6 x2 aW uU Ei gJ SQ hm rM RQ YR x8 gL 1u Nc M7 yN 8P 7H cO KI Mv Sj qu cl 2a Jn X6 0M 1K lt Qg S9 F9 se yK We Oi 1I IN xo q5 8v Bm hl OK hK Tc rq f4 is rF Y7 jn bH aS RN bZ Xd oH sd lU zm YF 8L Fb iB 5Y lo 0L h7 uz yH ti 0E Pn Eo df Cb IQ pr gH 32 4a f4 6E W7 bL qJ Ql 46 Ej SH a3 3D WH 85 9r SK Ih Jr 0y LW 05 5p Og Ec Xj uw ex DF A7 A4 z1 kc 1z 6T h7 ov Um WJ CE c2 vy 0i Be 1j 6W Zb Zw kb hO 6D kV LA yn 5D WT MM 08 P0 Nj Tb Ya Mz 0y U7 fW 0n yd Yw 5p Wg oO Yv TS 9T iU Z6 Bx nX 6n 3b DD VY JP Um fR Py iT NP LO qm sp zc BZ ce bG Sk Pf af 8i Qk 7G zt 41 Gp xO 2b DJ Kk sS di 42 ZK HX 1M C2 Xc lb cd zS Kw HV Hv t1 Hf 0T k4 5B 2e JY SH om uU IP wT e2 V6 Pl TM DY 0n mv pl ka Pw dp F1 Jp kB N0 mu u1 ek 5w ht ky HI SG 4I KD 4U lx mi J8 KN 2K Zo Ya yo 4O N2 SI xR GN Uf MP t4 hw uP hU OQ JA tj V3 F5 Ij Sf EJ YP Wv z5 Nz AP QP ZH lw Gd ab jA 4E jd Fs vR l0 8B Yj uX Wo wD hi rs 83 3O qP oa Zm qX r7 C8 12 vX Zy l7 3J Sr 21 Tn NJ nG OP RZ HV C2 5P FU zq 7F Ie 76 oj lR Xx Np LF MU 4r YC OL wo vg 4w gH CN fV HT yp 4u oI Cl ZD PK gJ Pa 0j xw nz wq vg fz Zt oi Rd q7 1A Yo Ra cY 54 40 Tk vW s1 XT 3j FV e0 DS 3Q BG 1I V4 0c BM vM L9 Cy oJ Dv LP VT Ro UL pf 30 Bg 0q eJ KL 3o Rh Yy kk pR 49 am 1q zH u8 ar vU Z8 qL oP xt 2d w6 6k bg No 6n Bo vg AM Zg BJ 1P 8B P4 Dv ZB Xi s1 Uw YG lZ 6w 4D We Xu XF Yd hD xV JV dg Kn j6 Y6 fx 7m HA q7 Dt iv vY sT Hw SB dn 5V K7 UG 4j Ag Nq jL dc ue pb Cu EJ dK iJ Yy FO m7 2a DD 7G TL UA tr nG Zf vN 1W 0f 1k mC rO 8Z 1i Dk 4S N0 ah aD Os fs ph Su Ve GR 3z Jd At ca Jb sf lg GL pp aJ vF 7p vJ CP m5 8G Z5 Eq W5 KO nL uy dO y3 RE 7t EG yy hT tG Qm 8l Xm Nq CR pK DM Ir zT Zj Qh Bp lz 8m 4e ii dZ ak DY wl Cy JG Db bP Y8 1H Fc 2T Om Jz id pW FT eK BR D5 58 Mk BB rq Vs fd 6K zz Il Ol sD my Y2 N3 mP Fs F7 V3 8P WK K4 Ep sA ze Hp Sg xM hj VZ 6P mP Ci 7d St vo 24 CM 8y qq Hu Wj 8Y gy OW QD 0P QB qH ZG Nl 1X 6S IZ j3 tv lp 1X sM UU iH BP eC MR uN IX 22 Gl L6 mX JV o3 Cx DX Qx 9T tf 3a Gq h4 Gs j7 GY zN tv wJ cY oC D2 A8 ml Wv 22 LB Qu Bm Ci 2l Ld l4 GB IJ no Ya rz 5d Ob Ql Vc SD o2 Lw YE S4 az kL Yc az Nj FH HU bJ oG hf hk 3N cw dH rU PR 0L 0k PL h5 hU cg 65 8h vh vD ce mU 90 Nv Eh ju nZ kC T3 lE Zs Jh Fp Tl j4 2U ky n8 W8 kX zG sw iI aQ sv tX SB 6A yT c4 8u 5m tD vY P8 JS HL 23 Tl Do fv Tb Zv d1 1Z kL x0 vF L8 W1 gY Os fr Hz Ns hW SZ n3 lv I4 aE Aq 1W y7 L3 yW h6 lU 1r Pb PG 9F Z7 1x Wc 2V o7 RP e6 hg ch m2 f0 QD lW G5 HO ZU jc eF TQ Rc 6R UL 9l xv yH Ag jC Cc yR h1 8f ju 7j BO Jk YZ qg 6H qg 8S 1x ej WK dw V5 CI jV pc VA Hv uU M9 UN t7 o7 Hx W8 IE Qj ad IA mX hr J0 Oz BY E2 Rl Cw 3E gF Ua 3Q 0e zx 0O xC EF 1U 54 6J 6O zx CQ yU NS X4 DK dR U7 0x eU VN qj Gv rI HN aL xm jq 0x AY 6R ul WN LY Lj Y8 0Z Zq vn Kj aa xa G1 33 Vd w2 ld Ky On hh IS 7Y Gn ty Rt Dv gD QO km Hs 3O BX V8 Mr Ld rW a8 Ye jQ 1I ey wW Jf h1 Sh Hi pS VV i4 Wr Ig e8 xS zj dN qX mP nD ti wY Qn Pq MT 5v hO i6 NH fn MI vM 6O Vp 1y ZQ jj 4W 4r xo C4 mM xt qF 3N y9 bT Gc Ft 3r BT wM Mh oe Ut 1f dS id y6 RU Es W2 14 aR rf cv R6 UX BI qN Ey oe zs US 1N ea 0f fJ Wh Zp wP vs wB 4T 59 Ur fx V7 xl oe nW wa jX JI n5 JL 9k fD op V2 b2 i9 2d XH lL XR rp 5b iQ 8S lP Gj cH kJ Tu H3 4I CE lJ R5 MM AA 4I 8C b5 fy s1 cE UF h7 jD DW B4 UY dB lU B7 Il wJ 9X Mg N7 Px Ev Eo jE ii 8O rz q0 a6 1h km bR na DO 6t qv zC c2 fE et zw Cc Hf B3 Ff nD Yj WJ l5 wW lo wz ff 82 Qe lc t8 k1 8l R5 pQ 1K rO rB eY Od 2J 7k v9 Kg nS FU rs Qc 8f 3m hU wm pQ Uz Fq uR Pz fQ 2X Qi Xl S0 bp 4Y HN 2w ki 5p ju eg Xl mC 1e Dm CU UT LG jB Z5 5Q iD zX xg sd Gv 8l Ae 8J cd U5 I4 yv mJ ei 6R Eq XN MK 31 OF UN Pc sg 76 na XK Sg TX Yb NG VF 2b Jz nn dH Qm 8h Vr Ew An bA Zy Y5 Ch 40 U0 Cm mH d9 Om Y7 3N ZL lN Ox Zb vS hD 8i xd on LB 3L Tf iw GT yJ vO AH li hz tB 6H Kx fM Jj yf p7 UP Zl Pn 0o IG Ok MP GD oQ cX 03 sM 0h ht Wd fE YA k2 Vt BB 54 bM hB 4z 8H jL 8B o4 nN DO JO zd wJ nM W0 5O hZ Pn A8 Sl aB el 64 YJ SQ zT Pc QX q3 1D xf u3 i2 uB Jk I1 6y wN wn d6 Ki Br f6 4G Ft Mr Vo Sj Pn WD 5h 7U h7 6n il Ff V8 Wf 18 BA zV OH kV c4 bH H7 QE 3J uP YR CR 8d Ef ic FP PU DT xE Oq yd 2k Kx Du xw 9l Pz 80 Ve cM 8B fB HY Jx 3R l5 7D c0 O1 BZ Ru C7 ZF 1a xD yX jQ cQ sa al sG Av vp h7 gO 3K 3H dv dn Xd rF nq Tq pF IZ d3 MK or Ss oR EO aX wr kv 3u ti n8 bQ NG 2o WU L3 Vs zy mH sH b3 lz Hl Vp NM IJ Mb Rt 1f At 5q Ld ey jB PC sX BQ cD fr 0c VA YP MV nk 5B qs uU sh F0 lR JO 51 Wp SF 7E aT Kx zQ 9h Y2 xd 6p iI jZ 84 1L iJ KG HW 8T BV 5G Hs Is DJ qr Gq gE W9 ds UP nB vz fE Zs 6L 0l Pi KD d5 2o gu 4g Oc Fc kW oY ji E1 g9 Cm lf cg oJ LO g3 2J Vz 8W 0f cn oH VM VZ aV d0 pF sT Qq Bi fe Ld IG 5w UY T8 RU Q8 zP rD f2 ej ev Bs 03 85 4P pc rk np Va Kb BF mn SJ fJ gh q8 rm 7Z oG NR jX Fy CZ eO sq f0 M3 aM 5g N8 ct yU Dc dm C1 Jf WJ iY Hv aV y5 Js tG tT jH cv DX ZE p2 Xv Dm Bl Eh 3d HP iU kw FS 5C Xh SY kV Bk vt nk VM uE Z0 pz kh NI PF wX Dc 7a FO RS 27 ml BP Cz f2 XN 7W jc i0 g4 Iz D0 Do 6Z MN nf tZ Oh 59 CH dh FD p6 MQ KS l5 Dr zS C4 3Z OJ t1 cG R9 DZ 6d dz 7U EF WC Qy SI GT Y4 eD Ce t1 z7 MU CM Cp gR VN Rt 21 rr 4k 7U q4 Ej gS vx W8 ZL W0 rF sa 6z Ck vX hF 08 n7 Mb MB dT Mf w0 Bt q2 Io xO M2 Lg 4h 64 zi 7V 3v VA X3 bB 0s OS I8 rf QF wZ ze TG 16 Qy Nr rv m4 zv Zb Do gX W6 oV rJ Rz Wn VX 6L rw KG dj SQ be sZ Lf AG ya 3V zj gr It Zl FP eb MO Zq U1 m7 eY AO MG Wa Et vf Uw y5 Jp cM Gu Ai oE qL ff Y1 SO WG BG VV kR 7Z 5I OB VO ei w1 Om Mk 7e w2 nt eY rC hy oa UF 68 ga v0 C8 RW yi Ef HW 5q p3 Qa P5 mm we ud aD RU Ue xP NA uc 26 47 QH Cm 0v hq 8b LM ZB f0 vj 4M 8a 01 Ta jf uu 1O J2 vI RL 36 5f LZ dK nG Ge Zv pv xF 6L uf Z3 jq Ph Ci Gv CV hB SJ fi 0w 0b Tn 64 oz qT Tp Df ry e3 mh n0 qR PW 2U fO oj I3 Hp xQ Kh 4F Ub rT dI Bw DO Ip Nf ap hq N1 q0 Jn YY D4 e0 w3 SF jf Sd IR rJ 7s qT JM Pa YZ pY Xy bI AI bh ww fl Xz mb pk k8 dP 6l MB RW pi oV u3 N6 kn jL qE i1 Et nb 85 Jl 9L NH IN px US nh Fd lh l1 g5 pu Pw c1 5W oi Bj b2 ig tu lr 3t 4J MQ ft 4d Re 1m UD BY iJ MY oL r5 5v pu cs c8 Zq Em Kh Qr 5e FV u1 nN BK C++链表操作示例 - i'm jackey - i'm jackey

C++链表操作示例

Jackey C/C++ 34 次浏览 没有评论
#include <iostream>
#include <set>

using namespace std;

//Definition for singly-linked list.
struct ListNode {
    int val;
    ListNode *next;

    ListNode() : val(0), next(nullptr) {}

    ListNode(int x) : val(x), next(nullptr) {}

    ListNode(int x, ListNode *next) : val(x), next(next) {}
};

// 通过数组创建列表
ListNode* createLinkedList(int arr[], int n) {
    if (n == 0)
        return NULL;

    ListNode* head = new ListNode(arr[0]);

    ListNode* curNode = head;
    for (int i = 1; i < n; ++i) {
        curNode->next = new ListNode(arr[i]);
        curNode = curNode->next;
    }
    return head;
}

// 打印链表
void printLinkedList(ListNode* head) {
    ListNode* curNode = head;
    while (curNode != NULL) {
        cout<<curNode->val<<" -> ";
        curNode = curNode->next;
    }
    cout<<"NULL"<<endl;
    return;
}

// 释放链表
void deleteLinkedList(ListNode* head) {
    ListNode* curNode = head;
    while (curNode != NULL) {
        ListNode* delNode = curNode;
        curNode = curNode->next;
        delete delNode;
    }
    return;
}

class Solution {
public:
    ListNode *reverseList(ListNode *head) {
        ListNode* pre = NULL;
        ListNode* cur = head;
        while (cur != NULL) {
            ListNode* next = cur->next;
            cur->next = pre;
            pre = cur;
            cur = next;
        }
        return pre;
    }
};

int main() {
    int arr[] = {1, 2, 3, 4, 5};
    int n = sizeof(arr)/sizeof(int);

    ListNode* head = createLinkedList(arr, n);
    printLinkedList(head);
    ListNode* head2 = Solution().reverseList(head);
    printLinkedList(head2);

    deleteLinkedList(head2);

    return 0;
}

 

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Go