2020-11-05 18:01:56 +00:00
|
|
|
#include "a_train.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
2020-11-05 18:04:10 +00:00
|
|
|
/*int main(void){
|
2020-11-05 18:01:56 +00:00
|
|
|
printf("Zadajte zoznam cieľových staníc a počet cestujúcich.\n");
|
|
|
|
printf("Zoznam zakončite prázdnym riadkom.\n");
|
2020-11-05 18:03:18 +00:00
|
|
|
|
2020-11-05 18:01:56 +00:00
|
|
|
add_car;
|
|
|
|
return 0;
|
2020-11-05 18:04:10 +00:00
|
|
|
}*/
|
2020-11-05 18:01:56 +00:00
|
|
|
|
|
|
|
struct car* add_car(struct car* first,const char* target) {
|
|
|
|
struct car* newcar = calloc(1,sizeof(struct car));
|
|
|
|
struct car* temp=first;
|
|
|
|
int length=0;
|
|
|
|
while(temp!=NULL){
|
2020-11-05 18:36:45 +00:00
|
|
|
if(temp->next!=NULL){
|
2020-11-05 18:35:57 +00:00
|
|
|
temp=temp->next;
|
2020-11-05 18:36:45 +00:00
|
|
|
}
|
|
|
|
length++;
|
2020-11-05 18:01:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(newcar->value, target);
|
|
|
|
struct car* this = first;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void print_train(struct car* first) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void cancel_train(struct car* first) {
|
|
|
|
}
|
|
|
|
|
|
|
|
struct car* clear_train(struct car* first, const char* target) {
|
|
|
|
struct car* prev = first;
|
|
|
|
// Už sme si istí, že prev a prev->next nie sú NULL
|
|
|
|
// while (prev->next->next != NULL){
|
|
|
|
// prev = prev->next;
|
|
|
|
//}
|
|
|
|
//struct car* third = prev->next->next;
|
|
|
|
//free(prev->next);
|
|
|
|
//prev->next = third;
|
|
|
|
//return first;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|