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