# Include <iostream> using namespace STD; typedef int t; class list {struct node {t data; node * Next; node (const T & D, node * Next = NULL ): data (D), next (next) {}}; node * head; int Len; public :~ List () {clear ();} List (): Head (), Len () {} int size () const {return Len;} void travel () const {node * P = head; while (p) {cout <p-> data <''; P = p-> next;} cout <Endl ;} void clear () {node * P = head, * q; while (p) {q = p-> next; Delete P; P = Q;} head = NULL, len = 0;} node * & getptr (int n) {If (n <0 | n> Len) n = Len; If (n = 0) return head; node * P = head; For (INT I = 1; I <n; I ++) P = p-> next; return p-> next ;} void insert (const T & D, int N) {node * & P = getptr (n); node * q = new node (d, p); P = Q; ++ Len ;} void erase (int n) {node * & P = getptr (n); If (p) {node * q = P; P = p-> next; Delete Q; -- Len ;}} void remove (const T & D) {node * & P = find (d); If (p) {node * q = P; P = p-> next; Delete Q; -- Len ;}} node * & find (const T & D) {If (LEN = 0 | head-> DATA = d) return head; node * P = head; while (p-> next & P-> next-> data! = D) P = p-> next; return p-> next;} void Update (const T & oldv, const T & newv) {node * P = find (oldv ); if (p) {P-> DATA = newv;} T & Front () {return head-> data;} T & back () {return getptr (len-1) -> data;} void push_front (const T & D) {insert (D, 0);} void push_back (const T & D) {insert (D, Len );} void pop_front () {erase (0);} void pop_back () {erase (len-1);} void sort () {} void reverse () {} T & operator [] (INT index) Throw (const char *) {If (index <0 | index> = Len) throw ""; return getptr (INDEX) -> data ;}}; int main () {list l; L. insert (1, 0); L. insert (2, 0); L. insert (3, 0); L. insert (4, 4); L. insert (5, 4); L. insert (6, 6); L. travel (); L. erase (3); L. remove (2); L. travel (); L. update (5, 6); L. travel (); For (INT I = 0; I <L. size (); I ++) cout <L [I] <','; cout <Endl; return 0 ;}
PS: for the interview and test, or want to familiarize yourself with the list of children's shoes