conditional Linked List

i've find a way to add and del node with FIFO method
here it is

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
void add ()
  {  
	 node *temp, *temp2;   
	 temp = new node;
	 
     temp->next = NULL;

     if (start == NULL)
         start = temp;
     else
       { temp2 = start;
         // We know this is not NULL - list not empty!
         while (temp2->next != NULL)
           {  temp2 = temp2->next;
              // Move to next link in chain
           }
         temp2->next = temp;
       }
  }

void del()
   { 
	    if (start = NULL)
			cout << "its already empty!"<<endl;
		node *temp;
		temp = start;
		start = start->next;
		delete temp;
   }



but cant find a way to make the algo for this case
'you have a limited numbered seat, every person that comes in sat in the lowest number of seat'

tried to use 'for' but found that it cannot work if someone leave before the seat is full

and how can i see how many seat avalaible/occupied ?

anyone help ?
Last edited on
I don't seem to grasp your problem... Could you explain a little bit more please??

You don't use a class??

Do you set start to NULL on purpose on line 23 (your compiler's probably warning you)...
Topic archived. No new replies allowed.