Guest User

Untitled

a guest
Dec 15th, 2014
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. void LList::insert(int num, int at)
  2. {
  3.     node **pp = &root;
  4.     for (; *pp && at; pp = &(*pp)->next, --at);
  5.    
  6.     if (at == 0)
  7.     {
  8.         node *t = new node(num);
  9.         t->next = *pp;
  10.         *pp = t;
  11.     }
  12.     else
  13.     {
  14.         std::cerr << "invalid index\n";
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment