-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKSLC.cpp
More file actions
45 lines (36 loc) · 973 Bytes
/
Copy pathKSLC.cpp
File metadata and controls
45 lines (36 loc) · 973 Bytes
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
#include <iostream>
const int MAX_WEIGHT = 1020; // Maximum weight in kg
const int MAX_PEOPLE = 8; // Maximum number of people allowed
int currentWeight = 0;
int peopleInLift = 0;
int detectPeopleInLift() {
if (peopleInLift < MAX_PEOPLE) {
peopleInLift++;
}
return peopleInLift;
}
bool checkWeight() {
return currentWeight >= MAX_WEIGHT || peopleInLift >= MAX_PEOPLE;
}
void skipFloors() {
while (checkWeight()) {
std::cout << "Lift full, skipping floors...\n";
peopleInLift--; // Simulate people exiting
}
}
void moveLiftToFloor() {
std::cout << "Lift moving...\n";
}
int main() {
while (true) {
detectPeopleInLift();
if (checkWeight()) {
std::cout << "Lift full!\n";
skipFloors();
} else {
moveLiftToFloor();
}
std::cout << "People in lift: " << peopleInLift << ", Weight: " << currentWeight << " kg\n";
}
return 0;
}