Initializacia
This commit is contained in:
parent
df2f224230
commit
6448cb0e4d
@ -21,47 +21,47 @@ struct car* add_car(struct car* first,const char* target) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void print_train(struct car* first) {
|
void print_train(struct car* first) {
|
||||||
if(first != NULL){
|
// if(first != NULL){
|
||||||
struct car* current = first;
|
// struct car* current = first;
|
||||||
while(current->next != NULL){
|
// while(current->next != NULL){
|
||||||
printf("%s\n", current->value);
|
// printf("%s\n", current->value);
|
||||||
current = current->next;
|
// current = current->next;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void cancel_train(struct car* first) {
|
void cancel_train(struct car* first) {
|
||||||
struct car* current = first;
|
// struct car* current = first;
|
||||||
while(first != NULL){
|
// while(first != NULL){
|
||||||
current = current->next;
|
// current = current->next;
|
||||||
free(first);
|
// free(first);
|
||||||
first = current;
|
// first = current;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct car* clear_train(struct car* first, const char* target) {
|
struct car* clear_train(struct car* first, const char* target) {
|
||||||
if (first = NULL){
|
// if (first = NULL){
|
||||||
return NULL;
|
// return NULL;
|
||||||
}
|
// }
|
||||||
struct car* current = first, new_first = first;
|
// struct car* current = first, new_first = first;
|
||||||
if (first != NULL){
|
// if (first != NULL){
|
||||||
if(strcmp(first->destination, target) == 0){
|
// if(strcmp(first->destination, target) == 0){
|
||||||
new_first = new_first->next;
|
// new_first = new_first->next;
|
||||||
free(first);
|
// free(first);
|
||||||
first = new_first;
|
// first = new_first;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
while (first->next != NULL) {
|
// while (first->next != NULL) {
|
||||||
current = first->next;
|
// current = first->next;
|
||||||
if (strcmp(current->destination, target) == 0) {
|
// if (strcmp(current->destination, target) == 0) {
|
||||||
first->next = current->next;
|
// first->next = current->next;
|
||||||
free(current);
|
// free(current);
|
||||||
} else {
|
// } else {
|
||||||
first = current;
|
// first = current;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return new_first;
|
// return new_first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user