Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #define N 30
- #define M 9
- typedef struct
- {
- char id[M];
- char name[N];
- char family[N];
- }passenger;
- typedef struct
- {
- int row;
- int chair;
- char clas;
- char status;
- char pasport[M];
- struct seat *next;
- }seat;
- typedef struct
- {
- int chairs;
- char classArows;
- seat *seat;
- }plane;
- void menu();
- typedef enum{ ticket_order = 1, cancel_order, report_group_passengers, report_not_occupied_seats, Exit }Menu;
- void linked_lists(plane*, seat*);
- void build_plane(plane*, seat*);
- int main() {
- plane plane;
- seat seat;
- do{
- printf("Enter number of seats in your plane (minimum 20 seats)\n");
- scanf("%d", &plane.chairs);
- if (plane.chairs < 20)
- printf("number of seats must be at least 20\n");
- } while (plane.chairs < 20);
- do{
- printf("Enter number of rows in 'A' class (beetwen 1-3)\n");
- scanf("%d", &plane.classArows);
- if (plane.classArows <1 || plane.classArows>3)
- printf("number of rows must be beetwen 1-3\n");
- } while (plane.classArows <1 || plane.classArows>3);
- linked_lists(&plane, &seat);
- printf("artur\n");
- /*build_plane(&plane, &seat);*/
- return 0;
- }
- void menu()
- {
- int choose;
- printf("Menu:\n1-To make an order of tickets\n2-Cancel tickets order\n3-Producing tickets report for Group of Passengers\n4-Producing a report of not occupied seats\n5-Exit\n");
- do{
- printf("what do you want to do?\nPlease make your choose from the menu\n");
- scanf("%d", &choose);
- if (choose<0 || choose>5)
- printf("please choose beetwen 1-5\n");
- } while (choose<0 || choose>5);
- switch (choose){
- case ticket_order:
- break;
- case cancel_order:
- break;
- case report_group_passengers:
- break;
- case report_not_occupied_seats:
- break;
- case Exit:
- exit(1);
- break;
- }
- }
- void linked_lists(plane *plane, seat *seat1)
- {
- int i,j,x=1,y=1;
- seat *head = NULL,*temp;
- for (i = 0; i < plane->chairs; i++)
- {
- temp = (seat*)malloc(sizeof(seat));
- if (temp = NULL)
- {
- printf("canot allocate memory\n");
- exit(1);
- }
- if (temp->chair <= (plane->classArows * 4))
- {
- temp->chair = i;
- if (temp->row <= plane->classArows)
- temp->row = y;
- if (x % 4 == 0)
- y++;
- temp->clas = 'A';
- x++;
- }
- else
- {
- temp->chair = i;
- temp->row = y;
- x++;
- if (x % 6 == 0)
- y++;
- temp->clas = 'T';
- }
- if (temp->chair == (plane->classArows * 4))
- x = 1;
- temp->next = head;
- head = temp;
- }
- plane->seat = head;
- }
- void build_plane(plane *plane, seat *seat1)
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement