Add cv6/main.c

This commit is contained in:
Marat Izmailov 2024-11-07 21:13:50 +00:00
parent 80d7f1c4d9
commit 7c8e8584b8

40
cv6/main.c Normal file
View File

@ -0,0 +1,40 @@
#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;
}