-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathParking.cpp
66 lines (57 loc) · 1.13 KB
/
Parking.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
#include <iostream>
int main()
{
using namespace std;
int priceA;
int priceB;
int priceC;
int startA, endA;
int startB, endB;
int startC, endC;
bool timeRange[101];
cin >> priceA >> priceB >> priceC;
cin >> startA >> endA;
cin >> startB >> endB;
cin >> startC >> endC;
int startRange[]{startA, startB, startC};
int endRange[]{endA, endB, endC};
int min = startA;;
int max = endA;
int totalPay = 0;
for(int i = 1; i < 3; i++)
{
if (startRange[i] < min)
{ min = startRange[i]; }
if (endRange[i] > max)
{
max = endRange[i];
}
}
for (double i = min+0.5; i < max; i++)
{
int price = 0;
int numOfCar = 0;
if (startA <= i && i <= endA)
{
numOfCar++;
}
if (startB <= i && i <= endB)
{
numOfCar++;
}
if (startC <= i && i <= endC)
{
numOfCar++;
}
switch(numOfCar)
{
case 0:break;
case 1: price = priceA; break;
case 2: price = priceB; break;
case 3: price = priceC; break;
}
totalPay += price*numOfCar;
}
cout << totalPay << endl;
return 0;
}