usaa24/cv6/main.c
2024-11-07 21:13:50 +00:00

41 lines
1.1 KiB
C

#include "a_station.h"
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
// Печатает всю станцию для отладки
void print_station(struct station* station) {
printf("station>>>\n");
for (int i = 0; i < station->track_count; i++) {
struct car* current = station->tracks[i];
while (current) {
printf("%s %d -> ", current->value, current->capacity);
current = current->next;
}
printf("NULL\n");
}
printf("<<<station\n");
}
// Тестирование функции станции
void test_station(struct station* station) {
const char* stations[] = {"Presov", "Kosice", "Bratislava", "Zilina", "Poprad"};
int size = 5;
for (int i = 0; i < 10; i++) {
int s = rand() % size;
int c = rand() % 20;
printf("%s %d\n", stations[s], c);
add_target_capacity(station, stations[s], c);
print_station(station);
}
}
int main() {
srand(time(NULL));
struct station* station = create_station();
test_station(station);
destroy_station(station);
return 0;
}