Odpowiedź:
#include <iostream>
#include <cmath>
using namespace std;
float poletrojkata(float a, float b, float c){
float p = (a+b+c)/2;
return sqrt(p*(p-a)*(p-b)*(p-c));
}
float pole(float a,float b,float c,float h){
return a*h+b*h+c*h+poletrojkata(a,b,c);
}
float objetosc(float a,float b,float c,float h){
return poletrojkata(a,b,c)*h/3;
}
int main()
{
float a,b,c,h;
cout << "podaj a,b,c,h\n";
cin >> a >> b >> c >> h;
cout << "pole(P) czy objetosc(V)\n";
string poleCzyObjetosc;
cin >> poleCzyObjetosc;
if (poleCzyObjetosc == "P")
cout << "pole to: " << pole(a,b,c,h);
else if (poleCzyObjetosc == "V")
cout << "objetosc to: " << objetosc(a,b,c,h);
else
cout << "bledne dane!\n";
return 0;
}