formatting
This commit is contained in:
@@ -164,6 +164,7 @@ public:
|
||||
Line(const Point &a_, const Point &b_) : a(a_),b(b_) {}
|
||||
Point a,b;
|
||||
};
|
||||
|
||||
double compute_slope(const Point &a, const Point &b) throw(int) {
|
||||
double rise = b.y - a.y;
|
||||
double run = b.x - a.x;
|
||||
@@ -174,14 +175,17 @@ return rise / run;
|
||||
double slope(const Line &ln) {
|
||||
return compute_slope(ln.a,ln.b);
|
||||
}
|
||||
|
||||
bool steeper_slope(const Line &m, const Line &n) {
|
||||
double slope_m = slope(m);
|
||||
double slope_n = slope(n);
|
||||
return slope_m > slope_n;
|
||||
}
|
||||
|
||||
void organize(std::vector<Line> &lines) {
|
||||
std::sort(lines.begin(),lines.end(), steeper_slope);
|
||||
}
|
||||
|
||||
int main () {
|
||||
std::vector<Line> lines;
|
||||
/* omitting code to initialize some data */
|
||||
@@ -210,6 +214,7 @@ virtual const char* what() const throw() {
|
||||
return "My exception happened";
|
||||
}
|
||||
};
|
||||
|
||||
int main () {
|
||||
myexception myex;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user