#include #include "String.h" #include "List.h" main () { #ifdef CPLUS_BUG19 IvlList l; #else IvlListOf l; #endif char c; char s[80]; while ((c = getchar ()) != EOF) { switch (c) { case 'a': scanf (" %s", s); l.Append (NewString (s)); break; case 'p': scanf (" %s", s); l.Prepend (NewString (s)); break; case '+': l.RemoveFirst (); break; case '-': l.RemoveLast (); break; case '\n': continue; case 'i': { int i; scanf (" %d %s", &i, s); #ifdef CPLUS_BUG19 IvlListIter lj (l); #else IvlListIterOf lj (l); #endif while ((i-- > 0) && ++lj) ; l.InsertBefore (lj, NewString (s)); break; } case 'j': { int i; scanf (" %d %s", &i, s); #ifdef CPLUS_BUG19 IvlListIter lj (l); #else IvlListIterOf lj (l); #endif while ((i-- > 0) && ++lj) ; l.InsertAfter (lj, NewString (s)); break; } } #ifdef CPLUS_BUG19 IvlListIter li (l); while (++li) { char* pt = (char*) *li; printf ("%s ", pt); } #else IvlListIterOf li (l); while (++li) { char* pt = *li; printf ("%s ", pt); } #endif printf ("\n"); } }