-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGear Changing.cpp
More file actions
95 lines (71 loc) · 1.46 KB
/
Copy pathGear Changing.cpp
File metadata and controls
95 lines (71 loc) · 1.46 KB
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
#include <bits/stdc++.h>
using namespace std;
int main(void){
ios::sync_with_stdio(false);
cin.tie(NULL);
int c,b;
double p;
double percent;
vector <int> crank;
vector <double> back;
vector <double> gear; //divison
int value;
cin >> c; //crank
cin >> b; //back
cin >> p; //cadence
percent = p/100; // if p is int. int / int = int
for(int i=0; i<c;i++){ //for crank
cin >> value;
crank.push_back(value);
}
for(int i=0; i<b; i++){ //for back
cin >> value;
back.push_back(value);
}
for(int i=0; i<crank.size(); i++){ // for combine
for(int j=0; j<back.size(); j++){
double combine;
combine = crank[i] / back[j];
gear.push_back(combine);
}
}
sort(gear.begin(), gear.end(), greater <double>());
//int change = 0;
for(int k=0; k<gear.size()-1; k++){ //to check if MORE THAN P/100
if(((gear[k] - gear[k+1])/gear[k+1]) > percent){
//change = 1;
cout << "Time to change gears!";
return 0; // better than break.
//break;
}
}
// if (change == 1){
//
// cout << "Time to change gears!";
// }
// else
cout << "Ride on!";
// for (auto v:crank){
//
// cout << v << " " ;
// }
//
// cout << endl;
// cout << endl;
//
//
// for (auto v:back){
//
// cout << v << " " ;
// }
//
// cout << endl;
// cout << endl;
//
// for (auto v:gear){
//
// cout << v << " " ;
// }
//
return 0;
}