-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
158 lines (151 loc) · 3.49 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
cout << "Flight Seating System \n" << "Type 1 for \"First Class.\"\n" << "Type 2 for \"Economy.\"" << endl;
srand(time(NULL));
int x[30], a, b;
cin >> a;
int sayac1 = 0;
int sayac2 = 10;
for (int i = 0; i < 10; i++)
{
x[i] = 1 + rand() % 10;
for (int j = 0; j < i; j++) {
if (x[i] == x[j])
{
i--;
break;
}
}
} //Rastgele Atama 1
for (int i = 10; i < 30; i++)
{
x[i] = 11 + rand() % 20;
for (int j = 10; j < i; j++) {
if (x[i] == x[j])
{
i--;
break;
}
}
} //Rastgele Atama 2
if (a != 1 && a != 2)
{
for (;;) {
cout << "Sorry, that choice is invalid." << endl;
cin >> a;
if (a == 1 || a == 2)
break;
}
}
do {
do {
if (a == 2)break;//ilk baþta economy üretmemesini engellemek için.
if (sayac1 < 10) {
cout << "\t---Boarding Pass---" << endl;
cout << "Seat Number: " << x[sayac1] << endl;
cout << "Section: First Class" << endl;
sayac1++;
cout << "Type 1 for \"First Class.\"\n" << "Type 2 for \"Economy.\"" << endl;
cin >> a;
if (a != 1 && a != 2)
{
for (;;) {
cout << "Sorry, that choice is invalid." << endl;
cin >> a;
if (a == 1 || a == 2)
break;
}
}
}
else
{
if (sayac2 < 30)
{
cout << "First Class is Full. Would you like a seat in Economy Class? For \"Yes\" Press \"1\" For \"No\" Press \"2\"" << endl;
cin >> b;
if (b == 1)
{
a == 2;
break;
}
else if (b == 2) {
cout << "The next flight leaves in 3 hours." << endl;
return 0;
}
else {
do {
cout << "Sorry, that choice is invalid." << endl;
cin >> b;
} while (b != 1 && b != 2);
if (b == 1)
{
a == 2;
break;
}
if (b == 2) {
cout << "The next flight leaves in 3 hours." << endl;
return 0;
}
}
}
else {
cout << "This flight's capacity is full. The next flight leaves in 3 hours." << endl;
return 0;
}
}
} while (a == 1);
do {
if (sayac2 < 30) {
cout << "\t---Boarding Pass---" << endl;
cout << "Seat Number: " << x[sayac2] << endl;
cout << "Section: Economy Class" << endl;
sayac2++;
cout << "Type 1 for \"First Class.\"\n" << "Type 2 for \"Economy.\"" << endl;
cin >> a;
if (a != 1 && a != 2)
{
for (;;) {
cout << "Sorry, that choice is invalid." << endl;
cin >> a;
if (a == 1 || a == 2)
break;
}
}
}
else
{
if (sayac1 < 10) {
cout << "Economy Class is Full. Would you like a seat in First Class? For \"Yes\" Press \"1\" For \"No\" Press \"2\"" << endl;
cin >> b;
if (b == 1) {
a == 1;
break;
}
else if (b == 2) {
cout << "The next flight leaves in 3 hours." << endl;
return 0;
}
else {
do {
cout << "Sorry, that choice is invalid." << endl;
cin >> b;
} while (b != 1 && b != 2);
if (b == 2) {
cout << "The next flight leaves in 3 hours." << endl;
return 0;
}
}
}
else {
cout << "This flight's capacity is full. The next flight leaves in 3 hours." << endl;
return 0;
}
}
} while (a == 2);
} while (a == 1 || a == 2);
return 0;
}//end main