Загрузил ciyew43689

3class

реклама
#include <iostream>
#include <cmath>
using namespace std;
class Circle {
private:
double radius;
public:
Circle(double radius) {
this->radius = radius;
}
double area() {
return M_PI * pow(radius, 2);
}
double circumference() {
return 2 * M_PI * radius;
}
void print_info() {
cout << "Circle with radius " << radius << endl;
cout << "Area: " << area() << endl;
cout << "Circumference: " << circumference() << endl;
}
};
int main() {
const int N = 4;
Circle circles[N] = { Circle(2), Circle(4), Circle(1), Circle(5) };
Circle max_area_circle = circles[0];
for (int i = 1; i < N; i++) {
if (circles[i].area() > max_area_circle.area()) {
max_area_circle = circles[i];
}
}
Circle min_circumference_circle = circles[0];
for (int i = 1; i < N; i++) {
if (circles[i].circumference() < min_circumference_circle.circumference()) {
min_circumference_circle = circles[i];
}
}
cout << "Max area circle:" << endl;
max_area_circle.print_info();
cout << "Min circumference circle:" << endl;
min_circumference_circle.print_info();
return 0;
}
Скачать