Advertisement
Guest User

Untitled

a guest
May 26th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #define N 30
  4. #define M 9
  5. typedef struct
  6. {
  7. char id[M];
  8. char name[N];
  9. char family[N];
  10. }passenger;
  11. typedef struct
  12. {
  13. int row;
  14. int chair;
  15. char clas;
  16. char status;
  17. char pasport[M];
  18. struct seat *next;
  19. }seat;
  20. typedef struct
  21. {
  22. int chairs;
  23. char classArows;
  24. seat *seat;
  25. }plane;
  26. void menu();
  27. typedef enum{ ticket_order = 1, cancel_order, report_group_passengers, report_not_occupied_seats, Exit }Menu;
  28. void linked_lists(plane*, seat*);
  29. void build_plane(plane*, seat*);
  30. int main() {
  31. plane plane;
  32. seat seat;
  33. do{
  34. printf("Enter number of seats in your plane (minimum 20 seats)\n");
  35. scanf("%d", &plane.chairs);
  36. if (plane.chairs < 20)
  37. printf("number of seats must be at least 20\n");
  38. } while (plane.chairs < 20);
  39. do{
  40. printf("Enter number of rows in 'A' class (beetwen 1-3)\n");
  41. scanf("%d", &plane.classArows);
  42. if (plane.classArows <1 || plane.classArows>3)
  43. printf("number of rows must be beetwen 1-3\n");
  44. } while (plane.classArows <1 || plane.classArows>3);
  45. linked_lists(&plane, &seat);
  46. printf("artur\n");
  47. /*build_plane(&plane, &seat);*/
  48. return 0;
  49. }
  50. void menu()
  51. {
  52. int choose;
  53. 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");
  54. do{
  55. printf("what do you want to do?\nPlease make your choose from the menu\n");
  56. scanf("%d", &choose);
  57. if (choose<0 || choose>5)
  58. printf("please choose beetwen 1-5\n");
  59. } while (choose<0 || choose>5);
  60. switch (choose){
  61. case ticket_order:
  62. break;
  63. case cancel_order:
  64. break;
  65. case report_group_passengers:
  66. break;
  67. case report_not_occupied_seats:
  68. break;
  69. case Exit:
  70. exit(1);
  71. break;
  72. }
  73. }
  74. void linked_lists(plane *plane, seat *seat1)
  75. {
  76. int i,j,x=1,y=1;
  77. seat *head = NULL,*temp;
  78. for (i = 0; i < plane->chairs; i++)
  79. {
  80. temp = (seat*)malloc(sizeof(seat));
  81. if (temp = NULL)
  82. {
  83. printf("canot allocate memory\n");
  84. exit(1);
  85. }
  86. if (temp->chair <= (plane->classArows * 4))
  87. {
  88. temp->chair = i;
  89. if (temp->row <= plane->classArows)
  90. temp->row = y;
  91. if (x % 4 == 0)
  92. y++;
  93. temp->clas = 'A';
  94. x++;
  95. }
  96. else
  97. {
  98. temp->chair = i;
  99. temp->row = y;
  100. x++;
  101. if (x % 6 == 0)
  102. y++;
  103. temp->clas = 'T';
  104. }
  105. if (temp->chair == (plane->classArows * 4))
  106. x = 1;
  107. temp->next = head;
  108. head = temp;
  109. }
  110. plane->seat = head;
  111. }
  112. void build_plane(plane *plane, seat *seat1)
  113. {
  114.  
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement