#include <math.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <iostream>
using namespace std;
const double PI = 3.1415926535897932384626433832795;
struct circle {
double radius;
char code;
circle()
: radius(0.0)
, code(' ') {
}
circle(double x, double y, char c) {
radius = sqrt(x*x + y*y);
code = c;
}
bool operator < (const circle& c) const {
return radius < c.radius;
}
bool operator > (const circle& c) const {
return !(*this < c);
}
double length() const {
return radius * PI * 2;
}
};
int main(int argc, char* argv[]) {
vector<circle> v(3);
v[0] = circle(5.6, 2.3, 'A');
v[1] = circle(-10.1, 4.7, 'B');
v[2] = circle(7.4, -12.3, 'C');
sort(v.begin(), v.end(), greater<circle>());
for(vector<circle>::iterator iter = v.begin();
iter != v.end();
++iter)
cout << "Circle: " << iter->code << ", length: " << iter->length() << endl;
return 0;
}
Если Вы уже зарегистрированы на Портале - войдите в систему, если Вы еще не регистрировались - пройдите простую процедуру регистрации.