void sortticket if headticket headticket- linknext headticket int int

 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
void sortticket(){
if(headticket && headticket->linknext!=headticket){
int k=1;
int s=0;
int i=0;
int n=0;
ticket *var=headticket;
ticket *vartwo;
while(var->linknext!=headticket){
k++;
var=var->linknext;
}
ticket *headtwo=NULL;
i=k;
while(k){
if(headtwo){
vartwo=headtwo;
while(vartwo->linknext!=headtwo){
vartwo=vartwo->linknext;
}
vartwo->linknext=new ticket;
vartwo=vartwo->linknext;
vartwo->linknext=headtwo;
}else{
headtwo=new ticket;
headtwo->linknext=headtwo;
}
k--;
}
while(i){
vartwo=headticket;
s=k;
while(s){
vartwo=vartwo->linknext;
s--;
}
var=headticket;
n=0;
do{
if(strcmp(var->numberticket,vartwo->numberticket)<0){
n++;
}
var=var->linknext;
}while(var!=headticket);
s=n;
var=headtwo;
while(s){
var=var->linknext;
s--;
}
strcpy(var->numberflight,vartwo->numberflight);
strcpy(var->numberpass,vartwo->numberpass);
strcpy(var->numberticket,vartwo->numberticket);
i--;
k++;
}
fulldellticket();
headticket=headtwo;
}
}