Advertisement
lukusm

Untitled

Jan 16th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. void insertFirst(book_list* b1, book* b) {
  2.     book* tmp = b1->first;
  3.     int ifExist = 0;
  4.     do{
  5.         if(strcmp(tmp->title,b->title)==0) {
  6.             tmp->copies += b->copies;
  7.             ifExist=1;
  8.         }
  9.     }while(tmp!=b1->first);
  10.    
  11.     if(ifExist==0) {
  12.         b->next = b1->first;
  13.         b1->first = b;
  14.         b1->last->next = b1->first;
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement