Title Description
Enter the length of the three edges, if the three edges can form a triangle, you need to calculate the Triangle area, and if you cannot form a triangle, output the hint message "error input". Output area is output as two decimal places
Input
Length of three sides
Output
If these three edges can form a triangle, the area of the triangle is output, and if the three edges do not form a triangle, the output cue message "Error input"
Sample input
3.3 4.4 5.5
Sample output
area=7.26
Tips
Retain two decimal places when output area
Code:
#include <iostream> #include <cstdio> #include <cmath> #include <iomanip>using namespace std; int main () { double a,b,c,l,s,m; cin>>a>>b>>c; L= (A+B+C)/2; m=l* (l-a) * (l-b) * (l-c); if (a+b>c&&a-b<c&&b-a<c) { s=sqrt (m); cout<< "Area=" <<setiosflags (ios::fixed) <<setprecision (2) <<s; } else cout<< "error input"; return 0;}
Operation Result:
Learning experience:
Good study Day Day up
OJ Final Brush question B: Finding the triangular area-gyy