train
This commit is contained in:
parent
e0e3d11bf2
commit
a395055ead
@ -32,16 +32,27 @@ void print_train(struct car* first) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cancel_train(struct car* first) {
|
void cancel_train(struct car* first) {
|
||||||
|
struct car* this;
|
||||||
if(first == NULL){
|
if(first == NULL){
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
if(first->next == NULL){
|
else if(first->next == NULL){
|
||||||
struct car* this = first;
|
this = first;
|
||||||
first = first->next;
|
first = first->next;
|
||||||
free(this);
|
free(this);
|
||||||
|
first = NULL;
|
||||||
}
|
}
|
||||||
cancel_train(first->next);
|
else{
|
||||||
free(first);
|
struct car* prev = first;
|
||||||
|
while(prev->next->next != NULL){
|
||||||
|
prev = prev->next;
|
||||||
|
}
|
||||||
|
this = prev->next;
|
||||||
|
prev->next = NULL;
|
||||||
|
free(this);
|
||||||
|
}
|
||||||
|
//cancel_train(first->next);
|
||||||
|
//free(first);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user