Cho chu vi P và diện tích A, tìm thể tích lớn nhất của hộp chữ nhật. Ví dụ P=24, A=24 → thể tích 8.
Công thức: P=4(l+b+d), A=2(lb+bd+ld), V=lbd. Diễn giải toán học cho ra thể tích tối đa.
Ví dụ
#include<iostream> #include<cmath> using namespace std; float maxVolumeCuboid(float Peri, float Area) { float length = (Peri - sqrt(Peri * Peri - 24 * Area)) / 12; float Vol = length * (Area / 2.0 - length * (Peri / 4.0 - length)); return Vol; } int main() { float P = 20, A = 16; cout << "Maximum volume of the cuboid will be: " << maxVolumeCuboid(P, A); }
Kết quả
Maximum volume of the cuboid will be: 4.14815