Link List that append 2 queue based on condition

This is a snippet of my code.
Basically this code are going to let user to key in customer (A~Z), time arrival, age and status (VIP or Normal).
If the person age is more than 55, it's also consider as a VIP.
The problem is that when I run the code, it just keep on not responding. The InsertMainQueue will append based on the following condition: every 3 VIP is served, a Normal customer must be served. After serving 10 customers, only those in VIP Queue are eligible to queue and those in Normal queue will be ignored.
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
void InsertMainQueue(Node* temp, int a)
    {
        if(counter<10)
        {
            if(a<3)
            {
                if(vipcont%3!=0)
                    Main=temp;
                else
                    Main->link=temp;
                    vipcont++;
            }
            else
            {
                if(counter%3==0)
                    Main=temp;
                else
                {
                    for(int i=0; i<counter; i++)
                        Main=Main->link;
                    Main=temp;
                }
            }
        }
        else
        {
            if(a<3)
                Main=temp;
        }
        Main=Main->link;
        counter++;
    }
    void Insert (char a, int time, int age, int status)
    {
        if (status==2) status=3;
        if(age>55) status=2;
        Node *temp,*q;
        temp=new Node;
        temp->customer = a;
        temp->priority=status;
        temp->time=time;
        if(status<3)
        {
            if(VIP==NULL||status<VIP->priority||time<VIP->time)
            {
                temp->link=VIP;
                VIP=temp;
            }
            else
            {
                q=VIP;
                while(q->link!=NULL&&q->link->time<=time)
                    q=q->link;
                temp->link=q->link;
                q->link=temp;
            }
        }
        else
        {
            if(Normal==NULL||status<Normal->priority||time<Normal->time)
            {
                temp->link=Normal;
                Normal=temp;
            }
            else
            {
                q=Normal;
                while(q->link!=NULL&&q->link->time<=time)
                    q=q->link;
                temp->link=q->link;
                q->link=temp;
            }
        }
        InsertMainQueue(temp,status);

    }
Topic archived. No new replies allowed.