Advertisement
Guest User

Untitled

a guest
Jan 20th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. int List::indexOf(int ch)
  2. {
  3.     int counter = 0;
  4.     charNode * temp = this->head;
  5.     while (temp != NULL) {
  6.         counter += temp->getValue();
  7.         if (temp->getData() == ch) {
  8.             delete temp;
  9.             return counter - temp->getValue();
  10.         }
  11.         temp = temp->getNext();
  12.     }
  13.     delete temp;
  14.     return -1;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement