این کد رو برام توضیح بده #include <stdio.h> #include <string.h> #define MAXDOCTORS 5…
- User
این کد رو برام توضیح بده
#include <stdio.h> #include <string.h>
#define MAX_DOCTORS 5 #define MAX_APPOINTMENTS 10
// Structure to store doctor information struct Doctor { char name[50]; char specialization[50]; int available_slots; char appointment_slots[MAX_APPOINTMENTS][20]; // Time slots for appointments };
// Structure to store appointment information struct Appointment { char patient_name[50]; char doctor_name[50]; char date[20]; char time[10]; // Appointment time };
// Function declarations void viewDoctors(struct Doctor doctors[], int count); void bookAppointment(struct Doctor doctors[], int doctorCount, struct Appointment appointments[], int *appointmentCount); void viewAppointments(struct Appointment appointments[], int appointmentCount); void cancelAppointment(struct Doctor doctors[], int doctorCount, struct Appointment appointments[], int *appointmentCount); void initializeDoctors(struct Doctor doctors[]);
int main() { struct Doctor doctors[MAX_DOCTORS]; struct Appointment appointments[MAX_APPOINTMENTS]; int appointmentCount = 0; int choice;
// Initialize doctors with data and time slots initializeDoctors(doctors); while (1) { // Menu options printf("\n--- Online Doctor Appointment System ---\n"); printf("1. View Available Doctors\n"); printf("2. Book an Appointment\n"); printf("3. View Your Appointments\n"); printf("4. Cancel an Appointment\n"); printf("5. Exit\n"); printf("Enter your choice: "); scanf("%d", &choice); switch (choice) { case 1: viewDoctors(doctors, MAX_DOCTORS); break; case 2: bookAppointment(doctors, MAX_DOCTORS, appointments, &appointmentCount); break; case 3: viewAppointments(appointments, appointmentCount); break; case 4: cancelAppointment(doctors, MAX_DOCTORS, appointments, &appointmentCount); break; case 5: printf("Exiting the system...\n"); return 0; default: printf("Invalid choice! Please enter a valid option.\n"); } } return 0;}
// Function to initialize doctors with available appointment slots void initializeDoctors(struct Doctor doctors[]) { strcpy(doctors[0].name, "Dr. John Smith"); strcpy(doctors[0].specialization, "Cardiologist"); doctors[0].available_slots = 5; strcpy(doctors[0].appointment_slots[0], "10:00 AM"); strcpy(doctors[0].appointment_slots[1], "11:00 AM"); strcpy(doctors[0].appointment_slots[2], "12:00 PM"); strcpy(doctors[0].appointment_slots[3], "02:00 PM"); strcpy(doctors[0].appointment_slots[4], "03:00 PM");
strcpy(doctors[1].name, "Dr. Emily Davis"); strcpy(doctors[1].specialization, "Dermatologist"); doctors[1].available_slots = 3; strcpy(doctors[1].appointment_slots[0], "09:00 AM"); strcpy(doctors[1].appointment_slots[1], "10:00 AM"); strcpy(doctors[1].appointment_slots[2], "11:00 AM"); strcpy(doctors[2].name, "Dr. William Brown"); strcpy(doctors[2].specialization, "Pediatrician"); doctors[2].available_slots = 4; strcpy(doctors[2].appointment_slots[0], "08:00 AM"); strcpy(doctors[2].appointment_slots[1], "09:30 AM"); strcpy(doctors[2].appointment_slots[2], "11:00 AM"); strcpy(doctors[2].appointment_slots[3], "01:00 PM"); strcpy(doctors[3].name, "Dr. Olivia Green"); strcpy(doctors[3].specialization, "Orthopedic"); doctors[3].available_slots = 2; strcpy(doctors[3].appointment_slots[0], "10:30 AM"); strcpy(doctors[3].appointment_slots[1], "12:30 PM"); strcpy(doctors[4].name, "Dr. Michael White"); strcpy(doctors[4].specialization, "General Practitioner"); doctors[4].available_slots = 6; strcpy(doctors[4].appointment_slots[0], "09:00 AM"); strcpy(doctors[4].appointment_slots[1], "10:00 AM"); strcpy(doctors[4].appointment_slots[2], "11:00 AM"); - Assistant
این برنامه یک سیستم مدیریت وقت ملاقات آنلاین برای پزشکان است که به کاربران امکان میدهد پزشکان موجود را مشاهده کنند، وقت ملاقات را رزرو کنند، ویزیتهای رزرو شده خود را ببینند و ویزیتهای خود را لغو کنند. در اینجا توضیح کلی ساختار و عملکرد این برنامه ارائه شده است:
-
ساختار های داده:
Doctor:- اطلاعات مربوط به پزشکان را نگه میدارد شامل نام، تخصص، تعداد اسلاتهای خالی و زمانی که برای وقت ملاقات موجود است.
Appointment:- اطلاعات مربوط به وقتهای ملاقات را نگه میدارد شامل نام بیمار، نام پزشک، تاریخ و زمان ملاقات.
-