From 094998cc799518b695cbec0665d1be45c7a47451 Mon Sep 17 00:00:00 2001 From: Sambo Chea Date: Mon, 3 Aug 2020 14:58:28 +0700 Subject: [PATCH] Updated and create q3 --- work1/q3.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/work1/q3.c b/work1/q3.c index 4ce89ab..3b2baf6 100644 --- a/work1/q3.c +++ b/work1/q3.c @@ -4,12 +4,15 @@ #define DEPOT_SIZE 10 -struct Bus { +struct Bus +{ int BusID; int RouteID; time_t schedule; } Depot[DEPOT_SIZE]; +typedef enum { true, false } bool; + void createBuses(); void printBuses(); void scheduleBuses(); @@ -17,12 +20,34 @@ void alignupBuses(); void releaseBuses(); void emergency(); -int main() { +// utils variable +bool has_created = false; +// utils function +print_depot(struct Bus *depot); + +int main() +{ return EXIT_SUCCESS; } -void createBuses() { - // do something - +void createBuses() +{ + for (int i = 0; i < DEPOT_SIZE; i++) + { + Depot[i].BusID = i + 1; + Depot[i].RouteID = 1000 + (i + i); + } + + has_created = true; +} + +print_depot(struct Bus *depot) { + int size = sizeof(depot) / sizeof(depot[0]); + + printf("\n Depost size: %d", size); + for (int i = 0; i < size; i++) { + printf("Bus ID: %d\n", depot[i].BusID); + printf("Route ID: %d\n", depot[i].RouteID); + } } \ No newline at end of file